Ignore:
Timestamp:
01/27/15 16:50:10 (9 years ago)
Author:
sdipsl
Message:
  • homogenize indentation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh

    r1155 r1156  
    10351035  # Check if AUTO is set in the filein on the same line as the key variable 
    10361036  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." 
    10381052      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 
    10541054  fi 
    10551055 
     
    10571057  if [ $modify = yes ] ; then 
    10581058 
    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 
    10721071      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 
    10781078  fi 
    10791079  IGCM_debug_PopStack "IGCM_comp_modifyDefFile" 
     
    11401140  # Verify the existance of the pattern 
    11411141  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." 
    11441157      IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 
    11451158      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." 
    11511166      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 
    11681168  fi 
    11691169 
     
    11711171  if [ $modify = yes ] ; then 
    11721172 
    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 
    11861185      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 
    11921192  fi 
    11931193  IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 
     
    12821282      sed -e "s/\(<[^\"]*\"${keyid}\".*>\)\([^<]*\)\(<[^>]*\)/\1${value}\3/" $filein > $filein.tmp 
    12831283    else 
    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 
     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 
    12941294    fi 
    12951295    \mv $filein.tmp $filein 
Note: See TracChangeset for help on using the changeset viewer.