source: CONFIG/UNIFORM/v7/IPSLCM7/GENERAL/DRIVER/orchidee.driver

Last change on this file was 6885, checked in by jgipsl, 7 days ago

Added possiblity to switch to ROUTING=native. It is needed to add the corresponding xml files in orchidee.card and make sur that intput file and restart files are set as well in orchidee.card.

File size: 15.6 KB
Line 
1#!/bin/ksh
2## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE
3#-----------------------------------------------------------------
4function 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#-----------------------------------------------------------------
28function 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} = Xnative ]; then
87        # ROUTING=native is set in orchidee.card
88        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
89        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  native
90    elif [ X${orchidee_UserChoices_ROUTING} = Xhighres ]; then
91        # ROUTING=highres is set in orchidee.card
92        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
93        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  highres
94    else
95        # ROUTING=off, routing will be deactivated
96        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING n
97        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  standard
98    fi
99
100    if [ X${orchidee_UserChoices_AtmCo2} != X ] ; then
101       ##-- CO2 forcing : update CO2 value in orchidee.def with the value defined in orchidee.card
102       ATM_CO2=${orchidee_UserChoices_AtmCo2}
103       echo '(ORCHIDEE) FORCE_CO2_VEG = y'
104       echo '(ORCHIDEE) ATM_CO2='${ATM_CO2}
105       IGCM_comp_modifyDefFile nonblocker orchidee.def FORCE_CO2_VEG y
106       IGCM_comp_modifyDefFile nonblocker orchidee.def ATM_CO2 ${ATM_CO2}
107    else
108       IGCM_comp_modifyDefFile nonblocker orchidee.def FORCE_CO2_VEG DEFAULT
109       IGCM_comp_modifyDefFile nonblocker orchidee.def ATM_CO2 DEFAULT
110    fi
111
112    # Set DO_WOOD_HARVEST in orchidee.def acording to value set in orchidee.card section UserChoices
113    # If DO_WOOD_HARVEST is not definded in orchidee.card, set default value y
114    if [ ! X${orchidee_UserChoices_DO_WOOD_HARVEST} = X ] ; then
115       IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   ${orchidee_UserChoices_DO_WOOD_HARVEST}
116    else
117       IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   DEFAULT
118    fi
119
120    # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices
121    # If LAI_MAP is not definded in orchidee.card, set default value n
122    # Note: this option is only read by ORCHIDEE if starting without restart files
123    if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then
124        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   ${orchidee_UserChoices_LAI_MAP}
125    else
126        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   DEFAULT
127    fi
128
129
130    # Activate creation of river description file only for the first period
131    if [ ${CumulPeriod} -eq 1 ] ; then
132        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
133    else
134        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
135    fi
136
137    # Activate calcul of chemistry BVOC
138    if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then
139        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC}
140    else
141        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n
142    fi
143
144    ## 2. Mangement of output and modifications of related xml files
145    # Modify file_def_orchidee.xml file using settings from orchidee.card
146    # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter
147    # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked.
148    # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
149    # Settings in config.card WriteFrequency are not used any more.
150   
151    if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then
152        # output_level_sechiba_history is not set in orchidee.card or it is set to NONE.
153        # Deactivate the file.
154        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE.
155        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0
156        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo
157    else
158        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled      .TRUE.
159        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history}
160        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history}
161        if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
162           IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba1 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history}
163        fi
164    fi
165   
166    if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
167        # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE.
168        # Deactivate the file.
169        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE.
170        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0
171        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo
172    else
173        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled      .TRUE.
174        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2}
175        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq  ${orchidee_UserChoices_output_freq_sechiba_out_2}
176        if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
177           IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba2 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_out_2}               
178        fi
179    fi
180   
181    if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
182        # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE.
183        # Deactivate the file.
184        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE.
185        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0
186        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo
187    else
188        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled      .TRUE.
189        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim}
190        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history_4dim}
191        if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
192           IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba3 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history_4dim}               
193        fi
194    fi
195   
196    # sechiba_stomate_history.nc: small output file with variables from the whole model mixed in the same file
197    if [ X${orchidee_UserChoices_output_level_sechiba_stomate_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_stomate_history} = XNONE ] ; then
198        # output_level_sechiba_history_4dim is not set in sechiba.card or it is set to NONE.
199        # Deactivate the file.
200        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 enabled .FALSE.
201        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_level 0
202        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_freq 1mo
203    else
204        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 enabled      .TRUE.
205        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_level ${orchidee_UserChoices_output_level_sechiba_stomate_history}
206        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_freq  ${orchidee_UserChoices_output_freq_sechiba_stomate_history}
207    fi
208   
209
210    # Add include of orchidee context in iodef.xml
211    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
212    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
213    # Add inclusion of file context_input_orchidee.xml if this file exists
214    if [ -f context_input_orchidee.xml ] ; then
215        echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
216    fi
217
218    # Add inclusion of file context_routing_orchidee.xml if this file exists
219    if [ X${orchidee_UserChoices_ROUTING} = Xsimple ]; then
220        echo '<context id="orchidee" src="./context_routing_orchidee.xml"/>' >> add.tmp
221    elif [ X${sechiba_UserChoices_ROUTING} = Xnative ] ; then
222        echo '<context id="orchidee" src="./context_routing_native_orchidee.xml"/>' >> add.tmp
223        echo '<context id="orchidee_init_routing" src="./context_init_routing_native_orchidee.xml"/>' >> add.tmp
224    fi
225
226    # Include xml files for output configuration if running with workflow CMIP6
227    if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then
228          echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
229          echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
230    fi
231    cp iodef.xml iodef.xml.tmp
232    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
233    rm iodef.xml.tmp add.tmp
234
235    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
236    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
237        listfile=$(ls file_def*orchidee.xml)
238        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
239        for file in ${listfile}
240        do
241            cp ${file} ${file}.tmp
242            sed -e "/<file id/r add.tmp" \
243                ${file}.tmp > ${file}
244            rm ${file}.tmp
245        done
246        rm add.tmp
247    fi
248
249
250    # Compression level (if CompressionLevel is not empty)
251    if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then
252        echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel}
253        listfile=$(ls file_def*orchidee.xml)
254        for file in ${listfile} ; do
255            sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file}
256        done
257    fi
258
259
260    # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card
261    if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
262        if [ ${RESOL_NBP} == 40  ] ; then
263            valuei=144
264            valuej=143
265        elif [ ${RESOL_NBP} == 60 ] ; then
266            valuei=270
267            valuej=135
268        elif [ ${RESOL_NBP} == 80  ] ; then
269            valuei=360
270            valuej=180
271        elif [ ${RESOL_NBP} == 160  ] ; then
272            valuei=720
273            valuej=360
274        elif [ ${RESOL_NBP} == 320  ] ; then
275            valuei=1440
276            valuej=720
277        else
278            IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers"
279            IGCM_debug_Verif_Exit
280        fi
281       
282        IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_orchidee.xml"
283        cp context_orchidee.xml context_orchidee.xml.init
284        sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \
285            -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \
286            context_orchidee.xml.init > context_orchidee.xml
287       
288    fi
289
290    # Set the appropriate monitoring file depending on grid and resolution if ICO component
291    if [ ${CumulPeriod} -eq 1 ] ; then
292       if [ ! X${config_ListOfComponents_ICO} = X ] ; then
293          IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_ICO${RESOL_NBP}.cfg  ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg
294       else
295          IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_REG.cfg  ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg
296       fi
297    fi
298
299    IGCM_debug_PopStack "SRF_Update"
300}
301
302#-----------------------------------------------------------------
303function SRF_Finalize
304{
305    IGCM_debug_PushStack "SRF_Finalize"
306
307    IGCM_debug_PopStack "SRF_Finalize"
308}
Note: See TracBrowser for help on using the repository browser.