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

Last change on this file since 6290 was 6290, checked in by aclsce, 19 months ago
  • Finalized merge in ICOLMDZOR configuration :
    • compilation : added rad option (with correct handling of svn test version)
    • experiments : merge with LMDZOR_v6.2 configuration, handling of remap frequency for ORCHIDEE xml file_def
    • cleaning and other small things
File size: 29.3 KB
RevLine 
[396]1#!/bin/ksh
2#-----------------------------------------------------------------
3function ATM_Initialize
4{
5    IGCM_debug_PushStack "ATM_Initialize"
6
7
[4281]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
[396]10
[4921]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       
[4281]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}"
[4921]27        RESOL_ATM=LMD${RESOL_ATM_X}${RESOL_ATM_Y}
28
29        IGCM_debug_Print 1 "The atomsopheric resolution is ${RESOL_ATM_3D} " 
[4281]30    else
31        RESOL_ATM_Z=${dynamico_UserChoices_RESOL_ATM_Z}
[4323]32        RESOL_NBP=${dynamico_UserChoices_RESOL_NBP}
[6100]33    RESOL_ATM="nbp${RESOL_NBP}"
[4281]34    fi
35
[1541]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
[1643]45    ##- Create_etat0_limit version
[1782]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
[1643]53
[1782]54
[1550]55    ## - LMDZ choice of config.def file
56    ##   ConfType must be set in lmdz.card
57    ConfType=${lmdz_UserChoices_ConfType}
[1541]58
[1550]59
[396]60    IGCM_debug_PopStack "ATM_Initialize"
61}
62
63#-----------------------------------------------------------------
64function ATM_Update
65{
66    IGCM_debug_PushStack "ATM_Update"
67
[1535]68    ##-- GHG forcing :
[2321]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
[2333]71
72    # Read value for solaire from file SOLARANDVOLCANOES.txt. If file not existing, take DEFAULT value from file.
[3127]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"
[1535]75    if [ -f SOLARANDVOLCANOES.txt ] ; then
[2333]76        value=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'`
77        if [ X"${value}" = X ] ; then
[2321]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
[1690]82    else
[2333]83        value=DEFAULT
[1535]84    fi
[2333]85    IGCM_comp_modifyDefFile nonblocker config.def solaire $value
[2321]86
[3771]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
[2333]99
[3771]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
[2333]126    # Read value for co2_ppm from file CO2.txt. If file not existing, take DEFAULT value from file.
[3568]127    # Calculate co2_ppm_per as co2_ppm*4.
[1535]128    if [ -f CO2.txt ] ; then
[2333]129        value=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
130        if [ X"${value}" = X ] ; then
[2321]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
[3568]135        value4=`grep Annee_${year} CO2.txt | awk -F= '{print $2 * 4}'`
[1690]136    else
[2333]137        value=DEFAULT
[3568]138        value4=DEFAULT
[1535]139    fi
[2333]140    IGCM_comp_modifyDefFile nonblocker config.def co2_ppm $value
[3568]141    IGCM_comp_modifyDefFile nonblocker config.def co2_ppm_per $value4
[1690]142
[2333]143
144    # Read value for CH4_ppb from file CH4.txt. If file not existing, take DEFAULT value from file.
[1535]145    if [ -f CH4.txt ] ; then
[2333]146        value=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'`
147        if [ X"${value}" = X ] ; then
[2321]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
[2333]152    else
153        value=DEFAULT
[1535]154    fi
[2333]155    IGCM_comp_modifyDefFile nonblocker config.def CH4_ppb $value
[2321]156
[2333]157
158    # Read value for N2O_ppb from file N2O.txt. If file not existing, take DEFAULT value from file.
[1535]159    if [ -f N2O.txt ] ; then
[2333]160        value=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'`
161        if [ X"${value}" = X ] ; then
[2321]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
[1690]166    else
[2333]167        value=DEFAULT
[1535]168    fi
[2333]169    IGCM_comp_modifyDefFile nonblocker config.def N2O_ppb $value
[2321]170
[2333]171    # Read value for CFC11_ppt from file CFC11.txt. If file not existing, take DEFAULT value from file.
[1535]172    if [ -f CFC11.txt ] ; then
[2333]173        value=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'`
174        if [ X"${value}" = X ] ; then
[2321]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
[1690]179    else
[2333]180        value=DEFAULT
[1535]181    fi
[2333]182    IGCM_comp_modifyDefFile nonblocker config.def CFC11_ppt $value
[2321]183
[2333]184
185    # Read value for CFC12_ppt from file CFC12.txt. If file not existing, take DEFAULT value from file.
[1535]186    if [ -f CFC12.txt ] ; then
[2333]187        value=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'`
188        if [ X"${value}" = X ] ; then
[2321]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
[1690]193    else
[2333]194        value=DEFAULT
[1535]195    fi
[2333]196    IGCM_comp_modifyDefFile nonblocker config.def CFC12_ppt $value
[1535]197
[1780]198
[2336]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}
[2332]201    IGCM_debug_Print 3 "LMDZ_t_coupl "   ${LMDZ_t_coupl}
[2333]202    IGCM_comp_modifyDefFile nonblocker config.def t_coupl   ${LMDZ_t_coupl} 
[2332]203
[1537]204
[4921]205    ## Activate diagnostic output files and set output_level for each file
[4336]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
[2600]211    else
[4336]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} 
[2600]214    fi
[4336]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} 
[2582]223    fi
[2605]224
[4336]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
[2600]233
[4336]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
[2332]242
[4336]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
[3104]247    else
[4336]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} 
[3104]250    fi
[396]251
[4336]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
[3104]260
[4336]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
[4604]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
[4336]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
[911]319    ## run.def parameters
[2598]320
321
322    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
[4281]323
[2598]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
[4281]331    #    calend is read from both LMDZ dynamics and physics parts of the model
[2598]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
[396]343
[4323]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}
[2480]348
[4366]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}
[4281]354       
[4366]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
[1804]358    else
[4323]359        # for case gcm : take first year of simulation
360        IGCM_comp_modifyDefFile blocker run.def anneeref ${InitYear}
[1804]361    fi
[4323]362   
[1643]363
[1650]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"
[2333]370        IGCM_comp_modifyDefFile blocker run.def VEGET y
[1650]371    else
372        echo "No ORCHIDEE, set VEGET=n in run.def"
[2333]373        IGCM_comp_modifyDefFile blocker run.def VEGET n
[1650]374    fi
375
376    if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then
377        echo "Activate coupling to ocean, set type_ocean=couple in run.def"
[2333]378        IGCM_comp_modifyDefFile blocker run.def type_ocean couple
[1650]379    else
380        echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def"
[3935]381        IGCM_comp_modifyDefFile nonblocker run.def type_ocean force
[1650]382    fi
383
[6290]384    if [ X${config_UserChoices_ConfigType} = XESMCO2AER ] ; then
385    echo "ESM config, with INCA and CO2i, set type_trac=inco in run.def"
386    IGCM_comp_modifyDefFile blocker run.def type_trac inco
387    IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1
388    elif [ X${config_ListOfComponents_CHM} = Xinca ] ; then
[1650]389        echo "Activate coupling to INCA, set type_trac=inca in run.def"
[2333]390        IGCM_comp_modifyDefFile blocker run.def type_trac inca
[6290]391        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1 
[1650]392    elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then
393        echo "Activate coupling to REPROBUS, set type_trac=repr in run.def"
[2333]394        IGCM_comp_modifyDefFile blocker run.def type_trac repr
395        IGCM_comp_modifyDefFile blocker run.def config_inca none
[6290]396        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1 
[4921]397    elif [ X${config_UserChoices_ConfigType} = XESMCO2 ] ; then
398        echo "ESM config, set type_trac=co2i in run.def"
399        IGCM_comp_modifyDefFile blocker run.def type_trac co2i
400        IGCM_comp_modifyDefFile blocker run.def config_inca none
[6290]401    IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1
[4921]402    elif [ X${lmdz_UserChoices_LMDZ_strataero} = Xy ] ; then
403        echo "No coupling to chemistry model but it is a LMDZ STRATAER configuration, set type_trac=coag in run.def"
404        IGCM_comp_modifyDefFile blocker run.def type_trac coag
405        IGCM_comp_modifyDefFile blocker run.def config_inca none
406        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 1 
[1650]407    else
408        echo "No coupling to chemistry model, set type_trac=lmdz in run.def"
[2333]409        IGCM_comp_modifyDefFile blocker run.def type_trac lmdz
410        IGCM_comp_modifyDefFile blocker run.def config_inca none
[4921]411        IGCM_comp_modifyDefFile blocker run.def iflag_phytrac 0
[1650]412    fi
413
[4921]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}
[4020]417    else
[4921]418        IGCM_comp_modifyDefFile nonblocker run.def cpl_old_calving y
[4020]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
[4921]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
[2015]435    # config.def : Activate direct radiative effect if ok_ade=y
436    if [ ! X${lmdz_UserChoices_ok_ade} = X ]; then
[2333]437        IGCM_comp_modifyDefFile nonblocker config.def ok_ade ${lmdz_UserChoices_ok_ade}
[2015]438    else
[2333]439        IGCM_comp_modifyDefFile nonblocker config.def ok_ade n
[2015]440    fi 
441
442    # config.def : Activate indirect radiative effect if ok_aie=y
443    if [ ! X${lmdz_UserChoices_ok_aie} = X ]; then
[2333]444        IGCM_comp_modifyDefFile nonblocker config.def ok_aie ${lmdz_UserChoices_ok_aie}
[2015]445    else
[2333]446        IGCM_comp_modifyDefFile nonblocker config.def ok_aie n
[2015]447    fi 
[1816]448
[2015]449    # config.def : Activate online aerosol coupled model if aerosol_couple=y
450    if [ ! X${lmdz_UserChoices_aerosol_couple} = X ]; then
[2333]451        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple ${lmdz_UserChoices_aerosol_couple}
[1686]452    else
[2333]453        IGCM_comp_modifyDefFile nonblocker config.def aerosol_couple n
[2015]454    fi 
[1686]455
[4020]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
[2015]463    # config.def : Activate reading of ozone in climatology if read_climoz=2
464    if [ ! X${lmdz_UserChoices_read_climoz} = X ]; then
[2333]465        IGCM_comp_modifyDefFile nonblocker config.def read_climoz ${lmdz_UserChoices_read_climoz}
[2015]466    else
[2333]467        IGCM_comp_modifyDefFile nonblocker config.def read_climoz 0     
[2015]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
[2333]474        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol ${lmdz_UserChoices_flag_aerosol}
[2015]475    else
[2333]476        IGCM_comp_modifyDefFile nonblocker config.def flag_aerosol 0
[2015]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
[2333]481        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc ${lmdz_UserChoices_ok_cdnc}
[2015]482    else
[2333]483        IGCM_comp_modifyDefFile nonblocker config.def ok_cdnc n
[2015]484    fi 
485
[2893]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
[2911]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
[2893]500
[6290]501    if ( [ X${config_UserChoices_ConfigType} = XESMCO2 ] || [ X${config_UserChoices_ConfigType} = XESMCO2AER ] ) ; then
[4921]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}
[6290]507        IGCM_comp_modifyDefFile nonblocker config.def co2_ppm0 ${lmdz_UserChoices_co2_ppm0} 
[4921]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
[6290]514        IGCM_comp_modifyDefFile nonblocker config.def co2_ppm0 DEFAULT
[4921]515    fi
516
[6290]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
[4921]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
[3868]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
[4038]545        IGCM_comp_modifyDefFile nonblocker physiq.def tau_gl DEFAULT
[3868]546    fi
547   
548
[1690]549    # guide.def : Activate nudging if ok_guide=y set in lmdz.card
[1643]550    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then
[2333]551        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide  ${lmdz_UserChoices_ok_guide}
[1690]552    else
[2333]553        IGCM_comp_modifyDefFile nonblocker guide.def ok_guide n
[1643]554    fi
555
[3868]556
[4281]557    # Specific ByPass option only used with LMDZ dynamcis (without DYNMAICO)
558    if [ X${config_ListOfComponents_ICO} = X ] ; then
[396]559
[4281]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
[6014]570        export lmdz_UserChoices_ByPass_hgardfou_teta=n
[4281]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
[6014]584            export lmdz_UserChoices_ByPass_hgardfou_mats=n
[4281]585            IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
586        fi
[396]587    fi
588
[4281]589
[2904]590    # Add include of LMDZ context in iodef.xml
[4108]591    # In iodef.xml add on the next line after "COMPONENT CONTEXT"
[2904]592    echo '<context id="LMDZ" src="./context_lmdz.xml"/>' > add.tmp
[4108]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
[6290]598    if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] || [ X${config_Post_dr2xmlIPSL} = XTRUE ] ) ; then
[3505]599        echo '<context id="LMDZ" src="./ping_lmdz.xml"/>' >> add.tmp
600        echo '<context id="LMDZ" src="./dr2xml_lmdz.xml"/>' >> add.tmp
601    fi
[2904]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
[2476]605
[2904]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
[2332]618    fi
[2904]619           
[4357]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
[4379]630
[4921]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} == 80  ] ; then
637            valuei=360
638            valuej=180
639        elif [ ${RESOL_NBP} == 160  ] ; then
640            valuei=720
641            valuej=360
[5537]642    elif [ ${RESOL_NBP} == 320  ] ; then
643        valuei=1440
644        valuej=720
[4921]645        else
646            IGCM_debug_Exit "RESOL_NBP=${RESOL_NBP} is not yet implemented in drivers"
647            IGCM_debug_Verif_Exit
648        fi
649
650        IGCM_debug_Print 1 "Modify output grid parameters for current resolution in context_lmdz.xml"
651        cp context_lmdz.xml context_lmdz.xml.init
652        sed -e "s/ni_glo.*=.*\"144\"/ni_glo=\"${valuei}\"/" \
653            -e "s/nj_glo.*=.*\"143\"/nj_glo=\"${valuej}\"/" \
654            context_lmdz.xml.init > context_lmdz.xml
[4379]655    fi
656
657
[396]658    IGCM_debug_PopStack "ATM_Update"
659}
660
661#-----------------------------------
662function ATM_Finalize
663{
664    IGCM_debug_PushStack "ATM_Finalize"
665
[4921]666    IGCM_debug_Print 1 "FINALIZE ATM !"
667
[1780]668    IGCM_debug_PopStack "ATM_Finalize"
669}
[1537]670
671
Note: See TracBrowser for help on using the repository browser.