Changeset 1155 for trunk


Ignore:
Timestamp:
01/27/15 16:45:34 (9 years ago)
Author:
sdipsl
Message:
  • enhanced comments
  • whitespace clean up
File:
1 edited

Legend:

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

    r1151 r1155  
    991991  IGCM_debug_Print 1 "Entering IGCM_comp_modifyDefFile with arguments: $type $filein $key $value" 
    992992 
    993  
    994993  # Test if first argument is correct 
    995994  if [ $type != blocker ] && [ $type != nonblocker ] && [ $type != force ] ; then 
     
    10331032    IGCM_debug_Exit "IGCM_comp_modifyDefFile : Variable $key is not set in correct file. It should be set in $filein." 
    10341033  fi 
    1035    
    10361034 
    10371035  # Check if AUTO is set in the filein on the same line as the key variable 
     
    10441042          # Exit because this is a blocker call 
    10451043          IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key cannot be modified. It should be set to AUTO." 
    1046           return 
     1044          return 
    10471045       elif [ $type = nonblocker ] ; then 
    10481046          # Do nothing. Suppose that the user did set the variable correct 
     
    10511049       elif [ $type = force ] ; then 
    10521050          # Force modification 
    1053           IGCM_debug_Print 1 "IGCM_comp_modifyDefFile : Variabl=$key was not set to AUTO. Modification will be forced." 
    1054           modify=yes 
     1051          IGCM_debug_Print 1 "IGCM_comp_modifyDefFile : Variabl=$key was not set to AUTO. Modification will be forced." 
     1052          modify=yes 
    10551053      fi 
    10561054  fi 
     
    10821080} 
    10831081 
    1084  
    10851082#======================================================================= 
    10861083function IGCM_comp_modifyNamelist 
     
    10921089# 
    10931090# 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 file syntax. 
     1091# The file must be a "namelist" file, i.e. with fortran namelist syntax. 
    10951092# This function can be used in the comp.driver files for the components. 
    10961093# 
     
    11241121  IGCM_debug_Print 1 "Entering IGCM_comp_modifyNamelist with arguments: $type $filein $key $value" 
    11251122 
    1126  
    11271123  # Test if first argument is correct 
    11281124  if [ $type != blocker ] && [ $type != nonblocker ] && [ $type != force ] ; then 
     
    11411137  # Read the line with key in the file without the comments 
    11421138  pattern=$( grep "^ *$key *=" $filein | sed -e "s% *\!.*%%" ) 
    1143    
     1139 
    11441140  # Verify the existance of the pattern 
    11451141  if [ X"$pattern" = X ] ; then 
     
    11491145      return 
    11501146  fi 
    1151    
     1147 
    11521148  # Check if the variable is set to AUTO in the filein 
    11531149  if [ $( echo $pattern | grep AUTO | wc -l ) = 1 ] ; then 
     
    11591155          # Exit because this is a blocker call 
    11601156          IGCM_debug_Exit "IGCM_comp_modifyNamelist : The variable $key cannot be modified. It should be set to AUTO." 
    1161           IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 
    1162           return 
     1157          IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 
     1158          return 
    11631159       elif [ $type = nonblocker ] ; then 
    11641160          # Do nothing. Suppose that the user did set the variable correct 
     
    11671163       elif [ $type = force ] ; then 
    11681164          # Force modification 
    1169           IGCM_debug_Print 1 "IGCM_comp_modifyNamelist : Variabl=$key was not set to AUTO. Modification will be forced." 
    1170           modify=yes 
     1165          IGCM_debug_Print 1 "IGCM_comp_modifyNamelist : Variabl=$key was not set to AUTO. Modification will be forced." 
     1166          modify=yes 
    11711167      fi 
    11721168  fi 
     
    11851181          IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: The syntax in $filein should be:" 
    11861182          IGCM_debug_Print 1 "IGCM_comp_modifyNamelist: $key=_AUTO_:DEFAULT=def_value" 
    1187           IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 
     1183          IGCM_debug_PopStack "IGCM_comp_modifyNamelist" 
    11881184          return 
    11891185        fi 
     
    12081204# 
    12091205# 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. 
    12111207# This function can be used in the comp.driver files for the components. 
    12121208# 
     
    12861282      sed -e "s/\(<[^\"]*\"${keyid}\".*>\)\([^<]*\)\(<[^>]*\)/\1${value}\3/" $filein > $filein.tmp 
    12871283    else 
    1288           # Check if keyattrib is set on the same line as keyid 
    1289         if [  $( grep -w $keyid $filein | grep $keyattrib | wc -l ) = 1 ] ; then 
     1284          # Check if keyattrib is set on the same line as keyid 
     1285        if [  $( grep -w $keyid $filein | grep $keyattrib | wc -l ) = 1 ] ; then 
    12901286            # Case to modify the attribute value 
    1291             IGCM_debug_Print 1 "Now modify ${filein} for id=${keyid} by setting attribute to ${keyattrib}=${value}" 
    1292             sed -e "/id=\"${keyid}\"/s/\(${keyattrib}=\"\)[^\"]*\(\"\)/\1${value}\2/" $filein > $filein.tmp 
    1293         else 
    1294             # Case to add the attribute and its value 
    1295              IGCM_debug_Print 1 "Now add in ${filein} for id=${keyid} the attribute ${keyattrib} to the value ${value}" 
    1296              sed -e "/id=\"${keyid}\"/s/\/>/ ${keyattrib}=\"${value}\"\/>/" $filein > $filein.tmp 
    1297         fi 
     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 
    12981294    fi 
    12991295    \mv $filein.tmp $filein 
Note: See TracChangeset for help on using the changeset viewer.