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/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.