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