source: CONFIG/UNIFORM/u1/LMDZOR_u1/GENERAL/DRIVER/lmdz.driver @ 1688

Last change on this file since 1688 was 1688, checked in by jgipsl, 12 years ago
  • Removed IGCM_card_DefineVariableFromOption : not necessary for UserChoices? section
  • Add test if Bands_file_name exist in lmdz.card and copy it only if it exists
File size: 19.1 KB
Line 
1#!/bin/ksh
2#-----------------------------------------------------------------
3function LMDZ_sed
4{
5    IGCM_debug_PushStack "LMDZ_sed"
6
7    sed -e "s/^${2}\ *=.*/${2}= ${3}/" ${1} > ${1}.tmp
8    RET=$?
9    echo "LMDZ_sed : ${1} ${2} ${3}"
10    \mv ${1}.tmp ${1}
11
12    IGCM_debug_PopStack "LMDZ_sed"
13    return $RET
14}
15
16function ATM_Initialize
17{
18    IGCM_debug_PushStack "ATM_Initialize"
19
20    RESOL_ATM=$( echo $RESOL | awk "-Fx" '{print $2}' | awk "-F-" '{print $1}')
21
22    [ -f ${SUBMIT_DIR}/../.resol ] && eval $(grep RESOL_ATM_3D ${SUBMIT_DIR}/../.resol) || RESOL_ATM_3D=96x95x19
23
24    RESOL_ATM_Z=$( echo ${RESOL_ATM_3D} | awk "-Fx" '{print $3}' )
25
26    ##-- Calendar type for LMDZ
27    case ${config_UserChoices_CalendarType} in
28        leap|gregorian)
29            CalendarTypeForLmdz=earth_366d;;
30        noleap)
31            CalendarTypeForLmdz=earth_365d;;
32        360d)
33            CalendarTypeForLmdz=earth_360d;;
34        *)
35            CalendarTypeForLmdz=earth_360d
36    esac
37
38    ##- LMDZ physics version
39    ##  Read LMDZ_Physics option in lmdz.card, if not present take default value AP (old physics)
40    if [ ! X${lmdz_UserChoices_LMDZ_Physics} = X ] ; then
41        LMDZ_Physics=${lmdz_UserChoices_LMDZ_Physics}
42    else
43        LMDZ_Physics=AP
44    fi
45    echo LMDZ physics version : ${LMDZ_Physics}
46
47    ##- Create_etat0_limit version
48    CREATE=${lmdz_UserChoices_CREATE}
49    echo create_etat0_limit version : ${CREATE}
50
51    ## - LMDZ choice of config.def file
52    ##   ConfType must be set in lmdz.card
53    ConfType=${lmdz_UserChoices_ConfType}
54
55    ##- LMDZ output level, to be set in lmdz.card
56    if [ X${lmdz_UserChoices_OutLevel} = X ] ; then
57        # OutLevel is not set. Take default value low.
58        OutLevel=low
59    else
60        OutLevel=${lmdz_UserChoices_OutLevel}
61    fi
62
63    ##-- Output frequency purpose ....
64    ##--  Initialisation  ....
65    ok_mensuel=n
66    ok_journe=n
67    ok_hf=n
68    ok_hf3h=n
69    ok_hf3hm=n
70    ok_stn=n
71
72    case ${config_UserChoices_PeriodLength} in
73        1Y|1y|1M|1m) ok_mensuel=y ;;
74        5D|5d|1D|1d) ok_journe=y ;;
75    esac
76
77    for frequency in ${config_ATM_WriteFrequency} ; do
78        case ${frequency} in
79            1M|1m) ok_mensuel=y ;;
80        esac
81        case ${frequency} in
82            5D|5d|1D|1d) ok_journe=y ;;
83        esac
84        case ${frequency} in
85            HF|hf) ok_hf=y ;;
86        esac
87        case ${frequency} in
88            HF3h|hf3h) ok_hf3h=y ;;
89        esac
90        case ${frequency} in
91            HF3hm|hf3hm) ok_hf3hm=y ;;
92        esac
93        case ${frequency} in
94            STN|stn) ok_stn=y ;;
95        esac
96    done
97
98    ## Read LMDZ_NbPeriod_adjust option in lmdz.card
99    if [ X"${lmdz_UserChoices_LMDZ_NbPeriod_adjust}" = X"" ] ; then
100        # The variable is not in lmdz.card, set default value
101        LMDZ_NbPeriod_adjust=0
102    else       
103        LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust}
104    fi
105
106    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
107        LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name}
108    fi
109
110    ##  Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card
111    LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero}
112    LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero}
113
114    ##  Read LMDZ_COSP_monthly  LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card
115    LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK}
116    LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly}
117    LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily}
118    LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf}
119
120    ##  Read LMDZ_NMC_monthly  LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card
121    LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly}
122    LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily}
123    LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf}
124
125    IGCM_debug_PopStack "ATM_Initialize"
126}
127
128#-----------------------------------------------------------------
129function ATM_Update
130{
131    IGCM_debug_PushStack "ATM_Update"
132
133
134    case ${config_UserChoices_PeriodLength} in
135        *Y|*y) 
136               LMDZ_ecrit_ISCCP=30.
137               LMDZ_periodav=30.
138               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
139                  echo Do not consider following warning if your running create_etat0_limit :
140                  echo WARNING !!! For lmdz : calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
141               fi
142               ;;
143        *)
144               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
145               LMDZ_periodav=${PeriodLengthInDays}.
146               ;;
147    esac
148 
149    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
150    if [ ${CumulPeriod} -eq 1 ] ; then
151        RAZ_DATE=1
152    else
153        RAZ_DATE=0
154    fi
155
156    ## algo : For CumulPeriod=1 ;
157    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
158    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
159    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
160    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
161
162    if [ ${CumulPeriod} -eq 1 ] ; then
163        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
164            if [ ! X${LMDZ_Bands_file_name} = X] ; then
165                IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
166                IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0
167                IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
168                IGCM_debug_Print 1 "Bands file forced to ${LMDZ_Bands_file_name} and stored in ${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_0"
169            fi
170        fi
171    fi
172
173    LMDZ_adjust=n
174    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
175
176    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
177    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
178
179    [ ${CumulPeriod} -gt 1 ] && ( IGCM_sys_Get ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${RefPeriod} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ; IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat )
180
181    ##-- GHG forcing :
182    ##   If forcing file exist in run directory, read values for the current year and modify config.def
183    if [ -f SOLARANDVOLCANOES.txt ] ; then
184        IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'`
185        LMDZ_sed config.def solaire     ${IPCC_SOLAR}
186    fi
187    if [ -f CO2.txt ] ; then
188        IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
189        LMDZ_sed config.def co2_ppm     ${IPCC_CO2}
190    fi
191    if [ -f CH4.txt ] ; then
192        IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'`
193        LMDZ_sed config.def CH4_ppb     ${IPCC_CH4}
194    fi
195    if [ -f N2O.txt ] ; then
196        IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'`
197        LMDZ_sed config.def N2O_ppb     ${IPCC_N2O}
198    fi
199    if [ -f CFC11.txt ] ; then
200        IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'`
201        LMDZ_sed config.def CFC11_ppt   ${IPCC_CFC11}
202    fi
203    if [ -f CFC12.txt ] ; then
204        IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'`
205        LMDZ_sed config.def CFC12_ppt   ${IPCC_CFC12}
206    fi
207
208    # Add special treatement for CARBON CYCLE
209    if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then
210
211        typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2
212        typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff
213        typeset PathCO2log
214        typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX
215
216        if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then
217        ##--Initialization of fluxes to an undefined value at the first run
218            UndefinedValueCo2=-9999
219            InitPeriodCo2=0
220            InitDateBeginCo2=${UndefinedValueCo2}
221            InitYearCo2=$(( ${year} - 1 )) 
222            InitDateEndCo2=${InitYearCo2}1231
223            fCO2_ff=${UndefinedValueCo2} 
224            CO2SBG=${UndefinedValueCo2}
225            CO2LU=${UndefinedValueCo2}
226            CO2MBG=${UndefinedValueCo2}
227            CO2_ppm_prec=${UndefinedValueCo2}
228        # Get the initial value of atmosp. pco2
229            CO2_ppm=${lmdz_UserChoices_co2_init}
230           
231            IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log
232            IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log
233           
234        # Save CO2 values in ExeCpuLog variable contents 5 fields
235            echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \
236                gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
237                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
238           
239        # Get the path where the log file co2.log is
240            PathCO2log=${SUBMIT_DIR} 
241        # Get Previous line in co2.log
242            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
243           
244        else
245           
246        # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ):
247        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2.
248        #SubmitRestartPath=
249            if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then
250                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath
251                PathCO2log=${config_ATM_SubmitRestartPath}
252                Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} )
253                PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log )
254               
255                IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log
256                IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log
257               
258            # Save Last Line of control in new co2.log file
259                InitPeriodCo2=0   
260                InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' )
261                InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' )
262                fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' )
263                CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' )
264                CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' )
265                CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' )
266                CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' )
267                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
268               
269                echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \
270                    gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
271                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
272            else
273           # Get restart line in co2.log
274                PathCO2log=${SUBMIT_DIR}
275                PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
276           # Get the value of atmosp. pco2 in co2.log
277                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
278            fi
279           
280        fi
281
282        if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then
283            # Modify co2_ppm in config.def only for historical run
284            LMDZ_sed config.def co2_ppm     ${CO2_ppm}
285        fi
286    fi
287    # end CARBON_CYCLE
288
289    ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate
290    ##   COSP daily output for years 1979 and later (mandatory for historical CMIP5 run).
291    if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] &&  [ ${year} -ge 1979 ]) ; then
292        LMDZ_COSP_daily=y
293    fi
294
295
296    ## output.def parameters
297    #  columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def : 
298    #                                            histmth       histday        histhf    histfh3h   histhf3hm   histstn
299    LMDZ_sed output.def phys_out_filekeys       "${ok_mensuel} ${ok_journe}   ${ok_hf}  ${ok_hf3h} ${ok_hf3hm} ${ok_stn}"
300    LMDZ_sed output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
301    LMDZ_sed output.def ok_cosp     ${LMDZ_COSP_OK}
302    LMDZ_sed output.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
303    LMDZ_sed output.def ok_journeCOSP   ${LMDZ_COSP_daily}
304    LMDZ_sed output.def ok_hfCOSP   ${LMDZ_COSP_hf}
305    LMDZ_sed output.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}"
306
307    ## gcm.def parameters :
308    # Modification only for new physics
309    if [ X${LMDZ_Physics} = X"NPv3.0" ] ; then
310        LMDZ_sed gcm.def iphysiq     5
311    fi
312
313
314    ## run.def parameters
315    LMDZ_sed run.def dayref   ${InitDay}
316    LMDZ_sed run.def anneeref ${InitYear}
317    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
318    LMDZ_sed run.def nday     ${PeriodLengthInDays}
319    LMDZ_sed run.def raz_date ${RAZ_DATE}
320    LMDZ_sed run.def periodav ${LMDZ_periodav}
321    LMDZ_sed run.def adjust   ${LMDZ_adjust}
322
323
324    ## Determine from the variable ListOfComponents in config.card coupling to external models
325    ## and set corresponding parameters in run.def
326    echo ListOfComponents now running : ${config_ListOfComponents[*]}
327
328    if [ X${config_ListOfComponents_SRF} = Xorchidee ] ; then
329        echo "Activate ORCHIDEE, set VEGET=y in run.def"
330        LMDZ_sed run.def VEGET y
331    else
332        echo "No ORCHIDEE, set VEGET=n in run.def"
333        LMDZ_sed run.def VEGET n
334    fi
335
336    if [ X${config_ListOfComponents_CPL} = Xoasis ] ; then
337        echo "Activate coupling to ocean, set type_ocean=couple in run.def"
338        LMDZ_sed run.def type_ocean couple
339    else
340        echo "LMDZ is running in forced mode without ocean model, set type_ocean=force in run.def"
341        LMDZ_sed run.def type_ocean force
342    fi
343
344    if [ X${config_ListOfComponents_CHM} = Xinca ] ; then
345        echo "Activate coupling to INCA, set type_trac=inca in run.def"
346        LMDZ_sed run.def type_trac inca
347    elif [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then
348        echo "Activate coupling to REPROBUS, set type_trac=repr in run.def"
349        LMDZ_sed run.def type_trac repr
350    else
351        echo "No coupling to chemistry model, set type_trac=lmdz in run.def"
352        LMDZ_sed run.def type_trac lmdz
353    fi
354
355
356    # config.def : If running with Reprobus, desactivate ok_ade, ok_aie and read_climoz
357    if [ X${config_ListOfComponents_CHM} = Xreprobus ] ; then
358        LMDZ_sed config.def ok_ade n
359        LMDZ_sed config.def ok_aie n
360        LMDZ_sed config.def read_climoz 0
361    else
362        LMDZ_sed config.def ok_ade y
363        LMDZ_sed config.def ok_aie y
364        LMDZ_sed config.def read_climoz 2
365    fi
366
367    # guide.def : Activate nudging if ok_guide set in lmdz.card
368    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then
369        LMDZ_sed guide.def ok_guide  ${lmdz_UserChoices_ok_guide}
370    fi
371
372    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
373    ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta}
374    if [ X"${ByPass_hgardfou_teta}" = X"y" ] ; then
375        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
376        IGCM_sys_Mv gcm.def.tmp gcm.def
377        echo
378        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
379        echo
380        cat gcm.def
381        ByPass_hgardfou_teta=n
382        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
383    fi
384
385    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
386    ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats}
387    if [ X"${ByPass_hgardfou_mats}" = X"y" ] ; then
388        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
389        IGCM_sys_Mv gcm.def.tmp gcm.def
390        echo
391        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
392        echo
393        cat gcm.def
394        ByPass_hgardfou_mats=n
395        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
396    fi
397
398    if ( ${FirstInitialize} ) ; then
399        if [ -f start.nc ] && [ -f startphy.nc ] ; then
400            # The restart files already exist. They have been copied from a previous run or from a CREATE job
401            echo "Restart files for LMDZ have been copied from a previous run"
402        elif [ -f create_etat0_limit* ] || [ -f ce0l* ] && ! [ -f lmdz.x ] ; then
403            # Do nothing because it is the program for creating restart files that is running and not LMDZ
404            echo "create_etat0_limit.e will create initial start files"
405        else
406            # Restart files have to be created
407            echo "Run create_etat0_limit.e to create restart files start.nc and startphy.nc for LMDZ"
408            if [ ${DRYRUN} -le 2 ] ; then
409                ##-- suppression of ozone file construction --
410                cp config.def config.def.save
411                LMDZ_sed config.def read_climoz 0
412                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
413                if [ ${DRYRUN} -le 1 ] ; then
414                    ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e
415                    IGCM_sys_Put_Out start.nc    ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc
416                    IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc
417                fi
418                IGCM_sys_Mv config.def.save config.def
419            else
420                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated"
421                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
422            fi
423        fi
424    fi
425
426    IGCM_debug_PopStack "ATM_Update"
427}
428
429#-----------------------------------
430function ATM_Finalize
431{
432    IGCM_debug_PushStack "ATM_Finalize"
433
434    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && IGCM_sys_Put_Out Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat ${R_OUT_ATM_D}/${config_UserChoices_JobName}_Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat_${CumulPeriod}
435
436
437    # Add special treatement for CARBON CYCLE
438    if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then
439        typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff
440
441        # Fossil fuel emission
442        if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then
443            # For Control, no fossil fuel emission :
444            fCO2_ff=0
445            echo "Fossil Fuel for control run  :" ${fCO2_ff}
446        else
447            # For historical, get the fossile fuel file :
448            fCO2_ff=$( gawk "{if (match(\$0,\"${year}\ *${month}\")) {print \$3}}" ${SUBMIT_DIR}/PARAM/CMIP5_gridcar_CO2_emissions_fossil_fuel_Andres_1751-2007_monthly_SC.txt )
449            echo "Fossil Fuel for historical run  :" ${fCO2_ff}
450        fi
451
452        # Get the value of ocean carbon flux
453        CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output )
454        CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" )
455        echo "Ocean carbon flux  :" ${CO2MBG}
456
457        # Get the value of land fluxes
458        set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 )
459        CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" )
460        CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" )
461        CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" )
462        echo "Land carbon flux (NEP)         :" ${CO2SRF}
463        echo "LU flux          (FLUC)        :" ${CO2LU}
464        echo "Total Land carbon flux (NBP)   :" ${CO2SBG}
465
466        # Previous CO2
467        CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
468        echo "Previous CO2  :" ${CO2_ppm_prec}
469
470        # Formula
471        CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l )
472        echo "New CO2  :" ${CO2_ppm}
473
474        # Save CO2 values in ExeCpuLog variable contents 5 fields
475        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \
476            gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
477                           $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
478
479    fi
480
481    echo FINALIZE ATM !
482
483    IGCM_debug_PopStack "ATM_Finalize"
484}
Note: See TracBrowser for help on using the repository browser.