source: CONFIG/IPSLCM/IPSLCM5_v4/GENERAL/DRIVER/lmdz.driver @ 1643

Last change on this file since 1643 was 1643, checked in by jgipsl, 13 years ago
  • Added all cards needed to run a forced LMDZOR amip experience in IPSLCM5_v4 configuration.
  • Added file guide.def. By defalut ok_guide=n, no nudging. To activate nudging, set ok_guide=y in lmdz.card
  • in lmdz.driver, changed test to know if create_etat0_limit execution is needed
File size: 17.6 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    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_NbPeriod_adjust
101    LMDZ_NbPeriod_adjust=${lmdz_UserChoices_LMDZ_NbPeriod_adjust}
102
103    if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
104        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices LMDZ_Bands_file_name
105        LMDZ_Bands_file_name=${lmdz_UserChoices_LMDZ_Bands_file_name}
106    fi
107
108    ##  Read LMDZ_Freq_aero and LMDZ_Length_aero in lmdz.card
109    LMDZ_Freq_aero=${lmdz_UserChoices_LMDZ_Freq_aero}
110    LMDZ_Length_aero=${lmdz_UserChoices_LMDZ_Length_aero}
111
112    ##  Read LMDZ_COSP_monthly  LMDZ_COSP_daily and LMDZ_COSP_hf in lmdz.card
113    LMDZ_COSP_OK=${lmdz_UserChoices_LMDZ_COSP_OK}
114    LMDZ_COSP_monthly=${lmdz_UserChoices_LMDZ_COSP_monthly}
115    LMDZ_COSP_daily=${lmdz_UserChoices_LMDZ_COSP_daily}
116    LMDZ_COSP_hf=${lmdz_UserChoices_LMDZ_COSP_hf}
117
118    ##  Read LMDZ_NMC_monthly  LMDZ_NMC_daily and LMDZ_NMC_hf in lmdz.card
119    LMDZ_NMC_monthly=${lmdz_UserChoices_LMDZ_NMC_monthly}
120    LMDZ_NMC_daily=${lmdz_UserChoices_LMDZ_NMC_daily}
121    LMDZ_NMC_hf=${lmdz_UserChoices_LMDZ_NMC_hf}
122
123    IGCM_debug_PopStack "ATM_Initialize"
124}
125
126#-----------------------------------------------------------------
127function ATM_Update
128{
129    IGCM_debug_PushStack "ATM_Update"
130
131
132    case ${config_UserChoices_PeriodLength} in
133        *Y|*y) 
134               LMDZ_ecrit_ISCCP=30.
135               LMDZ_periodav=30.
136               if [ "${config_UserChoices_CalendarType}" != "360d" ] ; then
137                  echo Change calendartype in config.card. PeriodLength=1Y allowed only for CalendarType=360d
138                  exit
139               fi
140               ;;
141        *)
142               LMDZ_ecrit_ISCCP=${PeriodLengthInDays}.
143               LMDZ_periodav=${PeriodLengthInDays}.
144               ;;
145    esac
146 
147    ##-- Remise ou non a zero de la date initiale de LMDZ pour le fichier run.def
148    if [ ${CumulPeriod} -eq 1 ] ; then
149        RAZ_DATE=1
150    else
151        RAZ_DATE=0
152    fi
153
154    ## algo : For CumulPeriod=1 ;
155    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix
156    ##        ELSE LMDZ_adjust=y ; save Bands file on file server ;
157    ##        For CumulPeriod=2 to LMDZ_NbPeriod_adjust ; Get Bands file from server (CumulPeriod-1) ; LMDZ_adjust=y ; save Bands file on file server ;
158    ##        For CumulPeriod > LMDZ_NbPeriod_adjust ; LMDZ_adjust=n ; Get Bands file from server (CumulPeriod=LMDZ_NbPeriod_adjust 0 to force it) ; Use Bands ;
159
160    if [ ${CumulPeriod} -eq 1 ] ; then
161        if [ ${LMDZ_NbPeriod_adjust} -eq 0 ] ; then
162            IGCM_sys_Get ${LMDZ_Bands_file_name} Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
163            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
164            IGCM_sys_Chmod u+w Bands_${RESOL_ATM_3D}_${NUM_PROC_ATM}prc.dat
165            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"
166        fi
167    fi
168
169    LMDZ_adjust=n
170    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && LMDZ_adjust=y
171
172    RefPeriod=${LMDZ_NbPeriod_adjust} #0 to use a Bands file from Restart
173    [ ${CumulPeriod} -le ${LMDZ_NbPeriod_adjust} ] && (( RefPeriod = ${CumulPeriod} - 1 )) 
174
175    [ ${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 )
176
177    ##-- GHG forcing :
178    ##   If forcing file exist in run directory, read values for the current year and modify config.def
179    if [ -f SOLARANDVOLCANOES.txt ] ; then
180        IPCC_SOLAR=`grep Annee_${year} SOLARANDVOLCANOES.txt | awk -F= '{print $2}'`
181        LMDZ_sed config.def solaire     ${IPCC_SOLAR}
182    fi
183    if [ -f CO2.txt ] ; then
184        IPCC_CO2=`grep Annee_${year} CO2.txt | awk -F= '{print $2}'`
185        LMDZ_sed config.def co2_ppm     ${IPCC_CO2}
186    fi
187    if [ -f CH4.txt ] ; then
188        IPCC_CH4=`grep Annee_${year} CH4.txt | awk -F= '{print $2}'`
189        LMDZ_sed config.def CH4_ppb     ${IPCC_CH4}
190    fi
191    if [ -f N2O.txt ] ; then
192        IPCC_N2O=`grep Annee_${year} N2O.txt | awk -F= '{print $2}'`
193        LMDZ_sed config.def N2O_ppb     ${IPCC_N2O}
194    fi
195    if [ -f CFC11.txt ] ; then
196        IPCC_CFC11=`grep Annee_${year} CFC11.txt | awk -F= '{print $2}'`
197        LMDZ_sed config.def CFC11_ppt   ${IPCC_CFC11}
198    fi
199    if [ -f CFC12.txt ] ; then
200        IPCC_CFC12=`grep Annee_${year} CFC12.txt | awk -F= '{print $2}'`
201        LMDZ_sed config.def CFC12_ppt   ${IPCC_CFC12}
202    fi
203
204    # Add special treatement for CARBON CYCLE
205    if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then
206
207        typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2
208        typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff
209        typeset PathCO2log
210        typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX
211
212        if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then
213        ##--Initialization of fluxes to an undefined value at the first run
214            UndefinedValueCo2=-9999
215            InitPeriodCo2=0
216            InitDateBeginCo2=${UndefinedValueCo2}
217            InitYearCo2=$(( ${year} - 1 )) 
218            InitDateEndCo2=${InitYearCo2}1231
219            fCO2_ff=${UndefinedValueCo2} 
220            CO2SBG=${UndefinedValueCo2}
221            CO2LU=${UndefinedValueCo2}
222            CO2MBG=${UndefinedValueCo2}
223            CO2_ppm_prec=${UndefinedValueCo2}
224        # Get the initial value of atmosp. pco2
225            CO2_ppm=${lmdz_UserChoices_co2_init}
226           
227            IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log
228            IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log
229           
230        # Save CO2 values in ExeCpuLog variable contents 5 fields
231            echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \
232                gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
233                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
234           
235        # Get the path where the log file co2.log is
236            PathCO2log=${SUBMIT_DIR} 
237        # Get Previous line in co2.log
238            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
239           
240        else
241           
242        # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ):
243        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2.
244        #SubmitRestartPath=
245            if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then
246                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath
247                PathCO2log=${config_ATM_SubmitRestartPath}
248                Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} )
249                PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log )
250               
251                IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log
252                IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log
253               
254            # Save Last Line of control in new co2.log file
255                InitPeriodCo2=0   
256                InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' )
257                InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' )
258                fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' )
259                CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' )
260                CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' )
261                CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' )
262                CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' )
263                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
264               
265                echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \
266                    gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
267                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
268            else
269           # Get restart line in co2.log
270                PathCO2log=${SUBMIT_DIR}
271                PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )
272           # Get the value of atmosp. pco2 in co2.log
273                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
274            fi
275           
276        fi
277
278        if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then
279            # Modify co2_ppm in config.def only for historical run
280            LMDZ_sed config.def co2_ppm     ${CO2_ppm}
281        fi
282    fi
283    # end CARBON_CYCLE
284
285    ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate
286    ##   COSP daily output for years 1979 and later (mandatory for historical CMIP5 run).
287    if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] &&  [ ${year} -ge 1979 ]) ; then
288        LMDZ_COSP_daily=y
289    fi
290
291
292    ## output.def parameters
293    #  columns in phys_output_filekeys refer to the filenames given in phys_out_filenames in output.def : 
294    #                                            histmth       histday        histhf    histfh3h   histhf3hm   histstn
295    LMDZ_sed output.def phys_out_filekeys       "${ok_mensuel} ${ok_journe}   ${ok_hf}  ${ok_hf3h} ${ok_hf3hm} ${ok_stn}"
296    LMDZ_sed output.def ecrit_ISCCP ${LMDZ_ecrit_ISCCP}
297    LMDZ_sed output.def ok_cosp     ${LMDZ_COSP_OK}
298    LMDZ_sed output.def ok_mensuelCOSP  ${LMDZ_COSP_monthly}
299    LMDZ_sed output.def ok_journeCOSP   ${LMDZ_COSP_daily}
300    LMDZ_sed output.def ok_hfCOSP   ${LMDZ_COSP_hf}
301    LMDZ_sed output.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}"
302
303    ## gcm.def parameters :
304    # Modification only for new physics
305    if [ X${LMDZ_Physics} = X"NPv3.0" ] ; then
306        LMDZ_sed gcm.def iphysiq     5
307    fi
308
309
310    ## run.def parameters
311    LMDZ_sed run.def dayref   ${InitDay}
312    LMDZ_sed run.def anneeref ${InitYear}
313    LMDZ_sed run.def calend   ${CalendarTypeForLmdz}
314    LMDZ_sed run.def nday     ${PeriodLengthInDays}
315    LMDZ_sed run.def raz_date ${RAZ_DATE}
316    LMDZ_sed run.def periodav ${LMDZ_periodav}
317    LMDZ_sed run.def adjust   ${LMDZ_adjust}
318
319
320    # guide.def : Activate nudging if ok_guide set in lmdz.card
321    if [ ! X${lmdz_UserChoices_ok_guide} = X ] ; then
322        LMDZ_sed guide.def ok_guide  ${lmdz_UserChoices_ok_guide}
323    fi
324
325    ## Read ByPass_hgardfou_teta option in lmdz.card --> divide teta* by 2 if [ $ByPass_hgardfou_teta = 1 ]
326    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta
327    ByPass_hgardfou_teta=${lmdz_UserChoices_ByPass_hgardfou_teta}
328    if [ ${ByPass_hgardfou_teta} = y ] ; then
329        awk '{ if ($0 ~ /^teta.*=/) {split($0,a,"=") ; print a[1]"="a[2]/2"."} else print $0}' gcm.def > gcm.def.tmp
330        IGCM_sys_Mv gcm.def.tmp gcm.def
331        echo
332        IGCM_debug_Print 1 "ByPass_hgardfou_teta : ^teta*/2 in gcm.def"
333        echo
334        cat gcm.def
335        ByPass_hgardfou_teta=n
336        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_teta "${ByPass_hgardfou_teta}"
337    fi
338
339    ## Read ByPass_hgardfou_mats option in lmdz.card --> purmats=y 2 if [ $ByPass_hgardfou_mats = 1 ]
340    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats
341    ByPass_hgardfou_mats=${lmdz_UserChoices_ByPass_hgardfou_mats}
342    if [ ${ByPass_hgardfou_mats} = y ] ; then
343        sed -e "s/^purmats=.*/purmats=y/" gcm.def > gcm.def.tmp
344        IGCM_sys_Mv gcm.def.tmp gcm.def
345        echo
346        IGCM_debug_Print 1 "ByPass_hgardfou_mats : purmats=y in gcm.def"
347        echo
348        cat gcm.def
349        ByPass_hgardfou_mats=n
350        IGCM_card_WriteOption ${SUBMIT_DIR}/COMP/lmdz.card UserChoices ByPass_hgardfou_mats "${ByPass_hgardfou_mats}"
351    fi
352
353    if ( ${FirstInitialize} ) ; then
354        if [ -f start.nc ] && [ -f startphy.nc ] ; then
355            # The restart files already exist. They have been copied from a previous run or from a CREATE job
356            echo "Restart files for LMDZ have been copied from a previous run"
357        else
358            # Restart files have to be created
359            echo "Run create_etat0_limit.e to create restart files start.nc and startphy.nc for LMDZ"
360            if [ ${DRYRUN} -le 2 ] ; then
361                ##-- suppression of ozone file construction --
362                cp config.def config.def.save
363                LMDZ_sed config.def read_climoz 0
364                IGCM_sys_Cp ${R_EXE}/create_etat0_limit.e ${RUN_DIR}/.
365                if [ ${DRYRUN} -le 1 ] ; then
366                    ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e
367                    IGCM_sys_Put_Out start.nc    ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_start.nc
368                    IGCM_sys_Put_Out startphy.nc ${R_OUT_ATM_R}/${config_UserChoices_JobName}_${PeriodDateBegin}_startphy.nc
369                fi
370                IGCM_sys_Mv config.def.save config.def
371            else
372                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated"
373                echo "EXECUTION of ${HOST_MPIRUN_COMMAND} -np 1 ./create_etat0_limit.e simulated for DRYRUN = " $DRYRUN >> stack
374            fi
375        fi
376    fi
377
378    IGCM_debug_PopStack "ATM_Update"
379}
380
381#-----------------------------------
382function ATM_Finalize
383{
384    IGCM_debug_PushStack "ATM_Finalize"
385
386    [ ${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}
387
388
389    # Add special treatement for CARBON CYCLE
390    if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then
391        typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff
392
393        # Fossil fuel emission
394        if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then
395            # For Control, no fossil fuel emission :
396            fCO2_ff=0
397            echo "Fossil Fuel for control run  :" ${fCO2_ff}
398        else
399            # For historical, get the fossile fuel file :
400            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 )
401            echo "Fossil Fuel for historical run  :" ${fCO2_ff}
402        fi
403
404        # Get the value of ocean carbon flux
405        CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output )
406        CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" )
407        echo "Ocean carbon flux  :" ${CO2MBG}
408
409        # Get the value of land fluxes
410        set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 )
411        CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" )
412        CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" )
413        CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" )
414        echo "Land carbon flux (NEP)         :" ${CO2SRF}
415        echo "LU flux          (FLUC)        :" ${CO2LU}
416        echo "Total Land carbon flux (NBP)   :" ${CO2SBG}
417
418        # Previous CO2
419        CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )
420        echo "Previous CO2  :" ${CO2_ppm_prec}
421
422        # Formula
423        CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l )
424        echo "New CO2  :" ${CO2_ppm}
425
426        # Save CO2 values in ExeCpuLog variable contents 5 fields
427        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \
428            gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \
429                           $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log
430
431    fi
432
433    echo FINALIZE ATM !
434
435    IGCM_debug_PopStack "ATM_Finalize"
436}
Note: See TracBrowser for help on using the repository browser.