Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to C starvation by canopy layer history variables #971

Merged
merged 8 commits into from
Feb 2, 2023
31 changes: 25 additions & 6 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ module FatesHistoryInterfaceMod
integer :: ih_h2oveg_recruit_si
integer :: ih_h2oveg_growturn_err_si
integer :: ih_h2oveg_hydro_err_si

integer :: ih_lai_si

integer :: ih_site_cstatus_si
integer :: ih_site_dstatus_si
integer :: ih_gdd_si
Expand Down Expand Up @@ -2474,7 +2475,8 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
hio_tveg24 => this%hvars(ih_tveg24_si)%r81d, &
hio_meanliqvol_si => this%hvars(ih_meanliqvol_si)%r81d, &
hio_cbal_err_fates_si => this%hvars(ih_cbal_err_fates_si)%r81d, &
hio_err_fates_si => this%hvars(ih_err_fates_si)%r82d )
hio_err_fates_si => this%hvars(ih_err_fates_si)%r82d, &
hio_lai_si => this%hvars(ih_lai_si)%r81d )

! If we don't have dynamics turned on, we just abort these diagnostics
if (hlm_use_ed_st3.eq.itrue) return
Expand Down Expand Up @@ -2650,6 +2652,9 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
+ cpatch%ncl_p * cpatch%area
hio_npatches_si_age(io_si,cpatch%age_class) = hio_npatches_si_age(io_si,cpatch%age_class) + 1._r8

hio_lai_si(io_si) = hio_lai_si(io_si) + sum( cpatch%canopy_area_profile(:,:,:) * cpatch%elai_profile(:,:,:) ) * &
cpatch%total_canopy_area * AREA_INV

if ( ED_val_comp_excln .lt. 0._r8 ) then ! only valid when "strict ppa" enabled
hio_zstar_si_age(io_si,cpatch%age_class) = hio_zstar_si_age(io_si,cpatch%age_class) &
+ cpatch%zstar * cpatch%area * AREA_INV
Expand Down Expand Up @@ -3293,6 +3298,9 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
(ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * &
ccohort%n * sec_per_day * days_per_year / m2_per_ha

hio_m3_mortality_canopy_si_scpf(io_si,scpf) = hio_m3_mortality_canopy_si_scpf(io_si,scpf) + &
ccohort%cmort * ccohort%n / m2_per_ha

hio_nplant_canopy_si_scpf(io_si,scpf) = hio_nplant_canopy_si_scpf(io_si,scpf) + ccohort%n / m2_per_ha
hio_nplant_canopy_si_scls(io_si,scls) = hio_nplant_canopy_si_scls(io_si,scls) + ccohort%n / m2_per_ha
hio_lai_canopy_si_scls(io_si,scls) = hio_lai_canopy_si_scls(io_si,scls) + &
Expand Down Expand Up @@ -3320,6 +3328,9 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
(ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * &
ccohort%n * sec_per_day * days_per_year / m2_per_ha

hio_m3_mortality_canopy_si_scls(io_si,scls) = hio_m3_mortality_canopy_si_scls(io_si,scls) + &
ccohort%cmort * ccohort%n / m2_per_ha

hio_canopy_mortality_carbonflux_si(io_si) = hio_canopy_mortality_carbonflux_si(io_si) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + &
ccohort%frmort + ccohort%smort + ccohort%asmort + ccohort%dgmort) * &
Expand All @@ -3334,9 +3345,6 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
(ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * &
ccohort%c_area * sec_per_day * days_per_year

hio_m3_mortality_canopy_si_scls(io_si,scls) = hio_m3_mortality_canopy_si_scls(io_si,scls) + &
ccohort%cmort * ccohort%n

hio_carbon_balance_canopy_si_scls(io_si,scls) = hio_carbon_balance_canopy_si_scls(io_si,scls) + &
ccohort%n * ccohort%npp_acc_hold / m2_per_ha / days_per_year / sec_per_day

Expand Down Expand Up @@ -3431,6 +3439,9 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
(ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * &
ccohort%n * sec_per_day * days_per_year / m2_per_ha

hio_m3_mortality_understory_si_scpf(io_si,scpf) = hio_m3_mortality_understory_si_scpf(io_si,scpf) + &
ccohort%cmort * ccohort%n / m2_per_ha

if ( cpatch%anthro_disturbance_label .eq. secondaryforest ) then
hio_mortality_canopy_secondary_si_scls(io_si,scls) = hio_mortality_canopy_secondary_si_scls(io_si,scls) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + &
Expand All @@ -3439,7 +3450,6 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
ccohort%n * sec_per_day * days_per_year / m2_per_ha
end if


hio_nplant_understory_si_scpf(io_si,scpf) = hio_nplant_understory_si_scpf(io_si,scpf) + ccohort%n / m2_per_ha
hio_nplant_understory_si_scls(io_si,scls) = hio_nplant_understory_si_scls(io_si,scls) + ccohort%n / m2_per_ha
hio_lai_understory_si_scls(io_si,scls) = hio_lai_understory_si_scls(io_si,scls) + &
Expand Down Expand Up @@ -3468,6 +3478,9 @@ subroutine update_history_dyn(this,nc,nsites,sites,bc_in)
(ccohort%lmort_direct + ccohort%lmort_collateral + ccohort%lmort_infra) * &
ccohort%n * sec_per_day * days_per_year / m2_per_ha

hio_m3_mortality_understory_si_scls(io_si,scls) = hio_m3_mortality_understory_si_scls(io_si,scls) + &
ccohort%cmort * ccohort%n / m2_per_ha

hio_understory_mortality_carbonflux_si(io_si) = hio_understory_mortality_carbonflux_si(io_si) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + &
ccohort%frmort + ccohort%smort + ccohort%asmort + ccohort%dgmort) * &
Expand Down Expand Up @@ -5321,6 +5334,12 @@ subroutine define_history_vars(this, initialize_variables)
upfreq=1, ivar=ivar, initialize=initialize_variables, &
index=ih_canopy_spread_si)

call this%set_history_var(vname='FATES_LAI', units='m2 m-2', &
long='leaf area index per m2 land area', &
use_default='active', avgflag='A', vtype=site_r8, hlms='CLM:ALM', &
upfreq=1, ivar=ivar, initialize=initialize_variables, &
index=ih_lai_si)

call this%set_history_var(vname='FATES_VEGC_PF', units='kg m-2', &
long='total PFT-level biomass in kg of carbon per land area', &
use_default='active', avgflag='A', vtype=site_pft_r8, hlms='CLM:ALM', &
Expand Down