source: CONFIG_DEVT/ICO_config/ICOLOR-SROUT.Anne/DRIVER/lmdz.driver @ 6225

Last change on this file since 6225 was 6225, checked in by acosce, 22 months ago

experiment use with ICO LMDZ ORCHIDEE new configuration (to be create)

  • master dynamico
  • orchidee2_2 7613
  • lmdz trunk 4227
  • icosa_lmdz 456
File size: 27.8 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function ATM_Initialize
4{
5    IGCM_debug_PushStack "ATM_Initialize"
6
7
8    # Define the resolution only if the composant ICO for DYNAMICO is not set in config.card
9    if [ X${config_ListOfComponents_ICO} = X ] ; then
10
11        # Read the resolution from the variables ResolAtm set in config.card UserChoices section or from .resol file
12        if [ X$ResolAtm != X ] ; then
13            # ResolAtm is set in config.card
14            RESOL_ATM_3D=${ResolAtm}
15        elif [ -f ${SUBMIT_DIR}/../.resol ] ; then
16            # ResolAtm was not set in config.card, try to read .resol file
17            eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x39
18        else
19            IGCM_debug_Exit "ResolAtm is not set in config.card and the .resol file does not exist."
20            IGCM_debug_Verif_Exit
21        fi
22       
23        RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' )
24        RESOL_ATM_X=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $1}' )
25        RESOL_ATM_Y=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $2}' )
26        RESOL_ATM_XY="${RESOL_ATM_X}x${RESOL_ATM_Y}"
27        RESOL_ATM=LMD${RESOL_ATM_X}${RESOL_ATM_Y}
28
29        IGCM_debug_Print 1 "The atomsopheric resolution is ${RESOL_ATM_3D} " 
30    else
31        RESOL_ATM_Z=${dynamico_UserChoices_RESOL_ATM_Z}
32        RESOL_NBP=${dynamico_UserChoices_RESOL_NBP}
33    fi
34
35    ##- LMDZ physics version
36    ##  Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics)
37    if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then
38        LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics}
39    else
40        LMDZ_Physics=AP
41    fi
42    echo LMDZ physics version : ${LMDZ_Physics}
43
44    ##- Create_etat0_limit version
45    ##  Define variable CREATE only if it is set in lmdz.card section UserChoices.
46    ##  This variable is only used in lmdz.card to choose input files.
47    if [ ! X${lmdz_UserChoices_CREATE} = X ] ; then
48        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices CREATE
49        CREATE=${lmdz_UserChoices_CREATE}
50        echo create_etat0_limit version : ${CREATE}
51    fi
52
53
54    ## - LMDZ choice of config.def file
55    ##   ConfType must be set in lmdz.card
56    ConfType=${lmdz_UserChoices_ConfType}
57
58
59    IGCM_debug_PopStack "ATM_Initialize"
60}
61
62#-----------------------------------------------------------------
63function ATM_Update
64{
65    IGCM_debug_PushStack "ATM_Update"
66
67    ##-- GHG forcing :
68    ##   If forcing file exist in run directory, read values for the current year
69    ##   and set in config.def. If not use the default value set in config.def
70
71    # Read value for solaire from file SOLARANDVOLCANOES.txt. If file not existing, take DEFAULT value from file.
72    IGCM_debug_Print 1 "Note that the solaire parameter is here below changed but it is only used by LMDZ for old physics(AP and NPv3.2)"
73    IGCM_debug_Print 1 "For newer physics with iflag_rrtm=1 and ok_suntime_rrtm=y, the solar constant is instead taken from solarforcing.nc file"
74    if [ -f SOLARANDVOLCANOES.txt ] ; then
75        value=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'`
76        if [ X"${value}" = X ] ; then
77            # The grep returned empty variable, stop execution
78            IGCM_debug_Exit "The file SOLARANDVOLCANOES.txt do not contain the current year."
79            IGCM_debug_Verif_Exit
80        fi
81    else
82        value=DEFAULT
83    fi
84    IGCM_comp_modifyDefFile nonblocker config.def solaire $value
85
86    # Read value for eccentricity from file Eccentricity.txt. If file not existing, take DEFAULT value from file.
87    if [ -f Eccentricity.txt ] ; then
88        value=`grep Annee_${year} Eccentricity.txt | awk -F= '{print $2}'`
89        if [ X"${value}" = X ] ; then
90            # The grep returned empty variable, stop execution
91            IGCM_debug_Exit "The file Eccentricity.txt do not contain the current year."
92            IGCM_debug_Verif_Exit
93        fi
94    else
95        value=DEFAULT
96    fi
97    IGCM_comp_modifyDefFile nonblocker config.def R_ecc $value
98
99    # Read value for obliquity from file Obliquity.txt. If file not existing, take DEFAULT value from file.
100    if [ -f Obliquity.txt ] ; then
101        value=`grep Annee_${year} Obliquity.txt | awk -F= '{print $2}'`
102        if [ X"${value}" = X ] ; then
103            # The grep returned empty variable, stop execution
104            IGCM_debug_Exit "The file Obliquity.txt do not contain the current year."
105            IGCM_debug_Verif_Exit
106        fi
107    else
108        value=DEFAULT
109    fi
110    IGCM_comp_modifyDefFile nonblocker config.def R_incl $value
111
112    # Read value for perihelie from file Perihelie.txt. If file not existing, take DEFAULT value from file.
113    if [ -f Perihelie.txt ] ; then
114        value=`grep Annee_${year} Perihelie.txt | awk -F= '{print $2}'`
115        if [ X"${value}" = X ] ; then
116            # The grep returned empty variable, stop execution
117            IGCM_debug_Exit "The file Perihelie.txt do not contain the current year."
118            IGCM_debug_Verif_Exit
119        fi
120    else
121        value=DEFAULT
122    fi
123    IGCM_comp_modifyDefFile nonblocker config.def R_peri $value
124
125    # Read value for co2_ppm from file CO2.txt. If file not existing, take DEFAULT value from file.
126    # Calculate co2_ppm_per as co2_ppm*4.
127    if [ -f CO2.txt ] ; then
128        value=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
129        if [ X"${value}" = X ] ; then
130            # The grep returned empty variable, stop execution
131            IGCM_debug_Exit "The file CO2.txt do not contain the current year."
132            IGCM_debug_Verif_Exit
133        fi
134        value4=`grep Annee_${year} CO2.txt | awk -F= '{print $2 * 4}'`
135    else
136        value=DEFAULT
137        value4=DEFAULT
138    fi
139    IGCM_comp_modifyDefFile nonblocker config.def co2_ppm $value
140    IGCM_comp_modifyDefFile nonblocker config.def co2_ppm_per $value4
141
142
143    # Read value for CH4_ppb from file CH4.txt. If file not existing, take DEFAULT value from file.
144    if [ -f CH4.txt ] ; then
145        value=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'`
146        if [ X"${value}" = X ] ; then
147            # The grep returned empty variable, stop execution
148            IGCM_debug_Exit "The file CH4.txt do not contain the current year."
149            IGCM_debug_Verif_Exit
150        fi
151    else
152        value=DEFAULT
153    fi
154    IGCM_comp_modifyDefFile nonblocker config.def CH4_ppb $value
155
156
157    # Read value for N2O_ppb from file N2O.txt. If file not existing, take DEFAULT value from file.
158    if [ -f N2O.txt ] ; then
159        value=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'`
160        if [ X"${value}" = X ] ; then
161            # The grep returned empty variable, stop execution
162            IGCM_debug_Exit "The file N2O.txt do not contain the current year."
163            IGCM_debug_Verif_Exit
164        fi
165    else
166        value=DEFAULT
167    fi
168    IGCM_comp_modifyDefFile nonblocker config.def N2O_ppb $value
169
170    # Read value for CFC11_ppt from file CFC11.txt. If file not existing, take DEFAULT value from file.
171    if [ -f CFC11.txt ] ; then
172        value=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'`
173        if [ X"${value}" = X ] ; then
174            # The grep returned empty variable, stop execution
175            IGCM_debug_Exit "The file CFC11.txt do not contain the current year."
176            IGCM_debug_Verif_Exit
177        fi
178    else
179        value=DEFAULT
180    fi
181    IGCM_comp_modifyDefFile nonblocker config.def CFC11_ppt $value
182
183
184    # Read value for CFC12_ppt from file CFC12.txt. If file not existing, take DEFAULT value from file.
185    if [ -f CFC12.txt ] ; then
186        value=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'`
187        if [ X"${value}" = X ] ; then
188            # The grep returned empty variable, stop execution
189            IGCM_debug_Exit "The file CFC12.txt do not contain the current year."
190            IGCM_debug_Verif_Exit
191        fi
192    else
193        value=DEFAULT
194    fi
195    IGCM_comp_modifyDefFile nonblocker config.def CFC12_ppt $value
196
197
198    ## Coupling Time Step : Take value of FreqCoupling set in oasis.card or if it is not set, take default value 86400
199    LMDZ_t_coupl=${oasis_UserChoices_FreqCoupling:-86400}
200    IGCM_debug_Print 3 "LMDZ_t_coupl "   ${LMDZ_t_coupl}
201    IGCM_comp_modifyDefFile nonblocker config.def t_coupl   ${LMDZ_t_coupl} 
202
203
204    ## Activate diagnostic output files and set output_level for each file
205
206    # histmth
207    if [ X${lmdz_UserChoices_output_level_histmth} = X ] || [ X${lmdz_UserChoices_output_level_histmth} = XNONE ] ; then
208        IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth enabled FALSE
209        IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth output_level 0
210    else
211        IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth enabled TRUE
212        IGCM_comp_modifyXmlFile nonblocker file_def_histmth_lmdz.xml histmth output_level ${lmdz_UserChoices_output_level_histmth} 
213    fi
214
215    # histday
216    if [ X${lmdz_UserChoices_output_level_histday} = X ] || [ X${lmdz_UserChoices_output_level_histday} = XNONE ] ; then
217        IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday enabled FALSE
218        IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday output_level 0
219    else
220        IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday enabled TRUE
221        IGCM_comp_modifyXmlFile nonblocker file_def_histday_lmdz.xml histday output_level ${lmdz_UserChoices_output_level_histday} 
222    fi
223
224    # histhf
225    if [ X${lmdz_UserChoices_output_level_histhf} = X ] || [ X${lmdz_UserChoices_output_level_histhf} = XNONE ] ; then
226        IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf enabled FALSE
227        IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level 0
228    else
229        IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf enabled TRUE
230        IGCM_comp_modifyXmlFile nonblocker file_def_histhf_lmdz.xml histhf output_level ${lmdz_UserChoices_output_level_histhf} 
231    fi
232
233    # histmthNMC
234    if [ X${lmdz_UserChoices_output_level_histmthNMC} = X ] || [ X${lmdz_UserChoices_output_level_histmthNMC} = XNONE ] ; then
235        IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC enabled FALSE
236        IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC output_level 0
237    else
238        IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC enabled TRUE
239        IGCM_comp_modifyXmlFile nonblocker file_def_histmthNMC_lmdz.xml histmthNMC output_level ${lmdz_UserChoices_output_level_histmthNMC} 
240    fi
241
242    # histdayNMC
243    if [ X${lmdz_UserChoices_output_level_histdayNMC} = X ] || [ X${lmdz_UserChoices_output_level_histdayNMC} = XNONE ] ; then
244        IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC enabled FALSE
245        IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC output_level 0
246    else
247        IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC enabled TRUE
248        IGCM_comp_modifyXmlFile nonblocker file_def_histdayNMC_lmdz.xml histdayNMC output_level ${lmdz_UserChoices_output_level_histdayNMC} 
249    fi
250
251    # histhfNMC
252    if [ X${lmdz_UserChoices_output_level_histhfNMC} = X ] || [ X${lmdz_UserChoices_output_level_histhfNMC} = XNONE ] ; then
253        IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC enabled FALSE
254        IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC output_level 0
255    else
256        IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC enabled TRUE
257        IGCM_comp_modifyXmlFile nonblocker file_def_histhfNMC_lmdz.xml histhfNMC output_level ${lmdz_UserChoices_output_level_histhfNMC} 
258    fi
259
260    # histstrataer
261    if [ X${lmdz_UserChoices_output_level_histstrataer} = X ] || [ X${lmdz_UserChoices_output_level_histstrataer} = XNONE ] ; then
262        IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled FALSE
263        IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer output_level 0
264    else
265        IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer enabled TRUE
266        IGCM_comp_modifyXmlFile nonblocker file_def_histstrataer_lmdz.xml histstrataer output_level ${lmdz_UserChoices_output_level_histstrataer} 
267    fi
268
269    # histdaystrataer
270    if [ X${lmdz_UserChoices_output_level_histdaystrataer} = X ] || [ X${lmdz_UserChoices_output_level_histdaystrataer} = XNONE ] ; then
271    IGCM_comp_modifyXmlFile nonblocker file_def_histdaystrataer_lmdz.xml histdaystrataer enabled FALSE
272    IGCM_comp_modifyXmlFile nonblocker file_def_histdaystrataer_lmdz.xml histdaystrataer output_level 0
273    else
274    IGCM_comp_modifyXmlFile nonblocker file_def_histdaystrataer_lmdz.xml histdaystrataer enabled TRUE
275    IGCM_comp_modifyXmlFile nonblocker file_def_histdaystrataer_lmdz.xml histdaystrataer output_level ${lmdz_UserChoices_output_level_histstrataer}
276    fi
277
278    # histstn
279    if [ X${lmdz_UserChoices_output_level_histstn} = X ] || [ X${lmdz_UserChoices_output_level_histstn} = XNONE ] ; then
280        IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn enabled FALSE
281        IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn output_level 0
282    else
283        IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn enabled TRUE
284        IGCM_comp_modifyXmlFile nonblocker file_def_histstn_lmdz.xml histstn output_level ${lmdz_UserChoices_output_level_histstn} 
285    fi
286
287
288    # histmthCOSP
289    if [ X${lmdz_UserChoices_output_level_histmthCOSP} = X ] || [ X${lmdz_UserChoices_output_level_histmthCOSP} = XNONE ] ; then
290        IGCM_comp_modifyXmlFile nonblocker file_def_histmthCOSP_lmdz.xml histmthCOSP enabled FALSE
291        IGCM_comp_modifyXmlFile nonblocker file_def_histmthCOSP_lmdz.xml histmthCOSP output_level 0
292    else
293        IGCM_comp_modifyXmlFile nonblocker file_def_histmthCOSP_lmdz.xml histmthCOSP enabled TRUE
294        IGCM_comp_modifyXmlFile nonblocker file_def_histmthCOSP_lmdz.xml histmthCOSP output_level ${lmdz_UserChoices_output_level_histmthCOSP} 
295    fi
296
297
298    # histdayCOSP
299    if [ X${lmdz_UserChoices_output_level_histdayCOSP} = X ] || [ X${lmdz_UserChoices_output_level_histdayCOSP} = XNONE ] ; then
300        IGCM_comp_modifyXmlFile nonblocker file_def_histdayCOSP_lmdz.xml histdayCOSP enabled FALSE
301        IGCM_comp_modifyXmlFile nonblocker file_def_histdayCOSP_lmdz.xml histdayCOSP output_level 0
302    else
303        IGCM_comp_modifyXmlFile nonblocker file_def_histdayCOSP_lmdz.xml histdayCOSP enabled TRUE
304        IGCM_comp_modifyXmlFile nonblocker file_def_histdayCOSP_lmdz.xml histdayCOSP output_level ${lmdz_UserChoices_output_level_histdayCOSP} 
305    fi
306
307
308    # histhfCOSP
309    if [ X${lmdz_UserChoices_output_level_histhfCOSP} = X ] || [ X${lmdz_UserChoices_output_level_histhfCOSP} = XNONE ] ; then
310        IGCM_comp_modifyXmlFile nonblocker file_def_histhfCOSP_lmdz.xml histhfCOSP enabled FALSE
311        IGCM_comp_modifyXmlFile nonblocker file_def_histhfCOSP_lmdz.xml histhfCOSP output_level 0
312    else
313        IGCM_comp_modifyXmlFile nonblocker file_def_histhfCOSP_lmdz.xml histhfCOSP enabled TRUE
314        IGCM_comp_modifyXmlFile nonblocker file_def_histhfCOSP_lmdz.xml histhfCOSP output_level ${lmdz_UserChoices_output_level_histhfCOSP} 
315    fi
316
317
318    ## run.def parameters
319
320
321    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
322
323    if [ ${CumulPeriod} -eq 1 ] ; then
324        IGCM_comp_modifyDefFile blocker run.def raz_date  1
325    else
326        IGCM_comp_modifyDefFile blocker run.def raz_date  0
327    fi
328
329    ##-- Calendar type for LMDZ and create_etat0_limit
330    #    calend is read from both LMDZ dynamics and physics parts of the model
331    case ${config_UserChoices_CalendarType} in
332        leap|gregorian)
333            IGCM_comp_modifyDefFile blocker run.def calend  gregorian ;;
334        noleap)
335            IGCM_comp_modifyDefFile blocker run.def calend  earth_365d ;;
336        360d)
337            IGCM_comp_modifyDefFile blocker run.def calend  earth_360d ;;
338        *)
339            IGCM_comp_modifyDefFile blocker run.def calend  earth_360d ;;
340    esac
341
342
343    ## -- Modify more calendar related variables.
344    IGCM_comp_modifyDefFile blocker run.def dayref    ${InitDay}
345    # Following variables are read by LMDZ dynamics
346    IGCM_comp_modifyDefFile blocker run.def nday      ${PeriodLengthInDays}
347
348    # Set anneeref different for gcm and create_etat0_limit mode
349    # Test if keyword create_etat0_limit=y is set in dynamico.card or in lmdz.card
350    if [ X${lmdz_UserChoices_create_etat0_limit} = Xy ] || [ X${dynamico_UserChoices_create_etat0_limit} = Xy ] ; then
351       # for case create_etat0_limit : always take current year
352       IGCM_comp_modifyDefFile blocker run.def anneeref ${year}
353       
354       # Temporary, set use_filtre_fft=n because we now use dyn3d for ce0l version where fft is not implemented.
355       # In more recent versions of LMDZ, this will not be needed.
356           IGCM_comp_modifyDefFile force   run.def use_filtre_fft n
357    else
358        # for case gcm : take first year of simulation
359        IGCM_comp_modifyDefFile blocker run.def anneeref ${InitYear}
360    fi
361   
362
363    ## Determine from the variable ListOfComponents in config.card coupling to external models
364    ## and set corresponding parameters in run.def
365    echo ListOfComponents now running : ${config_ListOfComponents[*]}
366
367    if [ X${config_ListOfComponents_SRF} = Xorchidee ] ; then
368        echo "Activate ORCHIDEE, set VEGET=y in run.def"
369        IGCM_comp_modifyDefFile blocker run.def VEGET y
370    else
371        echo "No ORCHIDEE, set VEGET=n in run.def"
372        IGCM_comp_modifyDefFile blocker run.def VEGET n
373    fi
374
375    if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then
376        echo "Activate coupling to ocean, set type_ocean=couple in run.def"
377        IGCM_comp_modifyDefFile blocker run.def type_ocean couple
378    else
379        echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def"
380        IGCM_comp_modifyDefFile nonblocker run.def type_ocean force
381    fi
382
383    if [ X${config_ListOfComponents_CHM} = Xinca ] ; then
384        echo "Activate coupling to INCA, set type_trac=inca in run.def"
385        IGCM_comp_modifyDefFile blocker run.def type_trac inca
386        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1
387    elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then
388        echo "Activate coupling to REPROBUS, set type_trac=repr in run.def"
389        IGCM_comp_modifyDefFile blocker run.def type_trac repr
390        IGCM_comp_modifyDefFile blocker run.def config_inca none
391        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1
392    elif [ X${config_UserChoices_ConfigType} = XESMCO2 ] ; then
393        echo "ESM config, set type_trac=co2i in run.def"
394        IGCM_comp_modifyDefFile blocker run.def type_trac co2i
395        IGCM_comp_modifyDefFile blocker run.def config_inca none
396        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1 
397    elif [ X${lmdz_UserChoices_LMDZ_strataero} = Xy ] ; then
398        echo "No coupling to chemistry model but it is a LMDZ STRATAER configuration, set type_trac=coag in run.def"
399        IGCM_comp_modifyDefFile blocker run.def type_trac coag
400        IGCM_comp_modifyDefFile blocker run.def config_inca none
401        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1 
402    else
403        echo "No coupling to chemistry model, set type_trac=lmdz in run.def"
404        IGCM_comp_modifyDefFile blocker run.def type_trac lmdz
405        IGCM_comp_modifyDefFile blocker run.def config_inca none
406        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 0
407    fi
408
409    # run.def : Activate the new calving
410    if [ ! X${lmdz_UserChoices_cpl_old_calving} = X ]; then
411        IGCM_comp_modifyDefFile nonblocker run.def cpl_old_calving ${lmdz_UserChoices_cpl_old_calving}
412    else
413        IGCM_comp_modifyDefFile nonblocker run.def cpl_old_calving y
414    fi 
415
416    # physiq.def : Activate the call to phytrac
417    if [ ! X${lmdz_UserChoices_ok_bug_cv_trac} = X ]; then
418        IGCM_comp_modifyDefFile nonblocker physiq.def ok_bug_cv_trac  ${lmdz_UserChoices_ok_bug_cv_trac}
419    else
420        IGCM_comp_modifyDefFile nonblocker physiq.def ok_bug_cv_trac  n
421    fi 
422
423    # config.def : Activate aerosol strato
424    if [ ! X${lmdz_UserChoices_flag_aerosol_strat} = X ]; then
425        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol_strat ${lmdz_UserChoices_flag_aerosol_strat}
426    else
427        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol_strat DEFAULT
428    fi 
429
430    # config.def : Activate direct radiative effect if ok_ade=y
431    if [ ! X${lmdz_UserChoices_ok_ade} = X ]; then
432        IGCM_comp_modifyDefFile nonblocker config.def ok_ade ${lmdz_UserChoices_ok_ade}
433    else
434        IGCM_comp_modifyDefFile nonblocker config.def ok_ade n
435    fi 
436
437    # config.def : Activate indirect radiative effect if ok_aie=y
438    if [ ! X${lmdz_UserChoices_ok_aie} = X ]; then
439        IGCM_comp_modifyDefFile nonblocker config.def ok_aie ${lmdz_UserChoices_ok_aie}
440    else
441        IGCM_comp_modifyDefFile nonblocker config.def ok_aie n
442    fi 
443
444    # config.def : Activate online aerosol coupled model if aerosol_couple=y
445    if [ ! X${lmdz_UserChoices_aerosol_couple} = X ]; then
446        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple}
447    else
448        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple n
449    fi 
450
451    # config.def : Activate online Ozone chemistry coupled model if chemistry_couple=y
452    if [ ! X${lmdz_UserChoices_chemistry_couple} = X ]; then
453        IGCM_comp_modifyDefFile nonblocker config.def chemistry_couple ${lmdz_UserChoices_chemistry_couple}
454    else
455        IGCM_comp_modifyDefFile nonblocker config.def chemistry_couple n
456    fi 
457
458    # config.def : Activate reading of ozone in climatology if read_climoz=2
459    if [ ! X${lmdz_UserChoices_read_climoz} = X ]; then
460        IGCM_comp_modifyDefFile nonblocker config.def read_climoz ${lmdz_UserChoices_read_climoz}
461    else
462        IGCM_comp_modifyDefFile nonblocker config.def read_climoz 0     
463    fi 
464
465    # config.def : Choose aerosol use in radiative effect
466    #  type of coupled aerosol =1 (default) =2 => bc  only =3 => pom only =4 => seasalt only
467    # =5 => dust only =6 => all aerosol   
468    if [ ! X${lmdz_UserChoices_flag_aerosol} = X ]; then
469        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol}
470    else
471        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol 0
472    fi 
473
474    # config.def : Activate calcul of Cloud droplet number concentration if ok_cdnc=y
475    if [ ! X${lmdz_UserChoices_ok_cdnc} = X ]; then
476        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc}
477    else
478        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc n
479    fi 
480
481    # config.def : Activate COSP
482    if [ ! X${lmdz_UserChoices_LMDZ_COSP_OK} = X ]; then
483        IGCM_comp_modifyDefFile nonblocker config.def ok_cosp ${lmdz_UserChoices_LMDZ_COSP_OK}
484    else
485        IGCM_comp_modifyDefFile nonblocker config.def ok_cosp n
486    fi 
487
488    # config.def : Modify parameter pmagic if it is set in lmdz.card
489    if [ ! X${lmdz_UserChoices_pmagic} = X ]; then
490        IGCM_comp_modifyDefFile nonblocker config.def pmagic ${lmdz_UserChoices_pmagic}
491    else
492        # Take default value set in config.def
493        IGCM_comp_modifyDefFile nonblocker config.def pmagic DEFAULT
494    fi
495
496    if [ X${config_UserChoices_ConfigType} = XESMCO2 ] ; then
497        # Set carbon cycle parameters according to parmeters in lmdz.card
498        IGCM_comp_modifyDefFile blocker config.def level_coupling_esm 2
499        IGCM_comp_modifyDefFile blocker config.def carbon_cycle_cpl ${lmdz_UserChoices_carbon_cycle_cpl} 
500        IGCM_comp_modifyDefFile blocker config.def carbon_cycle_tr ${lmdz_UserChoices_carbon_cycle_tr}
501        IGCM_comp_modifyDefFile blocker config.def carbon_cycle_rad ${lmdz_UserChoices_carbon_cycle_rad}
502    else
503        # Take default value set in config.def
504        IGCM_comp_modifyDefFile nonblocker config.def level_coupling_esm DEFAULT
505        IGCM_comp_modifyDefFile nonblocker config.def carbon_cycle_cpl DEFAULT
506        IGCM_comp_modifyDefFile nonblocker config.def carbon_cycle_tr DEFAULT
507        IGCM_comp_modifyDefFile nonblocker config.def carbon_cycle_rad DEFAULT
508    fi
509
510    # config.def : Modify parameter ok_volcan if ok_volcan=y or LMDZ_strataero=y in lmdz.card
511    # Note: ok_volcan is a flag allowing a double-call with/without natural forcing (instead of with/without anthro forcing).
512    if [ ! X${lmdz_UserChoices_ok_volcan} = X ] || [ X${lmdz_UserChoices_LMDZ_strataero} = Xy ] ; then
513        IGCM_comp_modifyDefFile nonblocker config.def ok_volcan ${lmdz_UserChoices_ok_volcan}
514    else
515        # Take default value set in config.def
516        IGCM_comp_modifyDefFile nonblocker config.def ok_volcan DEFAULT
517    fi
518
519
520    # physiq.def : Modify parameter tau_gl if it is set in lmdz.card
521    if [ ! X${lmdz_UserChoices_tau_gl} = X ]; then
522        IGCM_comp_modifyDefFile nonblocker physiq.def tau_gl ${lmdz_UserChoices_tau_gl}
523    else
524        # Take default value set in physiq.def
525        IGCM_comp_modifyDefFile nonblocker physiq.def tau_gl DEFAULT
526    fi
527   
528
529    # guide.def : Activate nudging if ok_guide=y set in lmdz.card
530    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then
531        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide  ${lmdz_UserChoices_ok_guide}
532    else
533        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide n
534    fi
535
536
537    # Specific ByPass option only used with LMDZ dynamcis (without DYNMAICO)
538    if [ X${config_ListOfComponents_ICO} = X ] ; then
539
540        ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
541        ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta}
542        if [ X"${ByPass_hgardfou_teta}" = X"y" ] ; then
543            awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
544            IGCM_sys_Mv gcm.def.tmp gcm.def
545            echo
546            IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
547            echo
548            cat gcm.def
549            ByPass_hgardfou_teta=n
550            IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
551        fi
552       
553        ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
554        ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats}
555        if [ X"${ByPass_hgardfou_mats}" = X"y" ] ; then
556            sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
557            IGCM_sys_Mv gcm.def.tmp gcm.def
558            echo
559            IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
560            echo
561            cat gcm.def
562            ByPass_hgardfou_mats=n
563            IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
564        fi
565    fi
566
567
568    # Add include of LMDZ context in iodef.xml
569    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
570    echo '<context id="LMDZ" src="./context_lmdz.xml"/>' > add.tmp
571    # Add inclusion of file context_input_lmdz.xml if this file exists
572    if [ -f context_input_lmdz.xml ] ; then
573        echo '<context id="LMDZ" src="./context_input_lmdz.xml"/>' >> add.tmp
574    fi
575    # Include xml files for output configuration if running with workflow CMIP6
576    if [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ; then
577        echo '<context id="LMDZ" src="./ping_lmdz.xml"/>' >> add.tmp
578        echo '<context id="LMDZ" src="./dr2xml_lmdz.xml"/>' >> add.tmp
579    fi
580    cp iodef.xml iodef.xml.tmp
581    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
582    rm iodef.xml.tmp add.tmp
583
584    #Long Name as global attribute (if LongName is not empty)
585    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
586        listfile=$(ls file_def*lmdz.xml)
587        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
588        for file in ${listfile}
589        do
590            cp ${file} ${file}.tmp
591            sed -e "/<file id/r add.tmp" \
592                ${file}.tmp > ${file}
593            rm ${file}.tmp
594        done
595        rm add.tmp
596    fi
597           
598
599    # Compression level (if CompressionLevel is not empty)
600    if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then
601        echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel}
602        listfile=$(ls file_def*lmdz.xml)
603        for file in ${listfile} ; do
604            sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file}
605        done
606    fi
607
608
609    # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card
610    if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
611        if [ ${RESOL_NBP} == 40  ] ; then
612            valuei=144
613            valuej=143
614        elif [ ${RESOL_NBP} == 80  ] ; then
615            valuei=360
616            valuej=180
617        elif [ ${RESOL_NBP} == 160  ] ; then
618            valuei=720
619            valuej=360
620    elif [ ${RESOL_NBP} == 320  ] ; then
621        valuei=1440
622        valuej=720
623        else
624            IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers"
625            IGCM_debug_Verif_Exit
626        fi
627
628        IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_lmdz.xml"
629        cp context_lmdz.xml context_lmdz.xml.init
630        sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \
631            -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \
632            context_lmdz.xml.init > context_lmdz.xml
633    fi
634
635
636    IGCM_debug_PopStack "ATM_Update"
637}
638
639#-----------------------------------
640function ATM_Finalize
641{
642    IGCM_debug_PushStack "ATM_Finalize"
643
644    IGCM_debug_Print 1 "FINALIZE ATM !"
645
646    IGCM_debug_PopStack "ATM_Finalize"
647}
648
649
Note: See TracBrowser for help on using the repository browser.