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

Last change on this file since 4604 was 4604, checked in by jgipsl, 5 years ago

Now also copy file_def_histdaystrataer_lmdz.xml added in the LMDZ/trunk.

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