- Timestamp:
- 01/27/15 16:45:34 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh
r1151 r1155 991 991 IGCM_debug_Print 1 "Entering IGCM_comp_modifyDefFile with arguments: $type $filein $key $value" 992 992 993 994 993 # Test if first argument is correct 995 994 if [ $type != blocker ] && [ $type != nonblocker ] && [ $type != force ] ; then … … 1033 1032 IGCM_debug_Exit "IGCM_comp_modifyDefFile : Variable $key is not set in correct file. It should be set in $filein." 1034 1033 fi 1035 1036 1034 1037 1035 # Check if AUTO is set in the filein on the same line as the key variable … … 1044 1042 # Exit because this is a blocker call 1045 1043 IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key cannot be modified. It should be set to AUTO." 1046 1044 return 1047 1045 elif [ $type = nonblocker ] ; then 1048 1046 # Do nothing. Suppose that the user did set the variable correct … … 1051 1049 elif [ $type = force ] ; then 1052 1050 # Force modification 1053 1054 1051 IGCM_debug_Print 1 "IGCM_comp_modifyDefFile : Variabl=$key was not set to AUTO. Modification will be forced." 1052 modify=yes 1055 1053 fi 1056 1054 fi … … 1082 1080 } 1083 1081 1084 1085 1082 #======================================================================= 1086 1083 function IGCM_comp_modifyNamelist … … 1092 1089 # 1093 1090 # This function is used to modify a parameter file for a specific variable. 1094 # The file must be a " .def" file, i.e. with IOIPSL parameter filesyntax.1091 # The file must be a "namelist" file, i.e. with fortran namelist syntax. 1095 1092 # This function can be used in the comp.driver files for the components. 1096 1093 # … … 1124 1121 IGCM_debug_Print 1 "Entering IGCM_comp_modifyNamelist with arguments: $type $filein $key $value" 1125 1122 1126 1127 1123 # Test if first argument is correct 1128 1124 if [ $type != blocker ] && [ $type != nonblocker ] && [ $type != force ] ; then … … 1141 1137 # Read the line with key in the file without the comments 1142 1138 pattern=$( grep "^ *$key *=" $filein | sed -e "s% *\!.*%%" ) 1143 1139 1144 1140 # Verify the existance of the pattern 1145 1141 if [ X"$pattern" = X ] ; then … … 1149 1145 return 1150 1146 fi 1151 1147 1152 1148 # Check if the variable is set to AUTO in the filein 1153 1149 if [ $( echo $pattern | grep AUTO | wc -l ) = 1 ] ; then … … 1159 1155 # Exit because this is a blocker call 1160 1156 IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable $key cannot be modified. It should be set to AUTO." 1161 1162 1157 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 1158 return 1163 1159 elif [ $type = nonblocker ] ; then 1164 1160 # Do nothing. Suppose that the user did set the variable correct … … 1167 1163 elif [ $type = force ] ; then 1168 1164 # Force modification 1169 1170 1165 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist : Variabl=$key was not set to AUTO. Modification will be forced." 1166 modify=yes 1171 1167 fi 1172 1168 fi … … 1185 1181 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: The syntax in $filein should be:" 1186 1182 IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: $key=_AUTO_:DEFAULT=def_value" 1187 1183 IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 1188 1184 return 1189 1185 fi … … 1208 1204 # 1209 1205 # This function is used to modify the value for a specific attribute and variable id. 1210 # The file must be a of xml syntax.1206 # The file must be a valid xml file. 1211 1207 # This function can be used in the comp.driver files for the components. 1212 1208 # … … 1286 1282 sed -e "s/\(<[^\"]*\"${keyid}\".*>\)\([^<]*\)\(<[^>]*\)/\1${value}\3/" $filein > $filein.tmp 1287 1283 else 1288 1289 1284 # Check if keyattrib is set on the same line as keyid 1285 if [ $( grep -w $keyid $filein | grep $keyattrib | wc -l ) = 1 ] ; then 1290 1286 # Case to modify the attribute value 1291 1292 1293 1294 1295 1296 1297 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 1298 1294 fi 1299 1295 \mv $filein.tmp $filein
Note: See TracChangeset
for help on using the changeset viewer.