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

Last change on this file since 6667 was 6667, checked in by cetlod, 8 months ago

CM7_work : Setting the appropriate monitoring file depending on grid and resolution and update driver consequently

File size: 14.3 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_SRF="nbp${RESOL_NBP}"
20    fi
21
22
23    IGCM_debug_PopStack "SRF_Initialize"
24}
25
26#-----------------------------------------------------------------
27function SRF_Update
28{
29    IGCM_debug_PushStack "SRF_Update"
30
31    ## 1. Modifications in orchidee.def parameter file
32
33    # Activate STOMATE if the compontent SBG=stomate is set in config.card
34    if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
35        # Activate stomate in orchidee.def
36        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
37    else
38        # Deactivate stomate in orchidee.def
39        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
40        # Deactivate output files for stomate
41        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
42        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0
43        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
44        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
45        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
46        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
47        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE.
48        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0
49        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo
50        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 enabled .FALSE.
51        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 output_level 0
52        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 output_freq 1mo
53    fi
54
55    # Define in orchidee.def if restart file should be used
56    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
57        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
58    else
59        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
60    fi
61
62    # 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)
63    if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then
64        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   1Y
65    fi
66
67    # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices
68    # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it.
69    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
70        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
71    else
72        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
73    fi
74
75
76    # Set parameters related to ROUTING in orchidee.def
77    if [ X${orchidee_UserChoices_ROUTING} = X ] || [ X${orchidee_UserChoices_ROUTING} = Xstandard ]; then
78        # Nothing is set or ROUTING=standard in orchidee.def, default option
79        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
80        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  standard
81    elif [ X${orchidee_UserChoices_ROUTING} = Xsimple ]; then
82        # ROUTING=simple is set in orchidee.card
83        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
84        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  simple
85    elif [ X${orchidee_UserChoices_ROUTING} = Xhighres ]; then
86        # ROUTING=highres is set in orchidee.card
87        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
88        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  highres
89    else
90        # ROUTING=off, routing will be deactivated
91        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING n
92        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  standard
93    fi
94
95    if [ X${orchidee_UserChoices_AtmCo2} != X ] ; then
96       ##-- CO2 forcing : update CO2 value in orchidee.def with the value defined in orchidee.card
97       ATM_CO2=${orchidee_UserChoices_AtmCo2}
98       echo '(ORCHIDEE) FORCE_CO2_VEG = y'
99       echo '(ORCHIDEE) ATM_CO2='${ATM_CO2}
100       IGCM_comp_modifyDefFile nonblocker orchidee.def FORCE_CO2_VEG y
101       IGCM_comp_modifyDefFile nonblocker orchidee.def ATM_CO2 ${ATM_CO2}
102    else
103       IGCM_comp_modifyDefFile nonblocker orchidee.def FORCE_CO2_VEG DEFAULT
104       IGCM_comp_modifyDefFile nonblocker orchidee.def ATM_CO2 DEFAULT
105    fi
106
107    # Set DO_WOOD_HARVEST in orchidee.def acording to value set in orchidee.card section UserChoices
108    # If DO_WOOD_HARVEST is not definded in orchidee.card, set default value y
109    if [ ! X${orchidee_UserChoices_DO_WOOD_HARVEST} = X ] ; then
110       IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   ${orchidee_UserChoices_DO_WOOD_HARVEST}
111    else
112       IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   DEFAULT
113    fi
114
115    # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices
116    # If LAI_MAP is not definded in orchidee.card, set default value n
117    # Note: this option is only read by ORCHIDEE if starting without restart files
118    if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then
119        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   ${orchidee_UserChoices_LAI_MAP}
120    else
121        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   DEFAULT
122    fi
123
124
125    # Activate creation of river description file only for the first period
126    if [ ${CumulPeriod} -eq 1 ] ; then
127        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
128    else
129        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
130    fi
131
132    # Activate calcul of chemistry BVOC
133    if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then
134        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC}
135    else
136        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n
137    fi
138
139    ## 2. Mangement of output and modifications of related xml files
140    # Modify file_def_orchidee.xml file using settings from orchidee.card
141    # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter
142    # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked.
143    # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
144    # Settings in config.card WriteFrequency are not used any more.
145   
146    if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then
147        # output_level_sechiba_history is not set in orchidee.card or it is set to NONE.
148        # Deactivate the file.
149        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE.
150        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0
151        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo
152    else
153        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled      .TRUE.
154        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history}
155        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history}
156        if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
157           IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba1 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history}
158        fi
159    fi
160   
161    if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
162        # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE.
163        # Deactivate the file.
164        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE.
165        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0
166        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo
167    else
168        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled      .TRUE.
169        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2}
170        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq  ${orchidee_UserChoices_output_freq_sechiba_out_2}
171        if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
172           IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba2 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_out_2}               
173        fi
174    fi
175   
176    if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
177        # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE.
178        # Deactivate the file.
179        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE.
180        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0
181        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo
182    else
183        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled      .TRUE.
184        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim}
185        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history_4dim}
186        if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
187           IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba3 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history_4dim}               
188        fi
189    fi
190       
191    if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
192       # Desactivate orchidee variables which are not correct in ICOLMDZOR configuration
193       IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_X enabled .FALSE.
194       IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_Y enabled .FALSE.
195       IGCM_comp_modifyXmlFile force field_def_orchidee.xml CONTFRAC_STOMATE enabled .FALSE.
196    fi
197
198
199    # Add include of orchidee context in iodef.xml
200    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
201    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
202    # Add inclusion of file context_input_orchidee.xml if this file exists
203    if [ -f context_input_orchidee.xml ] ; then
204        echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
205    fi
206
207    # Add inclusion of file context_routing_orchidee.xml if this file exists
208    if [ -f context_routing_orchidee.xml ] ; then
209        echo '<context id="orchidee" src="./context_routing_orchidee.xml"/>' >> add.tmp
210    fi
211
212    # Include xml files for output configuration if running with workflow CMIP6
213    if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then
214          echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
215          echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
216    fi
217    cp iodef.xml iodef.xml.tmp
218    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
219    rm iodef.xml.tmp add.tmp
220
221    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
222    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
223        listfile=$(ls file_def*orchidee.xml)
224        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
225        for file in ${listfile}
226        do
227            cp ${file} ${file}.tmp
228            sed -e "/<file id/r add.tmp" \
229                ${file}.tmp > ${file}
230            rm ${file}.tmp
231        done
232        rm add.tmp
233    fi
234
235
236    # Compression level (if CompressionLevel is not empty)
237    if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then
238        echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel}
239        listfile=$(ls file_def*orchidee.xml)
240        for file in ${listfile} ; do
241            sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file}
242        done
243    fi
244
245
246    # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card
247    if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
248        if [ ${RESOL_NBP} == 40  ] ; then
249            valuei=144
250            valuej=143
251        elif [ ${RESOL_NBP} == 80  ] ; then
252            valuei=360
253            valuej=180
254        elif [ ${RESOL_NBP} == 160  ] ; then
255            valuei=720
256            valuej=360
257        elif [ ${RESOL_NBP} == 320  ] ; then
258            valuei=1440
259            valuej=720
260        else
261            IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers"
262            IGCM_debug_Verif_Exit
263        fi
264       
265        IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_orchidee.xml"
266        cp context_orchidee.xml context_orchidee.xml.init
267        sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \
268            -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \
269            context_orchidee.xml.init > context_orchidee.xml
270       
271    fi
272
273    # Set the appropriate monitoring file depending on grid and resolution if ICO component
274    if [ ${CumulPeriod} -eq 1 ] ; then
275       if [ ! X${config_ListOfComponents_ICO} = X ] ; then
276          IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_${ResolAtm}.cfg  ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg
277       else
278          IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_orchidee_REG.cfg  ${SUBMIT_DIR}/POST/monitoring01_orchidee.cfg
279       fi
280    fi
281
282    IGCM_debug_PopStack "SRF_Update"
283}
284
285#-----------------------------------------------------------------
286function SRF_Finalize
287{
288    IGCM_debug_PushStack "SRF_Finalize"
289
290    IGCM_debug_PopStack "SRF_Finalize"
291}
Note: See TracBrowser for help on using the repository browser.