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