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

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