source: CONFIG/UNIFORM/v7/IPSLCM7/GENERAL/DRIVER/lmdz.driver @ 6743

Last change on this file since 6743 was 6743, checked in by aclsce, 4 months ago

Added nbp60 case for interpolation target grid.

File size: 29.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        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_histdaystrataer}
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 "lmdz|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    elif [ X${config_UserChoices_ConfigType} = XESMCO2AER ] ; then
404        echo "ESM config, with INCA and CO2i, set type_trac=inco in run.def"
405        IGCM_comp_modifyDefFile blocker run.def type_trac inco
406        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1
407    else
408        echo "No coupling to chemistry model, set type_trac=lmdz in run.def"
409        IGCM_comp_modifyDefFile blocker run.def type_trac lmdz
410        IGCM_comp_modifyDefFile blocker run.def config_inca none
411        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 0
412    fi
413
414    # run.def : Activate the new calving
415    if [ ! X${lmdz_UserChoices_cpl_old_calving} = X ]; then
416        IGCM_comp_modifyDefFile nonblocker run.def cpl_old_calving ${lmdz_UserChoices_cpl_old_calving}
417    else
418        IGCM_comp_modifyDefFile nonblocker run.def cpl_old_calving y
419    fi 
420
421    # physiq.def : Activate the call to phytrac
422    if [ ! X${lmdz_UserChoices_ok_bug_cv_trac} = X ]; then
423        IGCM_comp_modifyDefFile nonblocker physiq.def ok_bug_cv_trac  ${lmdz_UserChoices_ok_bug_cv_trac}
424    else
425        IGCM_comp_modifyDefFile nonblocker physiq.def ok_bug_cv_trac  n
426    fi 
427
428    # config.def : Activate aerosol strato
429    if [ ! X${lmdz_UserChoices_flag_aerosol_strat} = X ]; then
430        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol_strat ${lmdz_UserChoices_flag_aerosol_strat}
431    else
432        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol_strat DEFAULT
433    fi 
434
435    # config.def : Activate direct radiative effect if ok_ade=y
436    if [ ! X${lmdz_UserChoices_ok_ade} = X ]; then
437        IGCM_comp_modifyDefFile nonblocker config.def ok_ade ${lmdz_UserChoices_ok_ade}
438    else
439        IGCM_comp_modifyDefFile nonblocker config.def ok_ade n
440    fi 
441
442    # config.def : Activate indirect radiative effect if ok_aie=y
443    if [ ! X${lmdz_UserChoices_ok_aie} = X ]; then
444        IGCM_comp_modifyDefFile nonblocker config.def ok_aie ${lmdz_UserChoices_ok_aie}
445    else
446        IGCM_comp_modifyDefFile nonblocker config.def ok_aie n
447    fi 
448
449    # config.def : Activate online aerosol coupled model if aerosol_couple=y
450    if [ ! X${lmdz_UserChoices_aerosol_couple} = X ]; then
451        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple}
452    else
453        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple n
454    fi 
455
456    # config.def : Activate online Ozone chemistry coupled model if chemistry_couple=y
457    if [ ! X${lmdz_UserChoices_chemistry_couple} = X ]; then
458        IGCM_comp_modifyDefFile nonblocker config.def chemistry_couple ${lmdz_UserChoices_chemistry_couple}
459    else
460        IGCM_comp_modifyDefFile nonblocker config.def chemistry_couple n
461    fi 
462
463    # config.def : Activate reading of ozone in climatology if read_climoz=2
464    if [ ! X${lmdz_UserChoices_read_climoz} = X ]; then
465        IGCM_comp_modifyDefFile nonblocker config.def read_climoz ${lmdz_UserChoices_read_climoz}
466    else
467        IGCM_comp_modifyDefFile nonblocker config.def read_climoz 0     
468    fi 
469
470    # config.def : Choose aerosol use in radiative effect
471    #  type of coupled aerosol =1 (default) =2 => bc  only =3 => pom only =4 => seasalt only
472    # =5 => dust only =6 => all aerosol   
473    if [ ! X${lmdz_UserChoices_flag_aerosol} = X ]; then
474        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol}
475    else
476        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol 0
477    fi 
478
479    # config.def : Activate calcul of Cloud droplet number concentration if ok_cdnc=y
480    if [ ! X${lmdz_UserChoices_ok_cdnc} = X ]; then
481        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc}
482    else
483        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc n
484    fi 
485
486    # config.def : Activate COSP
487    if [ ! X${lmdz_UserChoices_LMDZ_COSP_OK} = X ]; then
488        IGCM_comp_modifyDefFile nonblocker config.def ok_cosp ${lmdz_UserChoices_LMDZ_COSP_OK}
489    else
490        IGCM_comp_modifyDefFile nonblocker config.def ok_cosp n
491    fi 
492
493    # config.def : Modify parameter pmagic if it is set in lmdz.card
494    if [ ! X${lmdz_UserChoices_pmagic} = X ]; then
495        IGCM_comp_modifyDefFile nonblocker config.def pmagic ${lmdz_UserChoices_pmagic}
496    else
497        # Take default value set in config.def
498        IGCM_comp_modifyDefFile nonblocker config.def pmagic DEFAULT
499    fi
500
501    if ( [ X${config_UserChoices_ConfigType} = XESMCO2 ] || [ X${config_UserChoices_ConfigType} = XESMCO2AER ] ) ; then
502        # Set carbon cycle parameters according to parmeters in lmdz.card
503        IGCM_comp_modifyDefFile blocker config.def level_coupling_esm 2
504        IGCM_comp_modifyDefFile blocker config.def carbon_cycle_cpl ${lmdz_UserChoices_carbon_cycle_cpl} 
505        IGCM_comp_modifyDefFile blocker config.def carbon_cycle_tr ${lmdz_UserChoices_carbon_cycle_tr}
506        IGCM_comp_modifyDefFile blocker config.def carbon_cycle_rad ${lmdz_UserChoices_carbon_cycle_rad}
507        IGCM_comp_modifyDefFile nonblocker config.def co2_ppm0 ${lmdz_UserChoices_co2_ppm0} 
508    else
509        # Take default value set in config.def
510        IGCM_comp_modifyDefFile nonblocker config.def level_coupling_esm DEFAULT
511        IGCM_comp_modifyDefFile nonblocker config.def carbon_cycle_cpl DEFAULT
512        IGCM_comp_modifyDefFile nonblocker config.def carbon_cycle_tr DEFAULT
513        IGCM_comp_modifyDefFile nonblocker config.def carbon_cycle_rad DEFAULT
514        IGCM_comp_modifyDefFile nonblocker config.def co2_ppm0 DEFAULT
515    fi
516
517    if ( [ X${config_UserChoices_ConfigType} = XESMCO2 ] ) ; then
518        # Set carbon cycle parameters according to parmeters in lmdz.card
519        IGCM_comp_modifyDefFile nonblocker config.def read_fco2_ocean_cor ${lmdz_UserChoices_read_fco2_ocean_cor}
520        IGCM_comp_modifyDefFile nonblocker config.def var_fco2_ocean_cor ${lmdz_UserChoices_var_fco2_ocean_cor}
521        IGCM_comp_modifyDefFile nonblocker config.def read_fco2_land_cor ${lmdz_UserChoices_read_fco2_land_cor}
522        IGCM_comp_modifyDefFile nonblocker config.def var_fco2_land_cor ${lmdz_UserChoices_var_fco2_land_cor}
523    else
524        IGCM_comp_modifyDefFile nonblocker config.def read_fco2_ocean_cor DEFAULT
525        IGCM_comp_modifyDefFile nonblocker config.def var_fco2_ocean_cor DEFAULT
526        IGCM_comp_modifyDefFile nonblocker config.def read_fco2_land_cor DEFAULT
527        IGCM_comp_modifyDefFile nonblocker config.def var_fco2_land_cor DEFAULT
528    fi
529
530    # config.def : Modify parameter ok_volcan if ok_volcan=y or LMDZ_strataero=y in lmdz.card
531    # Note: ok_volcan is a flag allowing a double-call with/without natural forcing (instead of with/without anthro forcing).
532    if [ ! X${lmdz_UserChoices_ok_volcan} = X ] || [ X${lmdz_UserChoices_LMDZ_strataero} = Xy ] ; then
533        IGCM_comp_modifyDefFile nonblocker config.def ok_volcan ${lmdz_UserChoices_ok_volcan}
534    else
535        # Take default value set in config.def
536        IGCM_comp_modifyDefFile nonblocker config.def ok_volcan DEFAULT
537    fi
538
539
540    # physiq.def : Modify parameter tau_gl if it is set in lmdz.card
541    if [ ! X${lmdz_UserChoices_tau_gl} = X ]; then
542        IGCM_comp_modifyDefFile nonblocker physiq.def tau_gl ${lmdz_UserChoices_tau_gl}
543    else
544        # Take default value set in physiq.def
545        IGCM_comp_modifyDefFile nonblocker physiq.def tau_gl DEFAULT
546    fi
547   
548
549    # guide.def : Activate nudging if ok_guide=y set in lmdz.card
550    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then
551        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide  ${lmdz_UserChoices_ok_guide}
552    else
553        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide n
554    fi
555
556
557    # Specific ByPass option only used with LMDZ dynamcis (without DYNMAICO)
558    if [ X${config_ListOfComponents_ICO} = X ] ; then
559
560        ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
561        ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta}
562        if [ X"${ByPass_hgardfou_teta}" = X"y" ] ; then
563            awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
564            IGCM_sys_Mv gcm.def.tmp gcm.def
565            echo
566            IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
567            echo
568            cat gcm.def
569            ByPass_hgardfou_teta=n
570        export lmdz_UserChoices_ByPass_hgardfou_teta=n
571            IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
572        fi
573       
574        ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
575        ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats}
576        if [ X"${ByPass_hgardfou_mats}" = X"y" ] ; then
577            sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
578            IGCM_sys_Mv gcm.def.tmp gcm.def
579            echo
580            IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
581            echo
582            cat gcm.def
583            ByPass_hgardfou_mats=n
584            export lmdz_UserChoices_ByPass_hgardfou_mats=n
585            IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
586        fi
587    fi
588
589
590    # Add include of LMDZ context in iodef.xml
591    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
592    echo '<context id="LMDZ" src="./context_lmdz.xml"/>' > add.tmp
593    # Add inclusion of file context_input_lmdz.xml if this file exists
594    if [ -f context_input_lmdz.xml ] ; then
595        echo '<context id="LMDZ" src="./context_input_lmdz.xml"/>' >> add.tmp
596    fi
597    # Include xml files for output configuration if running with workflow CMIP6
598    if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then
599        echo '<context id="LMDZ" src="./ping_lmdz.xml"/>' >> add.tmp
600        echo '<context id="LMDZ" src="./dr2xml_lmdz.xml"/>' >> add.tmp
601    fi
602    cp iodef.xml iodef.xml.tmp
603    sed -e "/COMPONENT CONTEXT/r add.tmp" iodef.xml.tmp > iodef.xml
604    rm iodef.xml.tmp add.tmp
605
606    #Long Name as global attribute (if LongName is not empty)
607    if [ ! "X${config_UserChoices_LongName}" = "X" ] ; then
608        listfile=$(ls file_def*lmdz.xml)
609        echo "<variable id=\"LongName\" type=\"string\">${config_UserChoices_LongName}</variable>" > add.tmp
610        for file in ${listfile}
611        do
612            cp ${file} ${file}.tmp
613            sed -e "/<file id/r add.tmp" \
614                ${file}.tmp > ${file}
615            rm ${file}.tmp
616        done
617        rm add.tmp
618    fi
619           
620
621    # Compression level (if CompressionLevel is not empty)
622    if [ ! "X${config_UserChoices_CompressionLevel}" = "X" ] ; then
623        echo "NetCDF output files compression level is " ${config_UserChoices_CompressionLevel}
624        listfile=$(ls file_def*lmdz.xml)
625        for file in ${listfile} ; do
626            sed -i -e "s/\(compression_level=\"\)[^\"]*\(\"\)/\1${config_UserChoices_CompressionLevel}\2/" ${file}
627        done
628    fi
629
630
631    # Set interpolated output grid depending on resoultion, only if ICO component is set in config.card
632    if [ ! "X${config_ListOfComponents_ICO}" = "X" ] ; then   
633        if [ ${RESOL_NBP} == 40  ] ; then
634            valuei=144
635            valuej=143
636        elif [ ${RESOL_NBP} == 60 ] ; then
637            valuei=270
638            valuej=135
639        elif [ ${RESOL_NBP} == 80  ] ; then
640            valuei=360
641            valuej=180
642        elif [ ${RESOL_NBP} == 160  ] ; then
643            valuei=720
644            valuej=360
645    elif [ ${RESOL_NBP} == 320  ] ; then
646        valuei=1440
647        valuej=720
648        else
649            IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers"
650            IGCM_debug_Verif_Exit
651        fi
652
653        IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_lmdz.xml"
654        cp context_lmdz.xml context_lmdz.xml.init
655        sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \
656            -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \
657            context_lmdz.xml.init > context_lmdz.xml
658    fi
659
660    # Set the appropriate monitoring file depending on grid and resolution if ICO component
661    if [ ${CumulPeriod} -eq 1 ] ; then
662       if [ X${config_ListOfComponents_ICO} = X ] ; then
663          IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_lmdz_REG.cfg  ${SUBMIT_DIR}/POST/monitoring01_lmdz.cfg
664       else
665          IGCM_sys_Cp ${SUBMIT_DIR}/POST/monitoring01_lmdz_ICO${RESOL_NBP}.cfg  ${SUBMIT_DIR}/POST/monitoring01_lmdz.cfg
666       fi
667    fi
668
669    IGCM_debug_PopStack "ATM_Update"
670}
671
672#-----------------------------------
673function ATM_Finalize
674{
675    IGCM_debug_PushStack "ATM_Finalize"
676
677    IGCM_debug_Print 1 "FINALIZE ATM !"
678
679    IGCM_debug_PopStack "ATM_Finalize"
680}
681
682
Note: See TracBrowser for help on using the repository browser.