source: CONFIG/UNIFORM/v7/ICOLMDZOR_v7/GENERAL/DRIVER/lmdz.driver @ 6100

Last change on this file since 6100 was 6100, checked in by aclsce, 2 years ago

Modified to allow the monitoring to work both in icosaedral and regular configurations.

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