Changeset 1537


Ignore:
Timestamp:
08/19/11 17:10:40 (13 years ago)
Author:
jgipsl
Message:

Modifications in working configuration :

  • Added optional variable CARBON_CYCLE=control/historical/NONE, to be set in lmdz.card UserSection?. Default value NONE.
  • The special treatement for carbon cycle in lmdz.driver is now done only if this variable is set to control or historical. Added carbon

cycle treatement in all drivers.

  • Added the variable CARBON_CYCLE=control/historical only in Chistorical and CpiControl? lmdz.card.

NB!

  • The specific treatement when "${FirstInitialize?} and ${config_ATM_Restart}=y" was only done in Chistorical before. Now this

is done for both cases of CARBON_CYCLE=historical and control.

Location:
CONFIG/IPSLCM/IPSLCM5-2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • CONFIG/IPSLCM/IPSLCM5-2/Chistorical/COMP/lmdz.card

    r1535 r1537  
    2828LMDZ_NMC_hf=y 
    2929 
     30# CARBON_CYCLE=NONE/control/historical 
     31CARBON_CYCLE=historical 
    3032co2_init=284.725 
    3133 
  • CONFIG/IPSLCM/IPSLCM5-2/Chistorical/COMP/lmdz.driver

    r1535 r1537  
    9292    IGCM_debug_PushStack "ATM_Update" 
    9393 
    94     typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 
    95     typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
    96     typeset PathCO2log  
    9794 
    9895    case ${config_UserChoices_PeriodLength} in 
     
    120117    fi 
    121118 
    122     ## To have more variables in output files for aerosols. Parameters are set in lmdz.card 
    123     #if [ ${CumulPeriod}%${LMDZ_Freq_aero} -le ${LMDZ_Length_aero} ]; then 
    124     #   if [ ${CumulPeriod}%${LMDZ_Freq_aero} -ne 0 ]; then  
    125     #      lev_histmth=4 
    126     #   else 
    127     #      lev_histmth=2     
    128     #   fi 
    129     #else 
    130     #   lev_histmth=2 
    131     #fi     
    132  
    133119    ## algo : For CumulPeriod=1 ;  
    134120    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix 
     
    180166    fi 
    181167 
    182     if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then 
     168 
     169    # Add special treatement for CARBON CYCLE 
     170    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     171 
     172        typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 
     173        typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     174        typeset PathCO2log  
     175        typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 
     176 
     177        if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then 
    183178        ##--Initialization of fluxes to an undefined value at the first run 
    184         UndefinedValueCo2=-9999 
    185         InitPeriodCo2=0 
    186         InitDateBeginCo2=${UndefinedValueCo2} 
    187         InitYearCo2=$(( ${year} - 1 ))  
    188         InitDateEndCo2=${InitYearCo2}1231 
    189         fCO2_ff=${UndefinedValueCo2}  
    190         CO2SBG=${UndefinedValueCo2} 
    191         CO2LU=${UndefinedValueCo2} 
    192         CO2MBG=${UndefinedValueCo2} 
    193         CO2_ppm_prec=${UndefinedValueCo2} 
     179            UndefinedValueCo2=-9999 
     180            InitPeriodCo2=0 
     181            InitDateBeginCo2=${UndefinedValueCo2} 
     182            InitYearCo2=$(( ${year} - 1 ))  
     183            InitDateEndCo2=${InitYearCo2}1231 
     184            fCO2_ff=${UndefinedValueCo2}  
     185            CO2SBG=${UndefinedValueCo2} 
     186            CO2LU=${UndefinedValueCo2} 
     187            CO2MBG=${UndefinedValueCo2} 
     188            CO2_ppm_prec=${UndefinedValueCo2} 
    194189        # Get the initial value of atmosp. pco2  
    195         CO2_ppm=${lmdz_UserChoices_co2_init} 
    196  
    197         IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
    198         IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
    199  
     190            CO2_ppm=${lmdz_UserChoices_co2_init} 
     191             
     192            IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     193            IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     194             
    200195        # Save CO2 values in ExeCpuLog variable contents 5 fields 
    201         echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
    202              gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     196            echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     197                gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
    203198                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
    204      
     199             
    205200        # Get the path where the log file co2.log is 
    206         PathCO2log=${SUBMIT_DIR}  
     201            PathCO2log=${SUBMIT_DIR}  
    207202        # Get Previous line in co2.log 
    208         PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
    209          
    210     else 
    211  
     203            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     204             
     205        else 
     206             
    212207        # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): 
    213208        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. 
    214209        #SubmitRestartPath= 
    215         if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then 
    216             IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 
    217             PathCO2log=${config_ATM_SubmitRestartPath} 
    218             Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 
    219             PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 
    220      
    221             IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
    222             IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
    223      
     210            if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then 
     211                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 
     212                PathCO2log=${config_ATM_SubmitRestartPath} 
     213                Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 
     214                PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 
     215                 
     216                IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     217                IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     218                 
    224219            # Save Last Line of control in new co2.log file 
    225             InitPeriodCo2=0    
    226             InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 
    227             InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 
    228             fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 
    229             CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 
    230             CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 
    231             CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 
    232             CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 
    233             CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
    234  
    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", \ 
     220                InitPeriodCo2=0    
     221                InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 
     222                InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 
     223                fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 
     224                CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 
     225                CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 
     226                CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 
     227                CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 
     228                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     229                 
     230                echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     231                    gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
    237232                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
    238         else 
     233            else 
    239234           # Get restart line in co2.log 
    240            PathCO2log=${SUBMIT_DIR} 
    241            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     235                PathCO2log=${SUBMIT_DIR} 
     236                PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
    242237           # Get the value of atmosp. pco2 in co2.log 
    243            CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     238                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     239            fi 
     240             
    244241        fi 
    245242 
    246     fi 
     243        if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     244            # Modify co2_ppm in physiq.def only for historical run 
     245            LMDZ_sed physiq.def co2_ppm     ${CO2_ppm} 
     246        fi 
     247    fi 
     248    # end CARBON_CYCLE 
    247249 
    248250    ##-- For historical daily cosp must be output during 1979-2005 period 
     
    253255    LMDZ_sed physiq.def OK_journe   ${OK_journe} 
    254256    LMDZ_sed physiq.def OK_mensuel  ${OK_mensuel} 
    255     #LMDZ_sed physiq.def lev_histmth ${lev_histmth} 
    256257    LMDZ_sed physiq.def ok_hf       ${ok_hf} 
    257258    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth} 
     
    262263    LMDZ_sed physiq.def ok_hfCOSP   ${LMDZ_COSP_hf} 
    263264    LMDZ_sed physiq.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" 
    264     LMDZ_sed physiq.def co2_ppm     ${CO2_ppm} 
    265265 
    266266    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified 
     
    335335    [ ${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} 
    336336 
    337     typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
    338  
    339 #   get the fossile fuel file : 
    340     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 ) 
    341     echo "Fossil Fuel for historical run  :" ${fCO2_ff} 
    342  
    343     # Get the value of ocean carbon flux 
    344     CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 
    345     CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 
    346     echo "Ocean carbon flux  :" ${CO2MBG} 
    347      
    348     # Get the value of land fluxes 
    349     set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 
    350     CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 
    351     CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 
    352     CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 
    353     echo "Land carbon flux (NEP)         :" ${CO2SRF} 
    354     echo "LU flux          (FLUC)        :" ${CO2LU} 
    355     echo "Total Land carbon flux (NBP)   :" ${CO2SBG} 
    356  
    357     # Previous CO2 
    358     CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
    359     echo "Previous CO2  :" ${CO2_ppm_prec} 
    360  
    361     # Formula 
    362     CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 
    363     echo "New CO2  :" ${CO2_ppm} 
    364  
    365     # Save CO2 values in ExeCpuLog variable contents 5 fields 
    366     echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
    367          gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     337 
     338    # Add special treatement for CARBON CYCLE 
     339    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     340        typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     341 
     342        # Fossil fuel emission 
     343        if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then 
     344            # For Control, no fossil fuel emission : 
     345            fCO2_ff=0 
     346            echo "Fossil Fuel for control run  :" ${fCO2_ff} 
     347        else 
     348            # For historical, get the fossile fuel file : 
     349            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 ) 
     350            echo "Fossil Fuel for historical run  :" ${fCO2_ff} 
     351        fi 
     352 
     353        # Get the value of ocean carbon flux 
     354        CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 
     355        CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 
     356        echo "Ocean carbon flux  :" ${CO2MBG} 
     357 
     358        # Get the value of land fluxes 
     359        set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 
     360        CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 
     361        CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 
     362        CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 
     363        echo "Land carbon flux (NEP)         :" ${CO2SRF} 
     364        echo "LU flux          (FLUC)        :" ${CO2LU} 
     365        echo "Total Land carbon flux (NBP)   :" ${CO2SBG} 
     366 
     367        # Previous CO2 
     368        CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     369        echo "Previous CO2  :" ${CO2_ppm_prec} 
     370 
     371        # Formula 
     372        CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 
     373        echo "New CO2  :" ${CO2_ppm} 
     374 
     375        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     376        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     377            gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
    368378                           $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     379 
     380    fi 
     381 
    369382    echo FINALIZE ATM ! 
    370383 
  • CONFIG/IPSLCM/IPSLCM5-2/CpiControl/COMP/lmdz.card

    r1507 r1537  
    2828LMDZ_NMC_hf=y 
    2929 
     30# CARBON_CYCLE=NONE/control/historical 
     31CARBON_CYCLE=control 
    3032# CO2_ppm init 
    3133co2_init=284.725 
  • CONFIG/IPSLCM/IPSLCM5-2/CpiControl/COMP/lmdz.driver

    r1535 r1537  
    8989    IGCM_debug_PushStack "ATM_Update" 
    9090 
    91     typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
    92     typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 
    9391 
    9492    case ${config_UserChoices_PeriodLength} in 
     
    166164    fi 
    167165 
    168     if ( ${FirstInitialize} ) ; then 
     166 
     167    # Add special treatement for CARBON CYCLE 
     168    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     169 
     170        typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 
     171        typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     172        typeset PathCO2log  
     173        typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 
     174 
     175        if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then 
    169176        ##--Initialization of fluxes to an undefined value at the first run 
    170         UndefinedValueCo2=-9999 
    171         InitPeriodCo2=0 
    172         InitDateBeginCo2=${UndefinedValueCo2} 
    173         InitYearCo2=$(( ${year} - 1 ))  
    174         InitDateEndCo2=${InitYearCo2}1231 
    175         fCO2_ff=${UndefinedValueCo2}  
    176         CO2SBG=${UndefinedValueCo2} 
    177         CO2LU=${UndefinedValueCo2} 
    178         CO2MBG=${UndefinedValueCo2} 
    179         CO2_ppm_prec=${UndefinedValueCo2} 
     177            UndefinedValueCo2=-9999 
     178            InitPeriodCo2=0 
     179            InitDateBeginCo2=${UndefinedValueCo2} 
     180            InitYearCo2=$(( ${year} - 1 ))  
     181            InitDateEndCo2=${InitYearCo2}1231 
     182            fCO2_ff=${UndefinedValueCo2}  
     183            CO2SBG=${UndefinedValueCo2} 
     184            CO2LU=${UndefinedValueCo2} 
     185            CO2MBG=${UndefinedValueCo2} 
     186            CO2_ppm_prec=${UndefinedValueCo2} 
    180187        # Get the initial value of atmosp. pco2  
    181         CO2_ppm=${lmdz_UserChoices_co2_init} 
    182  
    183         IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
    184         IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
    185      
    186         # Save CO2 values in ExeCpuLog variable contents 5 fields 
    187         echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
    188              gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     188            CO2_ppm=${lmdz_UserChoices_co2_init} 
     189             
     190            IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     191            IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     192             
     193        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     194            echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     195                gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
    189196                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
    190      
    191         # Get the path where the log file co2.log is 
    192         PathCO2log=${SUBMIT_DIR}  
    193         # Get Previous line in co2.log 
    194         PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
    195  
    196     else 
    197         # Get restart line in co2.log 
    198         PathCO2log=${SUBMIT_DIR} 
    199         PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )  
    200         # Get the value of atmosp. pco2 in co2.log 
    201         CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
    202  
    203     fi 
     197             
     198        # Get the path where the log file co2.log is 
     199            PathCO2log=${SUBMIT_DIR}  
     200        # Get Previous line in co2.log 
     201            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     202             
     203        else 
     204             
     205        # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): 
     206        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. 
     207        #SubmitRestartPath= 
     208            if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then 
     209                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 
     210                PathCO2log=${config_ATM_SubmitRestartPath} 
     211                Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 
     212                PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 
     213                 
     214                IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     215                IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     216                 
     217            # Save Last Line of control in new co2.log file 
     218                InitPeriodCo2=0    
     219                InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 
     220                InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 
     221                fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 
     222                CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 
     223                CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 
     224                CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 
     225                CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 
     226                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     227                 
     228                echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     229                    gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     230                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     231            else 
     232           # Get restart line in co2.log 
     233                PathCO2log=${SUBMIT_DIR} 
     234                PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     235           # Get the value of atmosp. pco2 in co2.log 
     236                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     237            fi 
     238             
     239        fi 
     240 
     241        if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     242            # Modify co2_ppm in physiq.def only for historical run 
     243            LMDZ_sed physiq.def co2_ppm     ${CO2_ppm} 
     244        fi 
     245    fi 
     246    # end CARBON_CYCLE 
     247 
    204248 
    205249    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} 
     
    215259    LMDZ_sed physiq.def ok_hfCOSP   ${LMDZ_COSP_hf} 
    216260    LMDZ_sed physiq.def ok_histNMC  "${LMDZ_NMC_monthly}, ${LMDZ_NMC_daily}, ${LMDZ_NMC_hf}" 
    217 #   For Control, we won't modify ATM CO2 : 
    218 #    LMDZ_sed physiq.def co2_ppm     ${CO2_ppm} 
    219261 
    220262    ## gcm.def parameters : no change since gcm.def_${RESOL_ATM_3D} is used and already modified 
     
    289331    [ ${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} 
    290332 
    291     typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
    292  
    293     # For Control, no fossil fuel emission : 
    294     fCO2_ff=0 
    295     echo "Fossil Fuel for control run  :" ${fCO2_ff} 
    296  
    297     # Get the value of ocean carbon flux 
    298     CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 
    299     CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 
    300     echo "Ocean carbon flux  :" ${CO2MBG} 
    301  
    302     # Get the value of land fluxes 
    303     set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 
    304     CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 
    305     CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 
    306     CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 
    307     echo "Land carbon flux (NEP)         :" ${CO2SRF} 
    308     echo "LU flux          (FLUC)        :" ${CO2LU} 
    309     echo "Total Land carbon flux (NBP)   :" ${CO2SBG} 
    310  
    311     # Previous CO2 
    312     CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
    313     echo "Previous CO2  :" ${CO2_ppm_prec} 
    314      
    315     # Formula 
    316     CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 
    317     echo "New CO2  :" ${CO2_ppm} 
    318  
    319     # Save CO2 values in ExeCpuLog variable contents 5 fields 
    320     echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
    321          gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     333 
     334    # Add special treatement for CARBON CYCLE 
     335    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     336        typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     337 
     338        # Fossil fuel emission 
     339        if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then 
     340            # For Control, no fossil fuel emission : 
     341            fCO2_ff=0 
     342            echo "Fossil Fuel for control run  :" ${fCO2_ff} 
     343        else 
     344            # For historical, get the fossile fuel file : 
     345            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 ) 
     346            echo "Fossil Fuel for historical run  :" ${fCO2_ff} 
     347        fi 
     348 
     349        # Get the value of ocean carbon flux 
     350        CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 
     351        CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 
     352        echo "Ocean carbon flux  :" ${CO2MBG} 
     353 
     354        # Get the value of land fluxes 
     355        set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 
     356        CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 
     357        CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 
     358        CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 
     359        echo "Land carbon flux (NEP)         :" ${CO2SRF} 
     360        echo "LU flux          (FLUC)        :" ${CO2LU} 
     361        echo "Total Land carbon flux (NBP)   :" ${CO2SBG} 
     362 
     363        # Previous CO2 
     364        CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     365        echo "Previous CO2  :" ${CO2_ppm_prec} 
     366 
     367        # Formula 
     368        CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 
     369        echo "New CO2  :" ${CO2_ppm} 
     370 
     371        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     372        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     373            gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
    322374                           $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     375 
     376    fi 
    323377 
    324378    echo FINALIZE ATM ! 
  • CONFIG/IPSLCM/IPSLCM5-2/EXP00/COMP/lmdz.driver

    r1535 r1537  
    8888{ 
    8989    IGCM_debug_PushStack "ATM_Update" 
     90 
    9091 
    9192    case ${config_UserChoices_PeriodLength} in 
     
    135136    [ ${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 ) 
    136137 
     138 
    137139    ##-- GHG forcing : 
    138140    ##   If forcing file exist in run directory, read values for the current year and modify physiq.def 
     
    161163        LMDZ_sed physiq.def CFC12_ppt   ${IPCC_CFC12} 
    162164    fi 
     165 
     166 
     167    # Add special treatement for CARBON CYCLE 
     168    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     169 
     170        typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 
     171        typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     172        typeset PathCO2log  
     173        typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 
     174 
     175        if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then 
     176        ##--Initialization of fluxes to an undefined value at the first run 
     177            UndefinedValueCo2=-9999 
     178            InitPeriodCo2=0 
     179            InitDateBeginCo2=${UndefinedValueCo2} 
     180            InitYearCo2=$(( ${year} - 1 ))  
     181            InitDateEndCo2=${InitYearCo2}1231 
     182            fCO2_ff=${UndefinedValueCo2}  
     183            CO2SBG=${UndefinedValueCo2} 
     184            CO2LU=${UndefinedValueCo2} 
     185            CO2MBG=${UndefinedValueCo2} 
     186            CO2_ppm_prec=${UndefinedValueCo2} 
     187        # Get the initial value of atmosp. pco2  
     188            CO2_ppm=${lmdz_UserChoices_co2_init} 
     189             
     190            IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     191            IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     192             
     193        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     194            echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     195                gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     196                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     197             
     198        # Get the path where the log file co2.log is 
     199            PathCO2log=${SUBMIT_DIR}  
     200        # Get Previous line in co2.log 
     201            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     202             
     203        else 
     204             
     205        # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): 
     206        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. 
     207        #SubmitRestartPath= 
     208            if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then 
     209                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 
     210                PathCO2log=${config_ATM_SubmitRestartPath} 
     211                Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 
     212                PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 
     213                 
     214                IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     215                IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     216                 
     217            # Save Last Line of control in new co2.log file 
     218                InitPeriodCo2=0    
     219                InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 
     220                InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 
     221                fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 
     222                CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 
     223                CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 
     224                CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 
     225                CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 
     226                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     227                 
     228                echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     229                    gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     230                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     231            else 
     232           # Get restart line in co2.log 
     233                PathCO2log=${SUBMIT_DIR} 
     234                PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     235           # Get the value of atmosp. pco2 in co2.log 
     236                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     237            fi 
     238             
     239        fi 
     240 
     241        if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     242            # Modify co2_ppm in physiq.def only for historical run 
     243            LMDZ_sed physiq.def co2_ppm     ${CO2_ppm} 
     244        fi 
     245    fi 
     246    # end CARBON_CYCLE 
     247 
    163248 
    164249    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} 
     
    246331    [ ${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} 
    247332 
     333 
     334    # Add special treatement for CARBON CYCLE 
     335    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     336        typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     337 
     338        # Fossil fuel emission 
     339        if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then 
     340            # For Control, no fossil fuel emission : 
     341            fCO2_ff=0 
     342            echo "Fossil Fuel for control run  :" ${fCO2_ff} 
     343        else 
     344            # For historical, get the fossile fuel file : 
     345            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 ) 
     346            echo "Fossil Fuel for historical run  :" ${fCO2_ff} 
     347        fi 
     348 
     349        # Get the value of ocean carbon flux 
     350        CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 
     351        CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 
     352        echo "Ocean carbon flux  :" ${CO2MBG} 
     353 
     354        # Get the value of land fluxes 
     355        set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 
     356        CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 
     357        CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 
     358        CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 
     359        echo "Land carbon flux (NEP)         :" ${CO2SRF} 
     360        echo "LU flux          (FLUC)        :" ${CO2LU} 
     361        echo "Total Land carbon flux (NBP)   :" ${CO2SBG} 
     362 
     363        # Previous CO2 
     364        CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     365        echo "Previous CO2  :" ${CO2_ppm_prec} 
     366 
     367        # Formula 
     368        CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 
     369        echo "New CO2  :" ${CO2_ppm} 
     370 
     371        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     372        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     373            gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     374                           $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     375 
     376    fi 
     377 
    248378    echo FINALIZE ATM ! 
    249379 
  • CONFIG/IPSLCM/IPSLCM5-2/historical/COMP/lmdz.driver

    r1535 r1537  
    9191{ 
    9292    IGCM_debug_PushStack "ATM_Update" 
     93 
    9394 
    9495    case ${config_UserChoices_PeriodLength} in 
     
    116117    fi 
    117118 
    118     ## To have more variables in output files for aerosols. Parameters are set in lmdz.card 
    119     #if [ ${CumulPeriod}%${LMDZ_Freq_aero} -le ${LMDZ_Length_aero} ]; then 
    120     #   if [ ${CumulPeriod}%${LMDZ_Freq_aero} -ne 0 ]; then  
    121     #      lev_histmth=4 
    122     #   else 
    123     #      lev_histmth=2     
    124     #   fi 
    125     #else 
    126     #   lev_histmth=2 
    127     #fi     
    128  
    129119    ## algo : For CumulPeriod=1 ;  
    130120    ##        IF NbPeriod_Adjust = 0, Get Bands file directly from server, store it with _0 suffix 
     
    176166    fi 
    177167 
     168 
     169    # Add special treatement for CARBON CYCLE 
     170    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     171 
     172        typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 
     173        typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     174        typeset PathCO2log  
     175        typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 
     176 
     177        if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then 
     178        ##--Initialization of fluxes to an undefined value at the first run 
     179            UndefinedValueCo2=-9999 
     180            InitPeriodCo2=0 
     181            InitDateBeginCo2=${UndefinedValueCo2} 
     182            InitYearCo2=$(( ${year} - 1 ))  
     183            InitDateEndCo2=${InitYearCo2}1231 
     184            fCO2_ff=${UndefinedValueCo2}  
     185            CO2SBG=${UndefinedValueCo2} 
     186            CO2LU=${UndefinedValueCo2} 
     187            CO2MBG=${UndefinedValueCo2} 
     188            CO2_ppm_prec=${UndefinedValueCo2} 
     189        # Get the initial value of atmosp. pco2  
     190            CO2_ppm=${lmdz_UserChoices_co2_init} 
     191             
     192            IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     193            IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     194             
     195        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     196            echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     197                gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     198                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     199             
     200        # Get the path where the log file co2.log is 
     201            PathCO2log=${SUBMIT_DIR}  
     202        # Get Previous line in co2.log 
     203            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     204             
     205        else 
     206             
     207        # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): 
     208        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. 
     209        #SubmitRestartPath= 
     210            if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then 
     211                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 
     212                PathCO2log=${config_ATM_SubmitRestartPath} 
     213                Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 
     214                PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 
     215                 
     216                IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     217                IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     218                 
     219            # Save Last Line of control in new co2.log file 
     220                InitPeriodCo2=0    
     221                InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 
     222                InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 
     223                fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 
     224                CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 
     225                CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 
     226                CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 
     227                CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 
     228                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     229                 
     230                echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     231                    gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     232                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     233            else 
     234           # Get restart line in co2.log 
     235                PathCO2log=${SUBMIT_DIR} 
     236                PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     237           # Get the value of atmosp. pco2 in co2.log 
     238                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     239            fi 
     240             
     241        fi 
     242 
     243        if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     244            # Modify co2_ppm in physiq.def only for historical run 
     245            LMDZ_sed physiq.def co2_ppm     ${CO2_ppm} 
     246        fi 
     247    fi 
     248    # end CARBON_CYCLE 
     249 
    178250    ##-- For historical daily cosp must be output during 1979-2005 period 
    179251    [ ${year} -ge 1979 ] && LMDZ_COSP_daily=y 
     
    183255    LMDZ_sed physiq.def OK_journe   ${OK_journe} 
    184256    LMDZ_sed physiq.def OK_mensuel  ${OK_mensuel} 
    185     #LMDZ_sed physiq.def lev_histmth ${lev_histmth} 
    186257    LMDZ_sed physiq.def ok_hf       ${ok_hf} 
    187258    LMDZ_sed physiq.def ecrit_mth   ${LMDZ_ecrit_mth} 
     
    264335    [ ${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} 
    265336 
     337 
     338    # Add special treatement for CARBON CYCLE 
     339    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     340        typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     341 
     342        # Fossil fuel emission 
     343        if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then 
     344            # For Control, no fossil fuel emission : 
     345            fCO2_ff=0 
     346            echo "Fossil Fuel for control run  :" ${fCO2_ff} 
     347        else 
     348            # For historical, get the fossile fuel file : 
     349            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 ) 
     350            echo "Fossil Fuel for historical run  :" ${fCO2_ff} 
     351        fi 
     352 
     353        # Get the value of ocean carbon flux 
     354        CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 
     355        CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 
     356        echo "Ocean carbon flux  :" ${CO2MBG} 
     357 
     358        # Get the value of land fluxes 
     359        set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 
     360        CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 
     361        CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 
     362        CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 
     363        echo "Land carbon flux (NEP)         :" ${CO2SRF} 
     364        echo "LU flux          (FLUC)        :" ${CO2LU} 
     365        echo "Total Land carbon flux (NBP)   :" ${CO2SBG} 
     366 
     367        # Previous CO2 
     368        CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     369        echo "Previous CO2  :" ${CO2_ppm_prec} 
     370 
     371        # Formula 
     372        CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 
     373        echo "New CO2  :" ${CO2_ppm} 
     374 
     375        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     376        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     377            gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     378                           $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     379 
     380    fi 
     381 
    266382    echo FINALIZE ATM ! 
    267383 
  • CONFIG/IPSLCM/IPSLCM5-2/piControl/COMP/lmdz.driver

    r1535 r1537  
    8888{ 
    8989    IGCM_debug_PushStack "ATM_Update" 
     90 
    9091 
    9192    case ${config_UserChoices_PeriodLength} in 
     
    135136    [ ${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 ) 
    136137 
     138 
    137139    ##-- GHG forcing : 
    138140    ##   If forcing file exist in run directory, read values for the current year and modify physiq.def 
     
    161163        LMDZ_sed physiq.def CFC12_ppt   ${IPCC_CFC12} 
    162164    fi 
     165 
     166 
     167    # Add special treatement for CARBON CYCLE 
     168    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     169 
     170        typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2 
     171        typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     172        typeset PathCO2log  
     173        typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX 
     174 
     175        if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ]) ; then 
     176        ##--Initialization of fluxes to an undefined value at the first run 
     177            UndefinedValueCo2=-9999 
     178            InitPeriodCo2=0 
     179            InitDateBeginCo2=${UndefinedValueCo2} 
     180            InitYearCo2=$(( ${year} - 1 ))  
     181            InitDateEndCo2=${InitYearCo2}1231 
     182            fCO2_ff=${UndefinedValueCo2}  
     183            CO2SBG=${UndefinedValueCo2} 
     184            CO2LU=${UndefinedValueCo2} 
     185            CO2MBG=${UndefinedValueCo2} 
     186            CO2_ppm_prec=${UndefinedValueCo2} 
     187        # Get the initial value of atmosp. pco2  
     188            CO2_ppm=${lmdz_UserChoices_co2_init} 
     189             
     190            IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     191            IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     192             
     193        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     194            echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     195                gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     196                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     197             
     198        # Get the path where the log file co2.log is 
     199            PathCO2log=${SUBMIT_DIR}  
     200        # Get Previous line in co2.log 
     201            PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     202             
     203        else 
     204             
     205        # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ): 
     206        # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2. 
     207        #SubmitRestartPath= 
     208            if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ]) ; then 
     209                IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath 
     210                PathCO2log=${config_ATM_SubmitRestartPath} 
     211                Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} ) 
     212                PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log ) 
     213                 
     214                IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log 
     215                IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log 
     216                 
     217            # Save Last Line of control in new co2.log file 
     218                InitPeriodCo2=0    
     219                InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' ) 
     220                InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' ) 
     221                fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' ) 
     222                CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' ) 
     223                CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' ) 
     224                CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' ) 
     225                CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' ) 
     226                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     227                 
     228                echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     229                    gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     230                              $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     231            else 
     232           # Get restart line in co2.log 
     233                PathCO2log=${SUBMIT_DIR} 
     234                PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log ) 
     235           # Get the value of atmosp. pco2 in co2.log 
     236                CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     237            fi 
     238             
     239        fi 
     240 
     241        if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     242            # Modify co2_ppm in physiq.def only for historical run 
     243            LMDZ_sed physiq.def co2_ppm     ${CO2_ppm} 
     244        fi 
     245    fi 
     246    # end CARBON_CYCLE 
     247 
    163248 
    164249    ## physiq.def parameters modified from initial physiq_L${RESOL_ATM_Z} 
     
    246331    [ ${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} 
    247332 
     333 
     334    # Add special treatement for CARBON CYCLE 
     335    if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] || [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then 
     336        typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff 
     337 
     338        # Fossil fuel emission 
     339        if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then 
     340            # For Control, no fossil fuel emission : 
     341            fCO2_ff=0 
     342            echo "Fossil Fuel for control run  :" ${fCO2_ff} 
     343        else 
     344            # For historical, get the fossile fuel file : 
     345            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 ) 
     346            echo "Fossil Fuel for historical run  :" ${fCO2_ff} 
     347        fi 
     348 
     349        # Get the value of ocean carbon flux 
     350        CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output ) 
     351        CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" ) 
     352        echo "Ocean carbon flux  :" ${CO2MBG} 
     353 
     354        # Get the value of land fluxes 
     355        set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 ) 
     356        CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" ) 
     357        CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" ) 
     358        CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" ) 
     359        echo "Land carbon flux (NEP)         :" ${CO2SRF} 
     360        echo "LU flux          (FLUC)        :" ${CO2LU} 
     361        echo "Total Land carbon flux (NBP)   :" ${CO2SBG} 
     362 
     363        # Previous CO2 
     364        CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' ) 
     365        echo "Previous CO2  :" ${CO2_ppm_prec} 
     366 
     367        # Formula 
     368        CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l ) 
     369        echo "New CO2  :" ${CO2_ppm} 
     370 
     371        # Save CO2 values in ExeCpuLog variable contents 5 fields 
     372        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" |   \ 
     373            gawk '{printf("  %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \ 
     374                           $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log 
     375 
     376    fi 
     377 
    248378    echo FINALIZE ATM ! 
    249379 
Note: See TracChangeset for help on using the changeset viewer.