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