[396] | 1 | #!/bin/ksh |
---|
[3047] | 2 | ## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE |
---|
[396] | 3 | #----------------------------------------------------------------- |
---|
| 4 | function SRF_Initialize |
---|
| 5 | { |
---|
| 6 | IGCM_debug_PushStack "SRF_Initialize" |
---|
| 7 | |
---|
[2018] | 8 | ##- Define variable DefSuffix set in orchidee.card |
---|
[2582] | 9 | ## This variable is used in orchidee.card to choose |
---|
| 10 | ## parameter file(orchidee.def_DefSuffix). |
---|
[2018] | 11 | if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then |
---|
[2582] | 12 | DefSuffix=${orchidee_UserChoices_DefSuffix} |
---|
[2018] | 13 | else |
---|
[4135] | 14 | DefSuffix=CWRR |
---|
[2018] | 15 | fi |
---|
| 16 | |
---|
[6100] | 17 | # Define the resolution only if the composant ICO for DYNAMICO is set in config.card |
---|
| 18 | if [ ! X${config_ListOfComponents_ICO} = X ] ; then |
---|
| 19 | RESOL_SRF="nbp${RESOL_NBP}" |
---|
| 20 | fi |
---|
| 21 | |
---|
| 22 | |
---|
[396] | 23 | IGCM_debug_PopStack "SRF_Initialize" |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | #----------------------------------------------------------------- |
---|
| 27 | function SRF_Update |
---|
| 28 | { |
---|
| 29 | IGCM_debug_PushStack "SRF_Update" |
---|
| 30 | |
---|
[2602] | 31 | ## 1. Modifications in orchidee.def parameter file |
---|
| 32 | |
---|
[2333] | 33 | # Activate STOMATE if the compontent SBG=stomate is set in config.card |
---|
| 34 | if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then |
---|
[2595] | 35 | # Activate stomate in orchidee.def |
---|
[2582] | 36 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y |
---|
[2333] | 37 | else |
---|
[2595] | 38 | # Deactivate stomate in orchidee.def |
---|
[2582] | 39 | IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n |
---|
[2595] | 40 | # Deactivate output files for stomate |
---|
| 41 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE. |
---|
[3563] | 42 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0 |
---|
[2907] | 43 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo |
---|
[4312] | 44 | |
---|
[2595] | 45 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE. |
---|
[3563] | 46 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0 |
---|
[2907] | 47 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo |
---|
[4312] | 48 | |
---|
| 49 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE. |
---|
| 50 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0 |
---|
| 51 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo |
---|
[2333] | 52 | fi |
---|
| 53 | |
---|
[2602] | 54 | # Define in orchidee.def if restart file should be used |
---|
| 55 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
| 56 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc |
---|
| 57 | else |
---|
| 58 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE |
---|
| 59 | fi |
---|
| 60 | |
---|
[3537] | 61 | # 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) |
---|
| 62 | if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 63 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 1Y |
---|
| 64 | fi |
---|
| 65 | |
---|
[2757] | 66 | # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices |
---|
[3537] | 67 | # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it. |
---|
[2602] | 68 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
| 69 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
| 70 | else |
---|
| 71 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y |
---|
| 72 | fi |
---|
| 73 | |
---|
[3772] | 74 | # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices |
---|
| 75 | # If LAI_MAP is not definded in orchidee.card, set default value n |
---|
| 76 | # Note: this option is only read by ORCHIDEE if starting without restart files |
---|
| 77 | if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then |
---|
| 78 | IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP ${orchidee_UserChoices_LAI_MAP} |
---|
| 79 | else |
---|
| 80 | IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP DEFAULT |
---|
| 81 | fi |
---|
| 82 | |
---|
[3815] | 83 | # Set DO_WOOD_HARVEST in orchidee.def acording to value set in orchidee.card section UserChoices |
---|
| 84 | # If DO_WOOD_HARVEST is not definded in orchidee.card, set default value y |
---|
| 85 | if [ ! X${orchidee_UserChoices_DO_WOOD_HARVEST} = X ] ; then |
---|
| 86 | IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST ${orchidee_UserChoices_DO_WOOD_HARVEST} |
---|
| 87 | else |
---|
| 88 | IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST DEFAULT |
---|
| 89 | fi |
---|
| 90 | |
---|
[2602] | 91 | # Activate creation of river description file only for the first period |
---|
| 92 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
| 93 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y |
---|
| 94 | else |
---|
| 95 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n |
---|
| 96 | fi |
---|
| 97 | |
---|
[4312] | 98 | # Activate calcul of chemistry BVOC |
---|
| 99 | if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then |
---|
| 100 | IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC} |
---|
| 101 | else |
---|
| 102 | IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n |
---|
| 103 | fi |
---|
[2602] | 104 | |
---|
| 105 | ## 2. Mangement of output and modifications of related xml files |
---|
[3564] | 106 | # Modify file_def_orchidee.xml file using settings from orchidee.card |
---|
| 107 | # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter |
---|
[3563] | 108 | # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked. |
---|
| 109 | # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated. |
---|
| 110 | # Settings in config.card WriteFrequency are not used any more. |
---|
[3047] | 111 | |
---|
[3564] | 112 | if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then |
---|
[3563] | 113 | # output_level_sechiba_history is not set in orchidee.card or it is set to NONE. |
---|
| 114 | # Deactivate the file. |
---|
| 115 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE. |
---|
| 116 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0 |
---|
| 117 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo |
---|
| 118 | else |
---|
| 119 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .TRUE. |
---|
[3564] | 120 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history} |
---|
| 121 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${orchidee_UserChoices_output_freq_sechiba_history} |
---|
[3563] | 122 | fi |
---|
| 123 | |
---|
[3564] | 124 | if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then |
---|
[3563] | 125 | # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE. |
---|
| 126 | # Deactivate the file. |
---|
| 127 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE. |
---|
| 128 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0 |
---|
| 129 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo |
---|
| 130 | else |
---|
| 131 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .TRUE. |
---|
[3564] | 132 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2} |
---|
| 133 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq ${orchidee_UserChoices_output_freq_sechiba_out_2} |
---|
[3563] | 134 | fi |
---|
| 135 | |
---|
[3564] | 136 | if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then |
---|
[3563] | 137 | # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE. |
---|
| 138 | # Deactivate the file. |
---|
| 139 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE. |
---|
| 140 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0 |
---|
| 141 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo |
---|
| 142 | else |
---|
| 143 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .TRUE. |
---|
[3564] | 144 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim} |
---|
| 145 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq ${orchidee_UserChoices_output_freq_sechiba_history_4dim} |
---|
[3563] | 146 | fi |
---|
| 147 | |
---|
[5148] | 148 | # Desactivate orchidee variables which are not correct in ICOLMDZOR configuration |
---|
| 149 | IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_X enabled .FALSE. |
---|
| 150 | IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_Y enabled .FALSE. |
---|
| 151 | IGCM_comp_modifyXmlFile force field_def_orchidee.xml CONTFRAC_STOMATE enabled .FALSE. |
---|
[763] | 152 | |
---|
[5148] | 153 | |
---|
[2595] | 154 | # Add include of orchidee context in iodef.xml |
---|
[4108] | 155 | # In iodef.xml add on the next line after "COMPONENT CONTEXT" |
---|
[2595] | 156 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
[4108] | 157 | # Add inclusion of file context_input_orchidee.xml if this file exists |
---|
| 158 | if [ -f context_input_orchidee.xml ] ; then |
---|
| 159 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
| 160 | fi |
---|
| 161 | # Include xml files for output configuration if running with workflow CMIP6 |
---|
[3505] | 162 | if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then |
---|
| 163 | echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp |
---|
| 164 | echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp |
---|
| 165 | fi |
---|
[2595] | 166 | cp iodef.xml iodef.xml.tmp |
---|
| 167 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
| 168 | rm iodef.xml.tmp add.tmp |
---|
| 169 | |
---|
[3047] | 170 | # Add LongName as global attribute in XIOS output files (if LongName is not empty) |
---|
| 171 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
| 172 | listfile=$(ls file_def*orchidee.xml) |
---|
| 173 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
| 174 | for file in ${listfile} |
---|
| 175 | do |
---|
| 176 | cp ${file} ${file}.tmp |
---|
| 177 | sed -e "/<file id/r add.tmp" \ |
---|
| 178 | ${file}.tmp > ${file} |
---|
| 179 | rm ${file}.tmp |
---|
| 180 | done |
---|
| 181 | rm add.tmp |
---|
| 182 | fi |
---|
[2833] | 183 | |
---|
[3047] | 184 | |
---|
[4357] | 185 | # Compression level (if CompressionLevel is not empty) |
---|
| 186 | if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then |
---|
| 187 | echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel} |
---|
| 188 | listfile=$(ls file_def*orchidee.xml) |
---|
| 189 | for file in ${listfile} ; do |
---|
| 190 | sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file} |
---|
| 191 | done |
---|
| 192 | fi |
---|
| 193 | |
---|
[4379] | 194 | |
---|
[4921] | 195 | # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card |
---|
| 196 | if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then |
---|
| 197 | if [ ${RESOL_NBP} == 40 ] ; then |
---|
| 198 | valuei=144 |
---|
| 199 | valuej=143 |
---|
| 200 | elif [ ${RESOL_NBP} == 80 ] ; then |
---|
| 201 | valuei=360 |
---|
| 202 | valuej=180 |
---|
| 203 | elif [ ${RESOL_NBP} == 160 ] ; then |
---|
| 204 | valuei=720 |
---|
| 205 | valuej=360 |
---|
[5540] | 206 | elif [ ${RESOL_NBP} == 320 ] ; then |
---|
| 207 | valuei=1440 |
---|
| 208 | valuej=720 |
---|
[4921] | 209 | else |
---|
| 210 | IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers" |
---|
| 211 | IGCM_debug_Verif_Exit |
---|
| 212 | fi |
---|
| 213 | |
---|
| 214 | IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_orchidee.xml" |
---|
| 215 | cp context_orchidee.xml context_orchidee.xml.init |
---|
| 216 | sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \ |
---|
| 217 | -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \ |
---|
| 218 | context_orchidee.xml.init > context_orchidee.xml |
---|
| 219 | |
---|
[4379] | 220 | fi |
---|
[4921] | 221 | |
---|
[396] | 222 | IGCM_debug_PopStack "SRF_Update" |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | #----------------------------------------------------------------- |
---|
| 226 | function SRF_Finalize |
---|
| 227 | { |
---|
| 228 | IGCM_debug_PushStack "SRF_Finalize" |
---|
| 229 | |
---|
| 230 | IGCM_debug_PopStack "SRF_Finalize" |
---|
| 231 | } |
---|