source: CMIP6/ScenarioMIP/CM61-LR-scen-ssp585-r33/DRIVER/orchidee.driver @ 5938

Last change on this file since 5938 was 5938, checked in by tlurton, 2 years ago

Registering experiment ssp585-r33.

File size: 9.5 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    IGCM_debug_PopStack "SRF_Initialize"
18}
19
20#-----------------------------------------------------------------
21function SRF_Update
22{
23    IGCM_debug_PushStack "SRF_Update"
24
25    ## 1. Modifications in orchidee.def parameter file
26
27    # Activate STOMATE if the compontent SBG=stomate is set in config.card
28    if [ X${config_ListOfComponents_SBG} = Xstomate ] ; then
29        # Activate stomate in orchidee.def
30        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE y
31    else
32        # Deactivate stomate in orchidee.def
33        IGCM_comp_modifyDefFile blocker orchidee.def STOMATE_OK_STOMATE n
34        # Deactivate output files for stomate
35        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 enabled .FALSE.
36        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_level 0
37        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate1 output_freq 1mo
38        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 enabled .FALSE.
39        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_level 0
40        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate2 output_freq 1mo
41        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 enabled .FALSE.
42        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_level 0
43        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate3 output_freq 1mo
44    fi
45
46    # Define in orchidee.def if restart file should be used
47    if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then
48        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc
49    else
50        IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE
51    fi
52
53    # 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)
54    if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then
55        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   1Y
56    fi
57
58    # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices
59    # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it.
60    if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then
61        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE   ${orchidee_UserChoices_VEGET_UPDATE}
62    else
63        IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y
64    fi
65
66    # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices
67    # If LAI_MAP is not definded in orchidee.card, set default value n
68    # Note: this option is only read by ORCHIDEE if starting without restart files
69    if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then
70        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   ${orchidee_UserChoices_LAI_MAP}
71    else
72        IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP   DEFAULT
73    fi
74
75    # Set DO_WOOD_HARVEST in orchidee.def acording to value set in orchidee.card section UserChoices
76    # If DO_WOOD_HARVEST is not definded in orchidee.card, set default value y
77    if [ ! X${orchidee_UserChoices_DO_WOOD_HARVEST} = X ] ; then
78        IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   ${orchidee_UserChoices_DO_WOOD_HARVEST}
79    else
80        IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST   DEFAULT
81    fi
82
83    # Activate creation of river description file only for the first period
84    if [ ${CumulPeriod} -eq 1 ] ; then
85        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y
86    else
87        IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n
88    fi
89
90    # Activate calcul of chemistry BVOC
91    if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then
92        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC}
93    else
94        IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n
95    fi
96
97    ## 2. Mangement of output and modifications of related xml files
98    # Modify file_def_orchidee.xml file using settings from orchidee.card
99    # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter
100    # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked.
101    # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated.
102    # Settings in config.card WriteFrequency are not used any more.
103   
104    if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then
105        # output_level_sechiba_history is not set in orchidee.card or it is set to NONE.
106        # Deactivate the file.
107        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE.
108        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0
109        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo
110    else
111        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled      .TRUE.
112        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history}
113        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history}
114    fi
115   
116    if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then
117        # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE.
118        # Deactivate the file.
119        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE.
120        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0
121        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo
122    else
123        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled      .TRUE.
124        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2}
125        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq  ${orchidee_UserChoices_output_freq_sechiba_out_2}
126    fi
127   
128    if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then
129        # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE.
130        # Deactivate the file.
131        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE.
132        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0
133        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo
134    else
135        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled      .TRUE.
136        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim}
137        IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq  ${orchidee_UserChoices_output_freq_sechiba_history_4dim}
138    fi
139       
140
141    # Add include of orchidee context in iodef.xml
142    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
143    echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
144    # Add inclusion of file context_input_orchidee.xml if this file exists
145    if [ -f context_input_orchidee.xml ] ; then
146        echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
147    fi
148    # Include xml files for output configuration if running with workflow CMIP6
149    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
150        echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp
151        echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp
152    fi
153    cp iodef.xml iodef.xml.tmp
154    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
155    rm iodef.xml.tmp add.tmp
156
157    # Add LongName as global attribute in XIOS output files (if LongName is not empty)
158    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
159        listfile=$(ls file_def*orchidee.xml)
160        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
161        for file in ${listfile}
162        do
163            cp ${file} ${file}.tmp
164            sed -e "/<file id/r add.tmp" \
165                ${file}.tmp > ${file}
166            rm ${file}.tmp
167        done
168        rm add.tmp
169    fi
170
171    #Compression level (if CompressionLevel is not empty)
172    if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then
173        echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel}
174        listfile=$(ls file_def*orchidee.xml)
175        for file in ${listfile}
176        do
177            sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file}
178        done
179    fi
180
181
182
183    IGCM_debug_PopStack "SRF_Update"
184}
185
186#-----------------------------------------------------------------
187function SRF_Finalize
188{
189    IGCM_debug_PushStack "SRF_Finalize"
190
191    IGCM_debug_PopStack "SRF_Finalize"
192}
Note: See TracBrowser for help on using the repository browser.