1 | #!/bin/ksh |
---|
2 | ## Driver for the component SRF corresponding to the sechiba part of ORCHIDEE |
---|
3 | #----------------------------------------------------------------- |
---|
4 | function 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 | #----------------------------------------------------------------- |
---|
21 | function 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 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 enabled .FALSE. |
---|
45 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 output_level 0 |
---|
46 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml stomate4 output_freq 1mo |
---|
47 | fi |
---|
48 | |
---|
49 | # Define in orchidee.def if restart file should be used |
---|
50 | if ( [ ${CumulPeriod} -ne 1 ] || [ "${config_SRF_Restart}" != "n" ] ) ; then |
---|
51 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in sechiba_rest_in.nc |
---|
52 | else |
---|
53 | IGCM_comp_modifyDefFile blocker orchidee.def SECHIBA_restart_in NONE |
---|
54 | fi |
---|
55 | |
---|
56 | # 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) |
---|
57 | if [ X${orchidee_UserChoices_VEGET_UPDATE_at_start} = Xy ] && [ ${CumulPeriod} -eq 1 ] ; then |
---|
58 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 1Y |
---|
59 | fi |
---|
60 | |
---|
61 | # Modify in orchidee.def VEGET_UPDATE if it is set in orchidee.card section UserChoices |
---|
62 | # Note: if the variable has been set by VEGET_UPDATE_at_start, this section will not overwrite it. |
---|
63 | if [ ! X${orchidee_UserChoices_VEGET_UPDATE} = X ] ; then |
---|
64 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE ${orchidee_UserChoices_VEGET_UPDATE} |
---|
65 | else |
---|
66 | IGCM_comp_modifyDefFile nonblocker orchidee.def VEGET_UPDATE 0Y |
---|
67 | fi |
---|
68 | |
---|
69 | # Set parameters related to ROUTING in orchidee.def |
---|
70 | if [ X${orchidee_UserChoices_ROUTING} = X ] || [ X${orchidee_UserChoices_ROUTING} = Xstandard ]; then |
---|
71 | # Nothing is set or ROUTING=standard in orchidee.def, default option |
---|
72 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y |
---|
73 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD standard |
---|
74 | elif [ X${orchidee_UserChoices_ROUTING} = Xsimple ]; then |
---|
75 | # ROUTING=simple is set in orchidee.card |
---|
76 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y |
---|
77 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD simple |
---|
78 | elif [ X${orchidee_UserChoices_ROUTING} = Xhighres ]; then |
---|
79 | # ROUTING=highres is set in orchidee.card |
---|
80 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING y |
---|
81 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD highres |
---|
82 | else |
---|
83 | # ROUTING=off, routing will be deactivated |
---|
84 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_ROUTING n |
---|
85 | IGCM_comp_modifyDefFile nonblocker orchidee.def ROUTING_METHOD standard |
---|
86 | fi |
---|
87 | |
---|
88 | # Set LAI_MAP in orchidee.def acording to value set in orchidee.card section UserChoices |
---|
89 | # If LAI_MAP is not definded in orchidee.card, set default value n |
---|
90 | # Note: this option is only read by ORCHIDEE if starting without restart files |
---|
91 | if [ ! X${orchidee_UserChoices_LAI_MAP} = X ] ; then |
---|
92 | IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP ${orchidee_UserChoices_LAI_MAP} |
---|
93 | else |
---|
94 | IGCM_comp_modifyDefFile nonblocker orchidee.def LAI_MAP DEFAULT |
---|
95 | fi |
---|
96 | |
---|
97 | # Set DO_WOOD_HARVEST in orchidee.def acording to value set in orchidee.card section UserChoices |
---|
98 | # If DO_WOOD_HARVEST is not definded in orchidee.card, set default value y |
---|
99 | if [ ! X${orchidee_UserChoices_DO_WOOD_HARVEST} = X ] ; then |
---|
100 | IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST ${orchidee_UserChoices_DO_WOOD_HARVEST} |
---|
101 | else |
---|
102 | IGCM_comp_modifyDefFile nonblocker orchidee.def DO_WOOD_HARVEST DEFAULT |
---|
103 | fi |
---|
104 | |
---|
105 | # Activate creation of river description file only for the first period |
---|
106 | if [ ${CumulPeriod} -eq 1 ] ; then |
---|
107 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC y |
---|
108 | else |
---|
109 | IGCM_comp_modifyDefFile nonblocker orchidee.def RIVER_DESC n |
---|
110 | fi |
---|
111 | |
---|
112 | # Activate calcul of chemistry BVOC |
---|
113 | if [ ! X${orchidee_UserChoices_CHEMISTRY_BVOC} = X ] ; then |
---|
114 | IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC ${orchidee_UserChoices_CHEMISTRY_BVOC} |
---|
115 | else |
---|
116 | IGCM_comp_modifyDefFile nonblocker orchidee.def CHEMISTRY_BVOC n |
---|
117 | fi |
---|
118 | |
---|
119 | ## 2. Mangement of output and modifications of related xml files |
---|
120 | # Modify file_def_orchidee.xml file using settings from orchidee.card |
---|
121 | # We here suppose that for each file, in orchidee.card UserChoices section, if the parameter |
---|
122 | # output_level_filename is set, then also output_freq_filename must be set. The existance of output_freq_filename will not be checked. |
---|
123 | # If output_level_filename=NONE or if it is not set, the corresponding file will be deactivated. |
---|
124 | # Settings in config.card WriteFrequency are not used any more. |
---|
125 | |
---|
126 | if [ X${orchidee_UserChoices_output_level_sechiba_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history} = XNONE ] ; then |
---|
127 | # output_level_sechiba_history is not set in orchidee.card or it is set to NONE. |
---|
128 | # Deactivate the file. |
---|
129 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .FALSE. |
---|
130 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level 0 |
---|
131 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq 1mo |
---|
132 | else |
---|
133 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 enabled .TRUE. |
---|
134 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_level ${orchidee_UserChoices_output_level_sechiba_history} |
---|
135 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba1 output_freq ${orchidee_UserChoices_output_freq_sechiba_history} |
---|
136 | fi |
---|
137 | |
---|
138 | if [ X${orchidee_UserChoices_output_level_sechiba_out_2} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_out_2} = XNONE ] ; then |
---|
139 | # output_level_sechiba_out_2 is not set in orchidee.card or it is set to NONE. |
---|
140 | # Deactivate the file. |
---|
141 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .FALSE. |
---|
142 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level 0 |
---|
143 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq 1mo |
---|
144 | else |
---|
145 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 enabled .TRUE. |
---|
146 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_level ${orchidee_UserChoices_output_level_sechiba_out_2} |
---|
147 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba2 output_freq ${orchidee_UserChoices_output_freq_sechiba_out_2} |
---|
148 | fi |
---|
149 | |
---|
150 | if [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_history_4dim} = XNONE ] ; then |
---|
151 | # output_level_sechiba_history_4dim is not set in orchidee.card or it is set to NONE. |
---|
152 | # Deactivate the file. |
---|
153 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .FALSE. |
---|
154 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level 0 |
---|
155 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq 1mo |
---|
156 | else |
---|
157 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 enabled .TRUE. |
---|
158 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_level ${orchidee_UserChoices_output_level_sechiba_history_4dim} |
---|
159 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechiba3 output_freq ${orchidee_UserChoices_output_freq_sechiba_history_4dim} |
---|
160 | fi |
---|
161 | |
---|
162 | |
---|
163 | # sechiba_stomate_history.nc: small output file with variables from the whole model mixed in the same file |
---|
164 | if [ X${orchidee_UserChoices_output_level_sechiba_stomate_history} = X ] || [ X${orchidee_UserChoices_output_level_sechiba_stomate_history} = XNONE ] ; then |
---|
165 | # output_level_sechiba_history_4dim is not set in sechiba.card or it is set to NONE. |
---|
166 | # Deactivate the file. |
---|
167 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 enabled .FALSE. |
---|
168 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_level 0 |
---|
169 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_freq 1mo |
---|
170 | else |
---|
171 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 enabled .TRUE. |
---|
172 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_level ${orchidee_UserChoices_output_level_sechiba_stomate_history} |
---|
173 | IGCM_comp_modifyXmlFile nonblocker file_def_orchidee.xml sechibastomate1 output_freq ${orchidee_UserChoices_output_freq_sechiba_stomate_history} |
---|
174 | fi |
---|
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 | |
---|
181 | # Add inclusion of file context_input_orchidee.xml if this file exists |
---|
182 | if [ -f context_input_orchidee.xml ] ; then |
---|
183 | echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp |
---|
184 | fi |
---|
185 | |
---|
186 | # Add inclusion of file context_routing_orchidee.xml if this file exists |
---|
187 | if [ -f context_routing_orchidee.xml ] ; then |
---|
188 | echo '<context id="orchidee" src="./context_routing_orchidee.xml"/>' >> add.tmp |
---|
189 | fi |
---|
190 | |
---|
191 | # Include xml files for output configuration if running with workflow CMIP6 |
---|
192 | if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then |
---|
193 | echo '<context id="orchidee" src="./ping_orchidee.xml"/>' >> add.tmp |
---|
194 | echo '<context id="orchidee" src="./dr2xml_orchidee.xml"/>' >> add.tmp |
---|
195 | fi |
---|
196 | cp iodef.xml iodef.xml.tmp |
---|
197 | sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml |
---|
198 | rm iodef.xml.tmp add.tmp |
---|
199 | |
---|
200 | # Add LongName as global attribute in XIOS output files (if LongName is not empty) |
---|
201 | if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then |
---|
202 | listfile=$(ls file_def*orchidee.xml) |
---|
203 | echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp |
---|
204 | for file in ${listfile} |
---|
205 | do |
---|
206 | cp ${file} ${file}.tmp |
---|
207 | sed -e "/<file id/r add.tmp" \ |
---|
208 | ${file}.tmp > ${file} |
---|
209 | rm ${file}.tmp |
---|
210 | done |
---|
211 | rm add.tmp |
---|
212 | fi |
---|
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 | |
---|
225 | IGCM_debug_PopStack "SRF_Update" |
---|
226 | } |
---|
227 | |
---|
228 | #----------------------------------------------------------------- |
---|
229 | function SRF_Finalize |
---|
230 | { |
---|
231 | IGCM_debug_PushStack "SRF_Finalize" |
---|
232 | |
---|
233 | IGCM_debug_PopStack "SRF_Finalize" |
---|
234 | } |
---|