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

Last change on this file since 1615 was 1550, checked in by jgipsl, 13 years ago
  • Added choice of config.def file : set ConfType?=preind/actuel/annuel in lmdz.card. The file config.def_$ConfType? will be used. The differences are :

preind : aer_type = preind, solar and GHG pre-industrial values, pmagic=0 (as piControl, CpiControl?)
actuel : aer_type = actuel, solar and GHG present values, pmagic=0.008 (as EXP00)
annuel : aer_type = annuel, solar and GHG must be updated with annual values from file, pmagic=0.008 (as historical,Chistorical)

  • For pisces, take same value for CO2 as for LMDZ except for CarbonCycle?=y (same treatment as before).

NB! I suppose that LMDZ ATM_Uptdate always is done before pisces MBG_Update.

  • Added choice of output.def file : set OutLev?=low(as EXP00)/medium(as piControl)/high(as histrical) in lmdz.card. The output are now the same as original IPSLCM5A for each experience.

=> In EXPALL, all 5 experiences correspond to original IPSLCM5A experiences, including possibility of new physics in LMDZ as IPSLCM5B and carbon cycle as IPSLCM5C. More testing is needed.

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