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

Last change on this file was 6290, checked in by aclsce, 18 months ago
  • Finalized merge in ICOLMDZOR configuration :
    • compilation : added rad option (with correct handling of svn test version)
    • experiments : merge with LMDZOR_v6.2 configuration, handling of remap frequency for ORCHIDEE xml file_def
    • cleaning and other small things
File size: 12.9 KB
RevLine 
[396]1#!/bin/ksh
[3047]2## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE
[396]3#-----------------------------------------------------------------
4function SRF_Initialize
5{
6    IGCM_debug_PushStack "SRF_Initialize"
7
[2018]8    ##- Define variable DefSuffix set in orchidee.card
[2582]9    ##  This variable is used in orchidee.card to choose
10    ##  parameter file(orchidee.def_DefSuffix).
[2018]11    if [ ! X${orchidee_UserChoices_DefSuffix} = X ] ; then
[2582]12        DefSuffix=${orchidee_UserChoices_DefSuffix}
[2018]13    else
[4135]14        DefSuffix=CWRR
[2018]15    fi
16
[6100]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
[396]23    IGCM_debug_PopStack "SRF_Initialize"
24}
25
26#-----------------------------------------------------------------
27function SRF_Update
28{
29    IGCM_debug_PushStack "SRF_Update"
30
[2602]31    ## 1. Modifications in orchidee.def parameter file
32
[2333]33    # Activate STOMATE if the compontent SBG=stomate is set in config.card
34    if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
[2595]35        # Activate stomate in orchidee.def
[2582]36        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
[2333]37    else
[2595]38        # Deactivate stomate in orchidee.def
[2582]39        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
[2595]40        # Deactivate output files for stomate
41        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
[3563]42        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0
[2907]43        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
[2595]44        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
[3563]45        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
[2907]46        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
[6290]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
[2333]53    fi
54
[2602]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
[3537]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
[2757]67    # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices
[3537]68    # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it.
[2602]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
[6290]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
[3772]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
[3815]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
[2602]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
[4312]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
[2602]124
125    ## 2. Mangement of output and modifications of related xml files
[3564]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
[3563]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.
[3047]131   
[3564]132    if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then
[3563]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.
[3564]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}
[6290]142        IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba1 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history}
[3563]143    fi
144   
[3564]145    if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
[3563]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.
[3564]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}
[6290]155        IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba2 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_out_2}         
[3563]156    fi
157   
[3564]158    if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
[3563]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.
[3564]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}
[6290]168        IGCM_comp_modifyXmlFile force      file_def_orchidee.xml groupremap_sechiba3 group_ref remap_${orchidee_UserChoices_output_freq_sechiba_history_4dim}           
[3563]169    fi
170       
[5148]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.
[763]175
[5148]176
[2595]177    # Add include of orchidee context in iodef.xml
[4108]178    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
[2595]179    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
[4108]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
[6290]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
[4108]190    # Include xml files for output configuration if running with workflow CMIP6
[6290]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
[3505]194    fi
[2595]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
[3047]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
[2833]212
[3047]213
[4357]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
[4379]223
[4921]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
[5540]235    elif [ ${RESOL_NBP} == 320  ] ; then
236        valuei=1440
237        valuej=720
[4921]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       
[4379]249    fi
[4921]250   
[396]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.