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 |
---|
14 | DefSuffix=15pft.1ac |
---|
15 | fi |
---|
16 | |
---|
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_NBP=${dynamico_UserChoices_RESOL_NBP} |
---|
20 | RESOL_SRF="nbp${RESOL_NBP}" |
---|
21 | fi |
---|
22 | |
---|
23 | |
---|
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 |
---|
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 |
---|
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 | |
---|
76 | |
---|
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 | |
---|
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 | |
---|
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} |
---|
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 |
---|
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} |
---|
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 |
---|
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} |
---|
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 |
---|
190 | fi |
---|
191 | |
---|
192 | # sechiba_stomate_history.nc: small output file with variables from the whole model mixed in the same file |
---|
193 | if [ X${orchidee_UserChoices_output_level_sechiba_stomate_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_stomate_history} = XNONE ] ; then |
---|
194 | # output_level_sechiba_history_4dim is not set in sechiba.card or it is set to NONE. |
---|
195 | # Deactivate the file. |
---|
196 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 enabled .FALSE. |
---|
197 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_level 0 |
---|
198 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_freq 1mo |
---|
199 | else |
---|
200 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 enabled .TRUE. |
---|
201 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_level ${orchidee_UserChoices_output_level_sechiba_stomate_history} |
---|
202 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_freq ${orchidee_UserChoices_output_freq_sechiba_stomate_history} |
---|
203 | fi |
---|
204 | |
---|
205 | |
---|
206 | # Add include of orchidee context in iodef.xml |
---|
207 | # In iodef.xml add on the next line after "COMPONENT CONTEXT" |
---|
208 | echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp |
---|
209 | # Add inclusion of file context_input_orchidee.xml if this file exists |
---|
210 | if [ -f context_input_orchidee.xml ] ; then |
---|
211 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
212 | fi |
---|
213 | |
---|
214 | # Add inclusion of file context_routing_orchidee.xml if this file exists |
---|
215 | if [ -f context_routing_orchidee.xml ] ; then |
---|
216 | echo '<context id="orchidee" src="./context_routing_orchidee.xml"/>' >> add.tmp |
---|
217 | fi |
---|
218 | |
---|
219 | # Include xml files for output configuration if running with workflow CMIP6 |
---|
220 | if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then |
---|
221 | echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp |
---|
222 | echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp |
---|
223 | fi |
---|
224 | cp iodef.xml iodef.xml.tmp |
---|
225 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
226 | rm iodef.xml.tmp add.tmp |
---|
227 | |
---|
228 | # Add LongName as global attribute in XIOS output files (if LongName is not empty) |
---|
229 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
230 | listfile=$(ls file_def*orchidee.xml) |
---|
231 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
232 | for file in ${listfile} |
---|
233 | do |
---|
234 | cp ${file} ${file}.tmp |
---|
235 | sed -e "/<file id/r add.tmp" \ |
---|
236 | ${file}.tmp > ${file} |
---|
237 | rm ${file}.tmp |
---|
238 | done |
---|
239 | rm add.tmp |
---|
240 | fi |
---|
241 | |
---|
242 | |
---|
243 | # Compression level (if CompressionLevel is not empty) |
---|
244 | if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then |
---|
245 | echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel} |
---|
246 | listfile=$(ls file_def*orchidee.xml) |
---|
247 | for file in ${listfile} ; do |
---|
248 | sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file} |
---|
249 | done |
---|
250 | fi |
---|
251 | |
---|
252 | |
---|
253 | # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card |
---|
254 | if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then |
---|
255 | if [ ${RESOL_NBP} == 40 ] ; then |
---|
256 | valuei=144 |
---|
257 | valuej=143 |
---|
258 | elif [ ${RESOL_NBP} == 60 ] ; then |
---|
259 | valuei=270 |
---|
260 | valuej=135 |
---|
261 | elif [ ${RESOL_NBP} == 80 ] ; then |
---|
262 | valuei=360 |
---|
263 | valuej=180 |
---|
264 | elif [ ${RESOL_NBP} == 160 ] ; then |
---|
265 | valuei=720 |
---|
266 | valuej=360 |
---|
267 | elif [ ${RESOL_NBP} == 320 ] ; then |
---|
268 | valuei=1440 |
---|
269 | valuej=720 |
---|
270 | else |
---|
271 | IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers" |
---|
272 | IGCM_debug_Verif_Exit |
---|
273 | fi |
---|
274 | |
---|
275 | IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_orchidee.xml" |
---|
276 | cp context_orchidee.xml context_orchidee.xml.init |
---|
277 | sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \ |
---|
278 | -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \ |
---|
279 | context_orchidee.xml.init > context_orchidee.xml |
---|
280 | |
---|
281 | fi |
---|
282 | |
---|
283 | # Set the appropriate monitoring file depending on grid and resolution if ICO component |
---|
284 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
285 | if [ ! X${config_ListOfComponents_ICO} = X ] ; then |
---|
286 | IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_ICO${RESOL_NBP}.cfg ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg |
---|
287 | else |
---|
288 | IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_REG.cfg ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg |
---|
289 | fi |
---|
290 | fi |
---|
291 | |
---|
292 | IGCM_debug_PopStack "SRF_Update" |
---|
293 | } |
---|
294 | |
---|
295 | #----------------------------------------------------------------- |
---|
296 | function SRF_Finalize |
---|
297 | { |
---|
298 | IGCM_debug_PushStack "SRF_Finalize" |
---|
299 | |
---|
300 | IGCM_debug_PopStack "SRF_Finalize" |
---|
301 | } |
---|