Changeset 1156 for trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh
- Timestamp:
- 01/27/15 16:50:10 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh
r1155 r1156 1035 1035 # Check if AUTO is set in the filein on the same line as the key variable 1036 1036 if [ $( grep -w $key $filein | grep -v "\#" | grep AUTO | wc -l ) = 1 ] ; then 1037 # Modification will be done for all cases 1037 # Modification will be done for all cases 1038 modify=yes 1039 else 1040 # The variable was not set to AUTO 1041 if [ $type = blocker ] ; then 1042 # Exit because this is a blocker call 1043 IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key cannot be modified. It should be set to AUTO." 1044 return 1045 elif [ $type = nonblocker ] ; then 1046 # Do nothing. Suppose that the user did set the variable correct 1047 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: $key is set by the user. Nothing done." 1048 modify=no 1049 elif [ $type = force ] ; then 1050 # Force modification 1051 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile : Variabl=$key was not set to AUTO. Modification will be forced." 1038 1052 modify=yes 1039 else 1040 # The variable was not set to AUTO 1041 if [ $type = blocker ] ; then 1042 # Exit because this is a blocker call 1043 IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key cannot be modified. It should be set to AUTO." 1044 return 1045 elif [ $type = nonblocker ] ; then 1046 # Do nothing. Suppose that the user did set the variable correct 1047 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: $key is set by the user. Nothing done." 1048 modify=no 1049 elif [ $type = force ] ; then 1050 # Force modification 1051 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile : Variabl=$key was not set to AUTO. Modification will be forced." 1052 modify=yes 1053 fi 1053 fi 1054 1054 fi 1055 1055 … … 1057 1057 if [ $modify = yes ] ; then 1058 1058 1059 # For option DEFAULT, read default value from file. 1060 if [ X"$value" = XDEFAULT ] || [ X"$value" = X ] ; then 1061 # Case to set DEFAULT value 1062 # Read default value from filein 1063 value=$( grep $key $filein | grep -v "\#" | awk -F"DEFAULT *=" '{print $2}') 1064 1065 if [ X"$value" = X ] ; then 1066 IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key needs a DEFAULT value in $filein." 1067 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: The syntax in $filein should be:" 1068 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: $key=_AUTO_:DEFAULT=def_value" 1069 IGCM_debug_PopStack "IGCM_comp_modifyDefFile" 1070 return 1071 fi 1059 # For option DEFAULT, read default value from file. 1060 if [ X"$value" = XDEFAULT ] || [ X"$value" = X ] ; then 1061 # Case to set DEFAULT value 1062 # Read default value from filein 1063 value=$( grep $key $filein | grep -v "\#" | awk -F"DEFAULT *=" '{print $2}') 1064 1065 if [ X"$value" = X ] ; then 1066 IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key needs a DEFAULT value in $filein." 1067 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: The syntax in $filein should be:" 1068 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: $key=_AUTO_:DEFAULT=def_value" 1069 IGCM_debug_PopStack "IGCM_comp_modifyDefFile" 1070 return 1072 1071 fi 1073 1074 # Now change key in filein 1075 sed -e "s/^${key}\ *=.*/${key}= ${value}/" $filein > $filein.tmp 1076 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: In $filein set $key=$value" 1077 \mv $filein.tmp $filein 1072 fi 1073 1074 # Now change key in filein 1075 sed -e "s/^${key}\ *=.*/${key}= ${value}/" $filein > $filein.tmp 1076 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: In $filein set $key=$value" 1077 \mv $filein.tmp $filein 1078 1078 fi 1079 1079 IGCM_debug_PopStack "IGCM_comp_modifyDefFile" … … 1140 1140 # Verify the existance of the pattern 1141 1141 if [ X"$pattern" = X ] ; then 1142 # Variable key is not set in filein, stop. 1143 IGCM_debug_Exit "IGCM_comp_modifyNamelist : Variable $key is not set in correct file. It should be set in $filein." 1142 # Variable key is not set in filein, stop. 1143 IGCM_debug_Exit "IGCM_comp_modifyNamelist : Variable $key is not set in correct file. It should be set in $filein." 1144 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 1145 return 1146 fi 1147 1148 # Check if the variable is set to AUTO in the filein 1149 if [ $( echo $pattern | grep AUTO | wc -l ) = 1 ] ; then 1150 # Modification will be done for all cases 1151 modify=yes 1152 else 1153 # The variable was not set to AUTO 1154 if [ $type = blocker ] ; then 1155 # Exit because this is a blocker call 1156 IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable $key cannot be modified. It should be set to AUTO." 1144 1157 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 1145 1158 return 1146 fi 1147 1148 # Check if the variable is set to AUTO in the filein 1149 if [ $( echo $pattern | grep AUTO | wc -l ) = 1 ] ; then 1150 # Modification will be done for all cases 1159 elif [ $type = nonblocker ] ; then 1160 # Do nothing. Suppose that the user did set the variable correct 1161 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: $key is set by the user. Nothing done." 1162 modify=no 1163 elif [ $type = force ] ; then 1164 # Force modification 1165 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist : Variabl=$key was not set to AUTO. Modification will be forced." 1151 1166 modify=yes 1152 else 1153 # The variable was not set to AUTO 1154 if [ $type = blocker ] ; then 1155 # Exit because this is a blocker call 1156 IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable $key cannot be modified. It should be set to AUTO." 1157 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 1158 return 1159 elif [ $type = nonblocker ] ; then 1160 # Do nothing. Suppose that the user did set the variable correct 1161 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: $key is set by the user. Nothing done." 1162 modify=no 1163 elif [ $type = force ] ; then 1164 # Force modification 1165 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist : Variabl=$key was not set to AUTO. Modification will be forced." 1166 modify=yes 1167 fi 1167 fi 1168 1168 fi 1169 1169 … … 1171 1171 if [ $modify = yes ] ; then 1172 1172 1173 # For option DEFAULT, read default value from file. 1174 if [ X"$value" = XDEFAULT ] || [ X"$value" = X ] ; then 1175 # Case to set DEFAULT value 1176 # Read default value from filein 1177 value=$( echo $pattern | awk -F"DEFAULT *=" '{print $2}') 1178 1179 if [ X"$value" = X ] ; then 1180 IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable $key needs a DEFAULT value in $filein." 1181 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: The syntax in $filein should be:" 1182 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: $key=_AUTO_:DEFAULT=def_value" 1183 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 1184 return 1185 fi 1173 # For option DEFAULT, read default value from file. 1174 if [ X"$value" = XDEFAULT ] || [ X"$value" = X ] ; then 1175 # Case to set DEFAULT value 1176 # Read default value from filein 1177 value=$( echo $pattern | awk -F"DEFAULT *=" '{print $2}') 1178 1179 if [ X"$value" = X ] ; then 1180 IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable $key needs a DEFAULT value in $filein." 1181 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: The syntax in $filein should be:" 1182 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: $key=_AUTO_:DEFAULT=def_value" 1183 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 1184 return 1186 1185 fi 1187 1188 # Now change key in filein 1189 sed -e "s/${pattern}/ $key=${value}/" $filein > $filein.tmp 1190 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: In $filein set $key=$value" 1191 \mv $filein.tmp $filein 1186 fi 1187 1188 # Now change key in filein 1189 sed -e "s/${pattern}/ $key=${value}/" $filein > $filein.tmp 1190 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: In $filein set $key=$value" 1191 \mv $filein.tmp $filein 1192 1192 fi 1193 1193 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" … … 1282 1282 sed -e "s/\(<[^\"]*\"${keyid}\".*>\)\([^<]*\)\(<[^>]*\)/\1${value}\3/" $filein > $filein.tmp 1283 1283 else 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1284 # Check if keyattrib is set on the same line as keyid 1285 if [ $( grep -w $keyid $filein | grep $keyattrib | wc -l ) = 1 ] ; then 1286 # Case to modify the attribute value 1287 IGCM_debug_Print 1 "Now modify ${filein} for id=${keyid} by setting attribute to ${keyattrib}=${value}" 1288 sed -e "/id=\"${keyid}\"/s/\(${keyattrib}=\"\)[^\"]*\(\"\)/\1${value}\2/" $filein > $filein.tmp 1289 else 1290 # Case to add the attribute and its value 1291 IGCM_debug_Print 1 "Now add in ${filein} for id=${keyid} the attribute ${keyattrib} to the value ${value}" 1292 sed -e "/id=\"${keyid}\"/s/\/>/ ${keyattrib}=\"${value}\"\/>/" $filein > $filein.tmp 1293 fi 1294 1294 fi 1295 1295 \mv $filein.tmp $filein
Note: See TracChangeset
for help on using the changeset viewer.