[2330] | 1 | #!/bin/ksh |
---|
[3061] | 2 | ## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE |
---|
[2330] | 3 | #----------------------------------------------------------------- |
---|
| 4 | function SRF_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "SRF_Initialize" |
---|
| 7 | |
---|
| 8 | ##- Define variable DefSuffix set in orchidee.card |
---|
[2694] | 9 | ## This variable is used in orchidee.card to choose |
---|
| 10 | ## parameter file(orchidee.def_DefSuffix). |
---|
[2330] | 11 | if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then |
---|
[2694] | 12 | DefSuffix=${orchidee_UserChoices_DefSuffix} |
---|
[2330] | 13 | else |
---|
[2694] | 14 | DefSuffix=Choi |
---|
[2330] | 15 | fi |
---|
| 16 | |
---|
| 17 | IGCM_debug_PopStack "SRF_Initialize" |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | #----------------------------------------------------------------- |
---|
| 21 | function SRF_Update |
---|
| 22 | { |
---|
| 23 | IGCM_debug_PushStack "SRF_Update" |
---|
| 24 | |
---|
[2694] | 25 | ## 1. Modifications in orchidee.def parameter file |
---|
| 26 | |
---|
[2346] | 27 | # Activate STOMATE if the compontent SBG=stomate is set in config.card |
---|
| 28 | if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then |
---|
[2694] | 29 | # Activate stomate in orchidee.def |
---|
| 30 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y |
---|
[2346] | 31 | else |
---|
[2694] | 32 | # Deactivate stomate in orchidee.def |
---|
| 33 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n |
---|
| 34 | # Deactivate output files for stomate |
---|
| 35 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE. |
---|
[2907] | 36 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo |
---|
[2694] | 37 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE. |
---|
[2907] | 38 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo |
---|
[2346] | 39 | fi |
---|
| 40 | |
---|
[2694] | 41 | # Define in orchidee.def if restart file should be used |
---|
[2330] | 42 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
[2694] | 43 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc |
---|
[2330] | 44 | else |
---|
[2694] | 45 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE |
---|
[2330] | 46 | fi |
---|
| 47 | |
---|
[2770] | 48 | # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices |
---|
[2330] | 49 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
[2694] | 50 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
[2330] | 51 | else |
---|
[2694] | 52 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y |
---|
[2330] | 53 | fi |
---|
| 54 | |
---|
[2694] | 55 | # Activate creation of river description file only for the first period |
---|
| 56 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 57 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y |
---|
| 58 | else |
---|
| 59 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n |
---|
| 60 | fi |
---|
[2330] | 61 | |
---|
| 62 | |
---|
[2694] | 63 | ## 2. Mangement of output and modifications of related xml files |
---|
| 64 | |
---|
[3061] | 65 | # Set default values for sechiba1_enabled and sechiba1_freq. |
---|
| 66 | # These variables are used only to modify file_def_orchidee.xml |
---|
[2694] | 67 | sechiba1_enabled=.FALSE. |
---|
| 68 | sechiba2_enabled=.FALSE. |
---|
| 69 | sechiba1_freq=0s |
---|
[3061] | 70 | sechiba2_freq=0s |
---|
[2694] | 71 | |
---|
[3061] | 72 | |
---|
| 73 | # Get WriteFrenquecy for SRF (SECHIBA) from config.card |
---|
| 74 | # 1 or 2 frequencies can be set in WriteFrenquecy for SRF |
---|
| 75 | # The first frequency will always be used for the sechiba_history file and the |
---|
| 76 | # second frequency will be used for the sechiba_out_2.nc file. |
---|
| 77 | # The files are activated only if its corresponding frequency is set in WriteFrequency |
---|
| 78 | ifreq=0 |
---|
[2694] | 79 | for frequency in ${config_SRF_WriteFrequency} ; do |
---|
| 80 | case ${frequency} in |
---|
| 81 | *Y|*y) |
---|
| 82 | NbYears=$( echo ${frequency} | awk -F '[yY]' '{print $1}' ) |
---|
| 83 | NbDaysYear=$( IGCM_date_DaysInYear ${year} ) |
---|
[3061] | 84 | file_enabled=.TRUE. |
---|
| 85 | file_freq=${NbYears}y ;; |
---|
[2694] | 86 | *M|*m) |
---|
| 87 | NbMonths=$( echo ${frequency} | awk -F '[mM]' '{print $1}' ) |
---|
[3061] | 88 | file_enabled=.TRUE. |
---|
| 89 | file_freq=${NbMonths}mo ;; |
---|
[2694] | 90 | *D|*d) |
---|
| 91 | NbDays=$( echo ${frequency} | awk -F '[dD]' '{print $1}' ) |
---|
[3061] | 92 | file_enabled=.TRUE. |
---|
| 93 | file_freq=${NbDays}d ;; |
---|
[2694] | 94 | *s) |
---|
| 95 | WriteInSeconds=$( echo ${frequency} | awk -F '[s]' '{print $1}' ) |
---|
[3061] | 96 | file_enabled=.TRUE. |
---|
| 97 | file_freq=${WriteInSeconds}s ;; |
---|
[2694] | 98 | HF|hf) |
---|
[3061] | 99 | file_enabled=.TRUE. |
---|
| 100 | file_freq=10800s ;; |
---|
[2694] | 101 | *) |
---|
[3061] | 102 | IGCM_debug_Exit "SRF_Update " ${frequency} " invalid WriteFrequency : choose in xY, xM, xD, xs and HF" |
---|
| 103 | IGCM_debug_Verif_Exit ;; |
---|
[2694] | 104 | esac |
---|
[3061] | 105 | |
---|
| 106 | (( ifreq = ifreq + 1 )) |
---|
| 107 | case ${ifreq} in |
---|
| 108 | 1) |
---|
| 109 | sechiba1_enabled=${file_enabled} |
---|
| 110 | sechiba1_freq=${file_freq} ;; |
---|
| 111 | 2) |
---|
| 112 | sechiba2_enabled=${file_enabled} |
---|
| 113 | sechiba2_freq=${file_freq} ;; |
---|
| 114 | *) |
---|
| 115 | IGCM_debug_Exit "SRF_Update: It is not possible to set more than 2 output files for sechiba from config.card" |
---|
| 116 | IGCM_debug_Exit "You must correct WriteFrequancy in SRF secion in config.card." |
---|
| 117 | IGCM_debug_Exit "Adapt file_def_orchidee.xml directly if you want more output files" |
---|
| 118 | IGCM_debug_Verif_Exit ;; |
---|
| 119 | esac |
---|
[2694] | 120 | done |
---|
| 121 | |
---|
[3061] | 122 | |
---|
| 123 | # Modify file_def_orchidee.xml file |
---|
[2694] | 124 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled ${sechiba1_enabled} |
---|
| 125 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${sechiba1_freq} |
---|
| 126 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled ${sechiba2_enabled} |
---|
[3061] | 127 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq ${sechiba2_freq} |
---|
[3251] | 128 | # Use same values for sechiba1 and for sechiba3 files |
---|
| 129 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled ${sechiba1_enabled} |
---|
| 130 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq ${sechiba1_freq} |
---|
[3061] | 131 | |
---|
[2694] | 132 | |
---|
[2330] | 133 | # Add include of orchidee context in iodef.xml |
---|
| 134 | # In iodef.xml add on next line after "COMPONENT CONTEXT" |
---|
| 135 | # <context id="orchidee" src="./context_orchidee.xml"/> |
---|
[2694] | 136 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
[3542] | 137 | if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then |
---|
| 138 | echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp |
---|
| 139 | echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp |
---|
| 140 | fi |
---|
[2694] | 141 | cp iodef.xml iodef.xml.tmp |
---|
| 142 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
| 143 | rm iodef.xml.tmp add.tmp |
---|
[2330] | 144 | |
---|
[3061] | 145 | # Add LongName as global attribute in XIOS output files (if LongName is not empty) |
---|
| 146 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
| 147 | listfile=$(ls file_def*orchidee.xml) |
---|
| 148 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
| 149 | for file in ${listfile} |
---|
| 150 | do |
---|
| 151 | cp ${file} ${file}.tmp |
---|
| 152 | sed -e "/<file id/r add.tmp" \ |
---|
| 153 | ${file}.tmp > ${file} |
---|
| 154 | rm ${file}.tmp |
---|
| 155 | done |
---|
| 156 | rm add.tmp |
---|
| 157 | fi |
---|
[2833] | 158 | |
---|
[3061] | 159 | |
---|
[2330] | 160 | IGCM_debug_PopStack "SRF_Update" |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | #----------------------------------------------------------------- |
---|
| 164 | function SRF_Finalize |
---|
| 165 | { |
---|
| 166 | IGCM_debug_PushStack "SRF_Finalize" |
---|
| 167 | |
---|
| 168 | IGCM_debug_PopStack "SRF_Finalize" |
---|
| 169 | } |
---|