- Timestamp:
- 03/28/19 14:43:11 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CONFIG/UNIFORM/v7/ICOLMDZOR_v7/GENERAL/DRIVER/lmdz.driver
r4366 r4378 189 189 IGCM_comp_modifyDefFile nonblocker config.def t_coupl ${LMDZ_t_coupl} 190 190 191 ##-- Add special treatement for CARBON CYCLE192 if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then193 ATM_Carbon_Update194 fi195 196 197 ##-- Set LMDZ_COSP_daily1979=y in section UserChoices in lmdz.card to activate198 ## COSP daily output for years 1979 and later (mandatory for historical CMIP5 run).199 if ([ X"${lmdz_UserChoices_LMDZ_COSP_daily1979}" = X"y" ] && [ ${year} -ge 1979 ]) ; then200 LMDZ_COSP_daily=.TRUE.201 fi202 191 203 192 ## Modifiy … … 561 550 IGCM_debug_PushStack "ATM_Finalize" 562 551 563 # Add special treatement for CARBON CYCLE564 if [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"control" ] || [ X"${lmdz_UserChoices_CARBON_CYCLE}" = X"historical" ] ; then565 ATM_Carbon_Finalize566 fi567 568 echo FINALIZE ATM !569 570 552 IGCM_debug_PopStack "ATM_Finalize" 571 553 } 572 554 573 555 574 575 function ATM_Carbon_Update576 {577 # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card578 579 IGCM_debug_PushStack "ATM_Carbon_Update"580 581 typeset InitPeriodCo2 InitDateBeginCo2 InitDateEndCo2582 typeset CO2SBG CO2MBG CO2LU CO2_ppm CO2_ppm_prec fCO2_ff583 typeset PathCO2log584 typeset PreviousLinelog LastPeriodDateBegin LastPeriodDateEnd LastDatesPeriod LastPREFIX585 586 if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"n" ] ) ; then587 ##--Initialization of fluxes to an undefined value at the first run588 UndefinedValueCo2=-9999589 InitPeriodCo2=0590 InitDateBeginCo2=${UndefinedValueCo2}591 InitYearCo2=$(( ${year} - 1 ))592 InitDateEndCo2=${InitYearCo2}1231593 fCO2_ff=${UndefinedValueCo2}594 CO2SBG=${UndefinedValueCo2}595 CO2LU=${UndefinedValueCo2}596 CO2MBG=${UndefinedValueCo2}597 CO2_ppm_prec=${UndefinedValueCo2}598 # Get the initial value of atmosp. pco2599 CO2_ppm=${lmdz_UserChoices_co2_init}600 601 IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log602 IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log603 604 # Save CO2 values in ExeCpuLog variable contents 5 fields605 echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \606 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \607 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log608 609 # Get the path where the log file co2.log is610 PathCO2log=${SUBMIT_DIR}611 # Get Previous line in co2.log612 PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )613 614 else615 616 # NEW parameter in config.card (even for Overule all restarts, you must modify the line after this comment ):617 # !! NEW for Carbone cycle !! Path where to find old co2.log file for restart CO2.618 #SubmitRestartPath=619 if ( ${FirstInitialize} && [ X"${config_ATM_Restart}" = X"y" ] ) ; then620 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ATM SubmitRestartPath621 PathCO2log=${config_ATM_SubmitRestartPath}622 Date_r=$( IGCM_date_ConvertFormatToGregorian ${config_ATM_RestartDate} )623 PreviousLinelog=$( grep ${Date_r} ${PathCO2log}/co2.log )624 625 IGCM_sys_Cp ${SUBMIT_DIR}/co2.log.init ${SUBMIT_DIR}/co2.log626 IGCM_sys_Chmod u+w ${SUBMIT_DIR}/co2.log627 628 # Save Last Line of control in new co2.log file629 InitPeriodCo2=0630 InitDateBeginCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $2}' )631 InitDateEndCo2=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $3}' )632 fCO2_ff=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $6}' )633 CO2SBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $8}' )634 CO2LU=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $9}' )635 CO2MBG=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $7}' )636 CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $5}' )637 CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )638 639 echo "${InitPeriodCo2} ${InitDateBeginCo2} ${InitDateEndCo2} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \640 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \641 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log642 else643 # Get restart line in co2.log644 PathCO2log=${SUBMIT_DIR}645 PreviousLinelog=$( tail -1 ${PathCO2log}/co2.log )646 # Get the value of atmosp. pco2 in co2.log647 CO2_ppm=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )648 fi649 650 fi651 652 if [ ${lmdz_UserChoices_CARBON_CYCLE} = historical ] ; then653 # Modify co2_ppm in config.def only for historical run654 # If not historical run, keep co2_ppm value set earlier by IGCM_comp_modifyDefFile655 IGCM_comp_modifyDefFile force config.def co2_ppm ${CO2_ppm}656 fi657 IGCM_debug_PopStack "ATM_Carbon_Update"658 }659 660 661 function ATM_Carbon_Finalize662 {663 # This fuction will be called only if CARBON_CYCLE is set to control or historical in lmdz.card664 665 IGCM_debug_PushStack "ATM_Carbon_Finalize"666 667 typeset CO2SBG_3V CO2SBG CO2MBG CO2SRF CO2LU CO2_ppm CO2_ppm_prec fCO2_ff668 669 # Fossil fuel emission670 if [ ${lmdz_UserChoices_CARBON_CYCLE} = control ] ; then671 # For Control, no fossil fuel emission :672 fCO2_ff=0673 echo "Fossil Fuel for control run :" ${fCO2_ff}674 else675 # For historical, get the fossile fuel file :676 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 )677 echo "Fossil Fuel for historical run :" ${fCO2_ff}678 fi679 680 # Get the value of ocean carbon flux681 CO2MBG=$( ${SUBMIT_DIR}/COMP/lmdz_analyse_pisces_out.awk ocean.output )682 CO2MBG=$( echo ${CO2MBG} | sed -e "s/ *//" )683 echo "Ocean carbon flux :" ${CO2MBG}684 685 # Get the value of land fluxes686 set +A CO2SBG_3V -- $( ${SUBMIT_DIR}/COMP/lmdz_analyse_stomate_out.awk out_orchidee_0000 )687 CO2SRF=$( echo ${CO2SBG_3V[0]} | sed -e "s/ *//" )688 CO2LU=$( echo ${CO2SBG_3V[1]} | sed -e "s/ *//" )689 CO2SBG=$( echo ${CO2SBG_3V[2]} | sed -e "s/ *//" )690 echo "Land carbon flux (NEP) :" ${CO2SRF}691 echo "LU flux (FLUC) :" ${CO2LU}692 echo "Total Land carbon flux (NBP) :" ${CO2SBG}693 694 # Previous CO2695 CO2_ppm_prec=$( echo "${PreviousLinelog[*]}" | gawk -F '|' '{gsub(" ",""); print $4}' )696 echo "Previous CO2 :" ${CO2_ppm_prec}697 698 # Formula699 CO2_ppm=$( echo "${CO2_ppm_prec} + (${fCO2_ff} + ${CO2MBG} + ${CO2SBG}) / 2.12" | bc -l )700 echo "New CO2 :" ${CO2_ppm}701 702 # Save CO2 values in ExeCpuLog variable contents 5 fields703 echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${CO2_ppm} ${CO2_ppm_prec} ${fCO2_ff} ${CO2MBG} ${CO2SBG} ${CO2LU}" | \704 gawk '{printf(" %11d | %15s | %15s | %22.15g | %20.15g | %11.8g | %11.8g | %12.8g | %12.8g \n", \705 $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/co2.log706 707 IGCM_debug_PopStack "ATM_Carbon_Finalize"708 }
Note: See TracChangeset
for help on using the changeset viewer.