Index: /issm/trunk/src/c/EnumDefinitions/EnumToModelField.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumToModelField.cpp	(revision 5226)
+++ /issm/trunk/src/c/EnumDefinitions/EnumToModelField.cpp	(revision 5227)
@@ -15,5 +15,5 @@
 		case ThicknessEnum : return "thickness";
 		case DragCoefficientEnum : return "drag_coefficient";
-		default : return "unknown";
+		default : return ISSMERROR("No model field is associated to enum %s",EnumToString(en));
 	}
 }
Index: /issm/trunk/src/c/EnumDefinitions/EnumToString.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/EnumToString.cpp	(revision 5226)
+++ /issm/trunk/src/c/EnumDefinitions/EnumToString.cpp	(revision 5227)
@@ -4,5 +4,5 @@
 *
 *   WARNING: DO NOT MODIFY THIS FILE
-*            this file has been automatically generated by SynchronizeStrings.sh
+*            this file has been automatically generated by Synchronize.sh
 *            Please read README for more information
 */
Index: /issm/trunk/src/c/EnumDefinitions/README
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/README	(revision 5226)
+++ /issm/trunk/src/c/EnumDefinitions/README	(revision 5227)
@@ -4,13 +4,7 @@
 - EnumToString.cpp
 - src/m/enum/*
-all these files are automatically synchronized with EnumDefinitions.h
+all these files are automatically synchronized with EnumDefinitions.h and EnumToModelField.cpp
 
 TO ADD AN ENUM:
 add the corresponding lines to EnumDefinitions.h
-and executes the 2 synchronizing scripts.
-
-SYNCHRONIZEMATLABENUM
-This script synchronizes all matlab enums from EnumDefinitions.h
-
-SYNCHRONIZESTRINGS
-This scrpit synchronizes StringToEnum.cpp and EnumToString.cpp according to EnumDefinitions.h
+and execute synchronizing script.
Index: /issm/trunk/src/c/EnumDefinitions/StringToEnum.cpp
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/StringToEnum.cpp	(revision 5226)
+++ /issm/trunk/src/c/EnumDefinitions/StringToEnum.cpp	(revision 5227)
@@ -4,5 +4,5 @@
 *
 *   WARNING: DO NOT MODIFY THIS FILE
-*            this file has been automatically generated by SynchronizeStrings.sh
+*            this file has been automatically generated by Synchronize.sh
 *            Please read README for more information
 */
Index: /issm/trunk/src/c/EnumDefinitions/Synchronize.sh
===================================================================
--- /issm/trunk/src/c/EnumDefinitions/Synchronize.sh	(revision 5226)
+++ /issm/trunk/src/c/EnumDefinitions/Synchronize.sh	(revision 5227)
@@ -1,4 +1,5 @@
 #!/bin/bash
 #Synchronize EnumToString.cpp and StringToEnum.cpp
+
 
 #first remove existing files
@@ -6,5 +7,32 @@
 rm $ISSM_DIR/src/m/enum/*.m
 
-echo "Synchronizing EnumToString..."
+echo "Synchronizing Enums..."
+
+#Take care of EnumToModelField.m first (easy)
+#Build EnumToModelField.m {{{1
+cat <<END > EnumToModelField.m
+function string=EnumToModelField(enum)
+%ENUMTOMODELFIELD - output string of model field associated to enum
+%
+%   WARNING: DO NOT MODIFY THIS FILE
+%            this file has been automatically generated by src/c/Synchronize.sh
+%            Please read src/c/README for more information
+%
+%   Usage:
+%      string=EnumToModelField(enum)
+
+switch enum,
+
+END
+
+cat EnumToModelField.cpp | grep "case" | sed -e "s/Enum/Enum()/g" -e "s/\"/'/g" >> EnumToModelField.m
+
+cat <<END >> EnumToModelField.m
+otherwise, error(['Enum ' num2str(enum)  ' not found associated to any model field']);
+
+end
+END
+#}}}
+
 #Get all lines of EnumDefinitions2.h which hold Enum | remove all comas | add line number in the first column > put everything in file temp
 cat EnumDefinitions.h | grep -e "[0-9]Enum" -e "[Aa-Zz]Enum" | grep -v StringToEnum | sed -e "s/,//g" | awk '{ printf "%s %s\n", NR, $0 }' > temp
@@ -17,5 +45,5 @@
 *
 *   WARNING: DO NOT MODIFY THIS FILE
-*            this file has been automatically generated by SynchronizeStrings.sh
+*            this file has been automatically generated by Synchronize.sh
 *            Please read README for more information
 */
@@ -38,5 +66,5 @@
 *
 *   WARNING: DO NOT MODIFY THIS FILE
-*            this file has been automatically generated by SynchronizeStrings.sh
+*            this file has been automatically generated by Synchronize.sh
 *            Please read README for more information
 */
@@ -56,5 +84,5 @@
 %
 %   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/SynchronizeMatlabEnum
+%            this file has been automatically generated by src/c/Synchronize.sh
 %            Please read src/c/README for more information
 %
@@ -72,5 +100,5 @@
 %
 %   WARNING: DO NOT MODIFY THIS FILE
-%            this file has been automatically generated by src/c/SynchronizeMatlabEnum
+%            this file has been automatically generated by src/c/Synchronize.sh
 %            Please read src/c/README for more information
 %
@@ -198,4 +226,5 @@
 mv StringToEnum.m         $ISSM_DIR/src/m/enum/
 mv EnumToString.m         $ISSM_DIR/src/m/enum/
+mv EnumToModelField.m     $ISSM_DIR/src/m/enum/
 #}}}
 #clean up{{{
