Ignore:
Timestamp:
10/07/14 12:27:21 (10 years ago)
Author:
jgipsl
Message:

Added option force in function IGCM_comp_modifyDefFile

File:
1 edited

Legend:

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

    r1080 r1081  
    957957# 
    958958# Arguments: 
    959 # - type   : first argument must be blocker or nonblocker. 
     959# - type   : first argument must be blocker, nonblocker or force 
    960960#            For "blocker" case, the variable must be attributed the keyworld AUTO 
    961961#            otherwise this function will exit. 
    962962#            For "nonblocker" case, the user can remove or modify the variable. For 
    963963#            this case, as long as AUTO is not set, no modification will be done. 
     964#            For "force" case, the variable will be modified even if it is not set to AUTO 
    964965# - filein : the file in run directory of .def type in which the variable should be set 
    965966# - key    : the variable to modify 
     
    984985  IGCM_debug_Print 1 "Entering IGCM_comp_modifyDefFile with arguments: $type $filein $key $value" 
    985986 
     987 
    986988  # Test if first argument is correct 
    987   if [ $type != blocker ] && [ $type != nonblocker ] ; then 
    988     IGCM_debug_Exit "IGCM_comp_modifyDefFile: Error in first argument must be blocker or nonblocker" 
     989  if [ $type != blocker ] && [ $type != nonblocker ] && [ $type != force ] ; then 
     990    IGCM_debug_Exit "IGCM_comp_modifyDefFile: Error in first argument must be blocker, nonblocker or force" 
    989991    IGCM_debug_PopStack "IGCM_comp_modifyDefFile" 
    990992    return 
     
    10201022    IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: $key is not set in $filein. This is a nonblocker call so nothing is done." 
    10211023    IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: Default value for $key from the model will be used." 
     1024    modify=no 
    10221025  elif [ $( grep $key $filein | grep -v "\#"  |wc -l ) = 0 ] ; then 
    10231026    # Variable key is not set in filein, stop. 
    10241027    IGCM_debug_Exit "IGCM_comp_modifyDefFile : Variable $key is not set in correct file. It should be set in $filein." 
     1028  fi 
     1029   
     1030 
     1031  # Check if AUTO is set in the filein on the same line as the key variable 
     1032  if [ $( grep $key $filein | grep -v "\#" | grep AUTO | wc -l ) = 1 ] ; then 
     1033      # Modification will be done for all cases 
     1034      modify=yes 
    10251035  else 
    1026     # Read the value of key from filein 
    1027     if [ X"$( grep $key $filein | grep -v "\#" | grep AUTO )" = "X" ] ; then 
    1028       # The key variable is not set to AUTO 
     1036      # The variable was not set to AUTO 
    10291037      if [ $type = blocker ] ; then 
    1030         # Stop because this is a blocker call 
    1031         IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key cannot be modified. It should be set to AUTO." 
    1032       else 
    1033         # Do nothing. Suppose that the user did set the variable correct 
    1034         IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: $key is set by the user. Nothing done." 
     1038          # Exit because this is a blocker call 
     1039          IGCM_debug_Exit "IGCM_comp_modifyDefFile : The variable $key cannot be modified. It should be set to AUTO." 
     1040          return 
     1041       elif [ $type = nonblocker ] ; then 
     1042          # Do nothing. Suppose that the user did set the variable correct 
     1043          IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: $key is set by the user. Nothing done." 
     1044          modify=no 
     1045       elif [ $type = force ] ; then 
     1046          # Force modification 
     1047          IGCM_debug_Print 1 "IGCM_comp_modifyDefFile : Variabl=$key was not set to AUTO. Modification will be forced." 
     1048          modify=yes 
    10351049      fi 
    1036     else 
    1037       # The variable key is set to AUTO. 
     1050  fi 
     1051 
     1052  # Do the modifcation now 
     1053  if [ $modify = yes ] ; then 
    10381054 
    10391055      # For option DEFAULT, read default value from file. 
     
    10561072      IGCM_debug_Print 1 "IGCM_comp_modifyDefFile: In $filein set $key=$value" 
    10571073      \mv $filein.tmp $filein 
    1058     fi 
    10591074  fi 
    10601075  IGCM_debug_PopStack "IGCM_comp_modifyDefFile" 
Note: See TracChangeset for help on using the changeset viewer.