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

Last change on this file was 6291, checked in by aclsce, 17 months ago
  • Merge in ICOLMDZOR_LAM configuration accordingly with ICOLMDZOR configuration :

compilation : added rad option (with correct handling of svn test version)
experiments : merge with LMDZOR_v6.2 configuration
cleaning and other small things

File size: 12.9 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=CWRR
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    # Set parameters related to ROUTING in orchidee.def
76    if [ X${orchidee_UserChoices_ROUTING} = X ] || [ X${orchidee_UserChoices_ROUTING} = Xstandard ]; then
77        # Nothing is set or ROUTING=standard in orchidee.def, default option
78        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
79        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  standard
80    elif [ X${orchidee_UserChoices_ROUTING} = Xsimple ]; then
81        # ROUTING=simple is set in orchidee.card
82        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
83        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  simple
84    elif [ X${orchidee_UserChoices_ROUTING} = Xhighres ]; then
85        # ROUTING=highres is set in orchidee.card
86        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y
87        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  highres
88    else
89        # ROUTING=off, routing will be deactivated
90        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING n
91        IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD  standard
92    fi
93
94    # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices
95    # If LAI_MAP is not definded in orchidee.card, set default value n
96    # Note: this option is only read by ORCHIDEE if starting without restart files
97    if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then
98        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   ${orchidee_UserChoices_LAI_MAP}
99    else
100        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   DEFAULT
101    fi
102
103    # Set DO_WOOD_HARVEST in orchidee.def acording to value set in orchidee.card section UserChoices
104    # If DO_WOOD_HARVEST is not definded in orchidee.card, set default value y
105    if [ ! X${orchidee_UserChoices_DO_WOOD_HARVEST} = X ] ; then
106        IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   ${orchidee_UserChoices_DO_WOOD_HARVEST}
107    else
108        IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   DEFAULT
109    fi
110
111    # Activate creation of river description file only for the first period
112    if [ ${CumulPeriod} -eq 1 ] ; then
113        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
114    else
115        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
116    fi
117
118    # Activate calcul of chemistry BVOC
119    if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then
120        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC}
121    else
122        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n
123    fi
124
125    ## 2. Mangement of output and modifications of related xml files
126    # Modify file_def_orchidee.xml file using settings from orchidee.card
127    # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter
128    # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked.
129    # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
130    # Settings in config.card WriteFrequency are not used any more.
131   
132    if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then
133        # output_level_sechiba_history is not set in orchidee.card or it is set to NONE.
134        # Deactivate the file.
135        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE.
136        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0
137        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo
138    else
139        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled      .TRUE.
140        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history}
141        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history}
142        IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba1 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history}
143    fi
144   
145    if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
146        # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE.
147        # Deactivate the file.
148        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE.
149        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0
150        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo
151    else
152        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled      .TRUE.
153        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2}
154        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq  ${orchidee_UserChoices_output_freq_sechiba_out_2}
155        IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba2 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_out_2}         
156    fi
157   
158    if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
159        # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE.
160        # Deactivate the file.
161        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE.
162        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0
163        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo
164    else
165        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled      .TRUE.
166        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim}
167        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history_4dim}
168        IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba3 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history_4dim}           
169    fi
170       
171    # Desactivate orchidee variables which are not correct in ICOLMDZOR configuration
172    IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_X enabled .FALSE.
173    IGCM_comp_modifyXmlFile force field_def_orchidee.xml RESOLUTION_Y enabled .FALSE.
174    IGCM_comp_modifyXmlFile force field_def_orchidee.xml CONTFRAC_STOMATE enabled .FALSE.
175
176
177    # Add include of orchidee context in iodef.xml
178    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
179    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
180    # Add inclusion of file context_input_orchidee.xml if this file exists
181    if [ -f context_input_orchidee.xml ] ; then
182        echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
183    fi
184
185    # Add inclusion of file context_routing_orchidee.xml if this file exists
186    if [ -f context_routing_orchidee.xml ] ; then
187        echo '<context id="orchidee" src="./context_routing_orchidee.xml"/>' >> add.tmp
188    fi
189
190    # Include xml files for output configuration if running with workflow CMIP6
191    if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then
192          echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
193          echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
194    fi
195    cp iodef.xml iodef.xml.tmp
196    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
197    rm iodef.xml.tmp add.tmp
198
199    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
200    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
201        listfile=$(ls file_def*orchidee.xml)
202        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
203        for file in ${listfile}
204        do
205            cp ${file} ${file}.tmp
206            sed -e "/<file id/r add.tmp" \
207                ${file}.tmp > ${file}
208            rm ${file}.tmp
209        done
210        rm add.tmp
211    fi
212
213
214    # Compression level (if CompressionLevel is not empty)
215    if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then
216        echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel}
217        listfile=$(ls file_def*orchidee.xml)
218        for file in ${listfile} ; do
219            sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file}
220        done
221    fi
222
223
224    # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card
225    if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
226        if [ ${RESOL_NBP} == 40  ] ; then
227            valuei=144
228            valuej=143
229        elif [ ${RESOL_NBP} == 80  ] ; then
230            valuei=360
231            valuej=180
232        elif [ ${RESOL_NBP} == 160  ] ; then
233            valuei=720
234            valuej=360
235    elif [ ${RESOL_NBP} == 320  ] ; then
236        valuei=1440
237        valuej=720
238        else
239            IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers"
240            IGCM_debug_Verif_Exit
241        fi
242       
243        IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_orchidee.xml"
244        cp context_orchidee.xml context_orchidee.xml.init
245        sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \
246            -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \
247            context_orchidee.xml.init > context_orchidee.xml
248       
249    fi
250   
251    IGCM_debug_PopStack "SRF_Update"
252}
253
254#-----------------------------------------------------------------
255function SRF_Finalize
256{
257    IGCM_debug_PushStack "SRF_Finalize"
258
259    IGCM_debug_PopStack "SRF_Finalize"
260}
Note: See TracBrowser for help on using the repository browser.