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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.