[5479] | 1 | #!/bin/ksh |
---|
| 2 | ## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE |
---|
| 3 | #----------------------------------------------------------------- |
---|
| 4 | function SRF_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "SRF_Initialize" |
---|
| 7 | |
---|
| 8 | ##- Define variable DefSuffix set in orchidee.card |
---|
| 9 | ## This variable is used in orchidee.card to choose |
---|
| 10 | ## parameter file(orchidee.def_DefSuffix). |
---|
| 11 | if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then |
---|
| 12 | DefSuffix=${orchidee_UserChoices_DefSuffix} |
---|
| 13 | else |
---|
[6662] | 14 | DefSuffix=15pft.1ac |
---|
[5479] | 15 | fi |
---|
| 16 | |
---|
[6296] | 17 | # Define the resolution only if the composant ICO for DYNAMICO is set in config.card |
---|
| 18 | if [ ! X${config_ListOfComponents_ICO} = X ] ; then |
---|
[6668] | 19 | RESOL_NBP=${dynamico_UserChoices_RESOL_NBP} |
---|
[6662] | 20 | RESOL_SRF="nbp${RESOL_NBP}" |
---|
[6296] | 21 | fi |
---|
| 22 | |
---|
| 23 | |
---|
[5479] | 24 | IGCM_debug_PopStack "SRF_Initialize" |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | #----------------------------------------------------------------- |
---|
| 28 | function SRF_Update |
---|
| 29 | { |
---|
| 30 | IGCM_debug_PushStack "SRF_Update" |
---|
| 31 | |
---|
| 32 | ## 1. Modifications in orchidee.def parameter file |
---|
| 33 | |
---|
| 34 | # Activate STOMATE if the compontent SBG=stomate is set in config.card |
---|
| 35 | if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then |
---|
| 36 | # Activate stomate in orchidee.def |
---|
| 37 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y |
---|
| 38 | else |
---|
| 39 | # Deactivate stomate in orchidee.def |
---|
| 40 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n |
---|
| 41 | # Deactivate output files for stomate |
---|
| 42 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE. |
---|
| 43 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0 |
---|
| 44 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo |
---|
| 45 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE. |
---|
| 46 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0 |
---|
| 47 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo |
---|
[6296] | 48 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE. |
---|
| 49 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0 |
---|
| 50 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo |
---|
| 51 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 enabled .FALSE. |
---|
| 52 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 output_level 0 |
---|
| 53 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 output_freq 1mo |
---|
[5479] | 54 | fi |
---|
| 55 | |
---|
| 56 | # Define in orchidee.def if restart file should be used |
---|
| 57 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
| 58 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc |
---|
| 59 | else |
---|
| 60 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE |
---|
| 61 | fi |
---|
| 62 | |
---|
| 63 | # Set VEGET_UPDATE=1Y in orchidee.def if VEGET_UPDATE_at_start=y in orchidee.card and if it is the first cumul periond (start of new simulation) |
---|
| 64 | if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 65 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 1Y |
---|
| 66 | fi |
---|
| 67 | |
---|
| 68 | # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices |
---|
| 69 | # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it. |
---|
| 70 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
| 71 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
| 72 | else |
---|
| 73 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y |
---|
| 74 | fi |
---|
| 75 | |
---|
[6662] | 76 | |
---|
[6296] | 77 | # Set parameters related to ROUTING in orchidee.def |
---|
| 78 | if [ X${orchidee_UserChoices_ROUTING} = X ] || [ X${orchidee_UserChoices_ROUTING} = Xstandard ]; then |
---|
| 79 | # Nothing is set or ROUTING=standard in orchidee.def, default option |
---|
| 80 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y |
---|
| 81 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD standard |
---|
| 82 | elif [ X${orchidee_UserChoices_ROUTING} = Xsimple ]; then |
---|
| 83 | # ROUTING=simple is set in orchidee.card |
---|
| 84 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y |
---|
| 85 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD simple |
---|
| 86 | elif [ X${orchidee_UserChoices_ROUTING} = Xhighres ]; then |
---|
| 87 | # ROUTING=highres is set in orchidee.card |
---|
| 88 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y |
---|
| 89 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD highres |
---|
| 90 | else |
---|
| 91 | # ROUTING=off, routing will be deactivated |
---|
| 92 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING n |
---|
| 93 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD standard |
---|
| 94 | fi |
---|
| 95 | |
---|
[6662] | 96 | if [ X${orchidee_UserChoices_AtmCo2} != X ] ; then |
---|
| 97 | ##-- CO2 forcing : update CO2 value in orchidee.def with the value defined in orchidee.card |
---|
| 98 | ATM_CO2=${orchidee_UserChoices_AtmCo2} |
---|
| 99 | echo '(ORCHIDEE) FORCE_CO2_VEG = y' |
---|
| 100 | echo '(ORCHIDEE) ATM_CO2='${ATM_CO2} |
---|
| 101 | IGCM_comp_modifyDefFile nonblocker orchidee.def FORCE_CO2_VEG y |
---|
| 102 | IGCM_comp_modifyDefFile nonblocker orchidee.def ATM_CO2 ${ATM_CO2} |
---|
| 103 | else |
---|
| 104 | IGCM_comp_modifyDefFile nonblocker orchidee.def FORCE_CO2_VEG DEFAULT |
---|
| 105 | IGCM_comp_modifyDefFile nonblocker orchidee.def ATM_CO2 DEFAULT |
---|
| 106 | fi |
---|
| 107 | |
---|
| 108 | # Set DO_WOOD_HARVEST in orchidee.def acording to value set in orchidee.card section UserChoices |
---|
| 109 | # If DO_WOOD_HARVEST is not definded in orchidee.card, set default value y |
---|
| 110 | if [ ! X${orchidee_UserChoices_DO_WOOD_HARVEST} = X ] ; then |
---|
| 111 | IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST ${orchidee_UserChoices_DO_WOOD_HARVEST} |
---|
| 112 | else |
---|
| 113 | IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST DEFAULT |
---|
| 114 | fi |
---|
| 115 | |
---|
[5479] | 116 | # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices |
---|
| 117 | # If LAI_MAP is not definded in orchidee.card, set default value n |
---|
| 118 | # Note: this option is only read by ORCHIDEE if starting without restart files |
---|
| 119 | if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then |
---|
| 120 | IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP ${orchidee_UserChoices_LAI_MAP} |
---|
| 121 | else |
---|
| 122 | IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP DEFAULT |
---|
| 123 | fi |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | # Activate creation of river description file only for the first period |
---|
| 127 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 128 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y |
---|
| 129 | else |
---|
| 130 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n |
---|
| 131 | fi |
---|
| 132 | |
---|
| 133 | # Activate calcul of chemistry BVOC |
---|
| 134 | if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then |
---|
| 135 | IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC} |
---|
| 136 | else |
---|
| 137 | IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n |
---|
| 138 | fi |
---|
| 139 | |
---|
| 140 | ## 2. Mangement of output and modifications of related xml files |
---|
| 141 | # Modify file_def_orchidee.xml file using settings from orchidee.card |
---|
| 142 | # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter |
---|
| 143 | # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked. |
---|
| 144 | # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated. |
---|
| 145 | # Settings in config.card WriteFrequency are not used any more. |
---|
| 146 | |
---|
| 147 | if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then |
---|
| 148 | # output_level_sechiba_history is not set in orchidee.card or it is set to NONE. |
---|
| 149 | # Deactivate the file. |
---|
| 150 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE. |
---|
| 151 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0 |
---|
| 152 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo |
---|
| 153 | else |
---|
| 154 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .TRUE. |
---|
| 155 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history} |
---|
| 156 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${orchidee_UserChoices_output_freq_sechiba_history} |
---|
[6662] | 157 | if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then |
---|
| 158 | IGCM_comp_modifyXmlFile force file_def_orchidee.xml groupremap_sechiba1 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history} |
---|
| 159 | fi |
---|
[5479] | 160 | fi |
---|
| 161 | |
---|
| 162 | if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then |
---|
| 163 | # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE. |
---|
| 164 | # Deactivate the file. |
---|
| 165 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE. |
---|
| 166 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0 |
---|
| 167 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo |
---|
| 168 | else |
---|
| 169 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .TRUE. |
---|
| 170 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2} |
---|
| 171 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq ${orchidee_UserChoices_output_freq_sechiba_out_2} |
---|
[6662] | 172 | if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then |
---|
| 173 | IGCM_comp_modifyXmlFile force file_def_orchidee.xml groupremap_sechiba2 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_out_2} |
---|
| 174 | fi |
---|
[5479] | 175 | fi |
---|
| 176 | |
---|
| 177 | if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then |
---|
| 178 | # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE. |
---|
| 179 | # Deactivate the file. |
---|
| 180 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE. |
---|
| 181 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0 |
---|
| 182 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo |
---|
| 183 | else |
---|
| 184 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .TRUE. |
---|
| 185 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim} |
---|
| 186 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq ${orchidee_UserChoices_output_freq_sechiba_history_4dim} |
---|
[6662] | 187 | if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then |
---|
| 188 | IGCM_comp_modifyXmlFile force file_def_orchidee.xml groupremap_sechiba3 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history_4dim} |
---|
| 189 | fi |
---|
[5479] | 190 | fi |
---|
| 191 | |
---|
[6662] | 192 | if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then |
---|
| 193 | # Desactivate orchidee variables which are not correct in ICOLMDZOR configuration |
---|
| 194 | IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_X enabled .FALSE. |
---|
| 195 | IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_Y enabled .FALSE. |
---|
| 196 | IGCM_comp_modifyXmlFile force field_def_orchidee.xml CONTFRAC_STOMATE enabled .FALSE. |
---|
| 197 | fi |
---|
[5479] | 198 | |
---|
| 199 | |
---|
| 200 | # Add include of orchidee context in iodef.xml |
---|
| 201 | # In iodef.xml add on the next line after "COMPONENT CONTEXT" |
---|
| 202 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
| 203 | # Add inclusion of file context_input_orchidee.xml if this file exists |
---|
| 204 | if [ -f context_input_orchidee.xml ] ; then |
---|
| 205 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
| 206 | fi |
---|
[6296] | 207 | |
---|
| 208 | # Add inclusion of file context_routing_orchidee.xml if this file exists |
---|
| 209 | if [ -f context_routing_orchidee.xml ] ; then |
---|
| 210 | echo '<context id="orchidee" src="./context_routing_orchidee.xml"/>' >> add.tmp |
---|
| 211 | fi |
---|
| 212 | |
---|
[5479] | 213 | # Include xml files for output configuration if running with workflow CMIP6 |
---|
[6296] | 214 | if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then |
---|
| 215 | echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp |
---|
| 216 | echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp |
---|
[5479] | 217 | fi |
---|
| 218 | cp iodef.xml iodef.xml.tmp |
---|
| 219 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
| 220 | rm iodef.xml.tmp add.tmp |
---|
| 221 | |
---|
| 222 | # Add LongName as global attribute in XIOS output files (if LongName is not empty) |
---|
| 223 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
| 224 | listfile=$(ls file_def*orchidee.xml) |
---|
| 225 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
| 226 | for file in ${listfile} |
---|
| 227 | do |
---|
| 228 | cp ${file} ${file}.tmp |
---|
| 229 | sed -e "/<file id/r add.tmp" \ |
---|
| 230 | ${file}.tmp > ${file} |
---|
| 231 | rm ${file}.tmp |
---|
| 232 | done |
---|
| 233 | rm add.tmp |
---|
| 234 | fi |
---|
| 235 | |
---|
| 236 | |
---|
| 237 | # Compression level (if CompressionLevel is not empty) |
---|
| 238 | if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then |
---|
| 239 | echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel} |
---|
| 240 | listfile=$(ls file_def*orchidee.xml) |
---|
| 241 | for file in ${listfile} ; do |
---|
| 242 | sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file} |
---|
| 243 | done |
---|
| 244 | fi |
---|
| 245 | |
---|
| 246 | |
---|
| 247 | # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card |
---|
| 248 | if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then |
---|
| 249 | if [ ${RESOL_NBP} == 40 ] ; then |
---|
| 250 | valuei=144 |
---|
| 251 | valuej=143 |
---|
[6743] | 252 | elif [ ${RESOL_NBP} == 60 ] ; then |
---|
| 253 | valuei=270 |
---|
| 254 | valuej=135 |
---|
[5479] | 255 | elif [ ${RESOL_NBP} == 80 ] ; then |
---|
| 256 | valuei=360 |
---|
| 257 | valuej=180 |
---|
| 258 | elif [ ${RESOL_NBP} == 160 ] ; then |
---|
| 259 | valuei=720 |
---|
| 260 | valuej=360 |
---|
[6662] | 261 | elif [ ${RESOL_NBP} == 320 ] ; then |
---|
| 262 | valuei=1440 |
---|
| 263 | valuej=720 |
---|
[5479] | 264 | else |
---|
| 265 | IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers" |
---|
| 266 | IGCM_debug_Verif_Exit |
---|
| 267 | fi |
---|
| 268 | |
---|
| 269 | IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_orchidee.xml" |
---|
| 270 | cp context_orchidee.xml context_orchidee.xml.init |
---|
| 271 | sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \ |
---|
| 272 | -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \ |
---|
| 273 | context_orchidee.xml.init > context_orchidee.xml |
---|
| 274 | |
---|
| 275 | fi |
---|
[6667] | 276 | |
---|
| 277 | # Set the appropriate monitoring file depending on grid and resolution if ICO component |
---|
| 278 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 279 | if [ ! X${config_ListOfComponents_ICO} = X ] ; then |
---|
[6668] | 280 | IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_ICO${RESOL_NBP}.cfg ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg |
---|
[6667] | 281 | else |
---|
| 282 | IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_REG.cfg ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg |
---|
| 283 | fi |
---|
| 284 | fi |
---|
| 285 | |
---|
[5479] | 286 | IGCM_debug_PopStack "SRF_Update" |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | #----------------------------------------------------------------- |
---|
| 290 | function SRF_Finalize |
---|
| 291 | { |
---|
| 292 | IGCM_debug_PushStack "SRF_Finalize" |
---|
| 293 | |
---|
| 294 | IGCM_debug_PopStack "SRF_Finalize" |
---|
| 295 | } |
---|