Skip to content

Commit

Permalink
Merge pull request #1217 from rgknox/history-flux-diags
Browse files Browse the repository at this point in the history
time integrated flux diagnostics
  • Loading branch information
rgknox authored Oct 18, 2024
2 parents 825579d + c83473d commit f5bd625
Show file tree
Hide file tree
Showing 12 changed files with 558 additions and 183 deletions.
17 changes: 9 additions & 8 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Module EDCohortDynamicsMod
use PRTGenericMod , only : max_nleafage
use FatesConstantsMod , only : ican_upper
use EDTypesMod , only : site_fluxdiags_type
use EDTypesMod , only : elem_diag_type
use PRTGenericMod , only : num_elements
use FatesConstantsMod , only : leaves_on
use FatesConstantsMod , only : leaves_off
Expand Down Expand Up @@ -602,7 +603,7 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)
type(bc_in_type), intent(in) :: bc_in

type(litter_type), pointer :: litt ! Litter object for each element
type(site_fluxdiags_type),pointer :: flux_diags
type(elem_diag_type),pointer :: elflux_diags

real(r8) :: leaf_m ! leaf mass [kg]
real(r8) :: store_m ! storage mass [kg]
Expand Down Expand Up @@ -646,7 +647,7 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)
endif

litt => cpatch%litter(el)
flux_diags => csite%flux_diags(el)
elflux_diags => csite%flux_diags%elem(el)

!adjust how wood is partitioned between the cwd classes based on cohort dbh
call adjust_SF_CWD_frac(ccohort%dbh,ncwd,SF_val_CWD_frac,SF_val_CWD_frac_adj)
Expand All @@ -667,12 +668,12 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)
enddo

! above ground
flux_diags%cwd_ag_input(c) = flux_diags%cwd_ag_input(c) + &
elflux_diags%cwd_ag_input(c) = elflux_diags%cwd_ag_input(c) + &
(struct_m+sapw_m) * SF_val_CWD_frac_adj(c) * &
prt_params%allom_agb_frac(pft) * nplant

! below ground
flux_diags%cwd_bg_input(c) = flux_diags%cwd_bg_input(c) + &
elflux_diags%cwd_bg_input(c) = elflux_diags%cwd_bg_input(c) + &
(struct_m + sapw_m) * SF_val_CWD_frac_adj(c) * &
(1.0_r8 - prt_params%allom_agb_frac(pft)) * nplant

Expand All @@ -692,11 +693,11 @@ subroutine SendCohortToLitter(csite,cpatch,ccohort,nplant,bc_in)

end do

flux_diags%leaf_litter_input(pft) = &
flux_diags%leaf_litter_input(pft) + &
elflux_diags%surf_fine_litter_input(pft) = &
elflux_diags%surf_fine_litter_input(pft) + &
(leaf_m+repro_m) * nplant
flux_diags%root_litter_input(pft) = &
flux_diags%root_litter_input(pft) + &
elflux_diags%root_litter_input(pft) = &
elflux_diags%root_litter_input(pft) + &
(fnrt_m+store_m) * nplant


Expand Down
43 changes: 23 additions & 20 deletions biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module EDLoggingMortalityMod
use FatesPatchMod , only : fates_patch_type
use EDTypesMod , only : site_massbal_type
use EDTypesMod , only : site_fluxdiags_type
use EDTypesMod , only : elem_diag_type
use FatesLitterMod , only : ncwd
use FatesLitterMod , only : ndcmpy
use FatesLitterMod , only : litter_type
Expand All @@ -28,6 +29,7 @@ module EDLoggingMortalityMod
use FatesConstantsMod , only : dtype_ilog
use FatesConstantsMod , only : dtype_ifall
use FatesConstantsMod , only : dtype_ifire
use EDTypesMod , only : area_inv
use FatesConstantsMod , only : n_landuse_cats
use EDPftvarcon , only : EDPftvarcon_inst
use EDPftvarcon , only : GetDecompyFrac
Expand Down Expand Up @@ -502,8 +504,6 @@ subroutine get_harvestable_carbon (csite, site_area, hlm_harvest_catnames, harve

!USES:
use SFParamsMod, only : SF_val_cwd_frac
use EDTypesMod, only : AREA_INV


! -------------------------------------------------------------------------------------------
!
Expand Down Expand Up @@ -556,7 +556,7 @@ subroutine get_harvestable_carbon (csite, site_area, hlm_harvest_catnames, harve
harvestable_cohort_c = logging_direct_frac * ( sapw_m + struct_m ) * &
prt_params%allom_agb_frac(currentCohort%pft) * &
SF_val_CWD_frac(ncwd) * logging_export_frac * &
currentCohort%n * AREA_INV * site_area
currentCohort%n * area_inv * site_area

! No harvest for trees without canopy
if (currentCohort%canopy_layer>=1) then
Expand Down Expand Up @@ -795,9 +795,9 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site


!LOCAL VARIABLES:
type(fates_cohort_type), pointer :: currentCohort
type(fates_cohort_type), pointer :: currentCohort
type(site_massbal_type), pointer :: site_mass
type(site_fluxdiags_type), pointer :: flux_diags
type(elem_diag_type), pointer :: elflux_diags
type(litter_type),pointer :: new_litt
type(litter_type),pointer :: cur_litt

Expand Down Expand Up @@ -855,12 +855,12 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site


do el = 1,num_elements

element_id = element_list(el)
site_mass => currentSite%mass_balance(el)
flux_diags=> currentSite%flux_diags(el)
elflux_diags=> currentSite%flux_diags%elem(el)
cur_litt => currentPatch%litter(el) ! Litter pool of "current" patch
new_litt => newPatch%litter(el) ! Litter pool of "new" patch
new_litt => newPatch%litter(el) ! Litter pool of "new" patch

! Zero some site level accumulator diagnsotics
trunk_product_site = 0.0_r8
Expand Down Expand Up @@ -958,10 +958,10 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site


! Diagnostics on fluxes into the AG and BG CWD pools
flux_diags%cwd_ag_input(c) = flux_diags%cwd_ag_input(c) + &
elflux_diags%cwd_ag_input(c) = elflux_diags%cwd_ag_input(c) + &
SF_val_CWD_frac_adj(c) * ag_wood

flux_diags%cwd_bg_input(c) = flux_diags%cwd_bg_input(c) + &
elflux_diags%cwd_bg_input(c) = elflux_diags%cwd_bg_input(c) + &
SF_val_CWD_frac_adj(c) * bg_wood

! Diagnostic specific to resource management code
Expand Down Expand Up @@ -999,10 +999,10 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site

end do

flux_diags%cwd_ag_input(ncwd) = flux_diags%cwd_ag_input(ncwd) + &
elflux_diags%cwd_ag_input(ncwd) = elflux_diags%cwd_ag_input(ncwd) + &
SF_val_CWD_frac_adj(ncwd) * ag_wood

flux_diags%cwd_bg_input(ncwd) = flux_diags%cwd_bg_input(ncwd) + &
elflux_diags%cwd_bg_input(ncwd) = elflux_diags%cwd_bg_input(ncwd) + &
SF_val_CWD_frac_adj(ncwd) * bg_wood

if( element_id .eq. carbon12_element) then
Expand All @@ -1027,7 +1027,7 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site
retain_m2
end do

flux_diags%cwd_bg_input(ncwd) = flux_diags%cwd_bg_input(ncwd) + &
elflux_diags%cwd_bg_input(ncwd) = elflux_diags%cwd_bg_input(ncwd) + &
bg_wood

! ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1088,10 +1088,10 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site
end do

! track as diagnostic fluxes
flux_diags%leaf_litter_input(pft) = flux_diags%leaf_litter_input(pft) + &
elflux_diags%surf_fine_litter_input(pft) = elflux_diags%surf_fine_litter_input(pft) + &
leaf_litter

flux_diags%root_litter_input(pft) = flux_diags%root_litter_input(pft) + &
elflux_diags%root_litter_input(pft) = elflux_diags%root_litter_input(pft) + &
root_litter

! Logging specific diagnostics
Expand All @@ -1116,6 +1116,10 @@ subroutine logging_litter_fluxes(currentSite, currentPatch, newPatch, patch_site
currentCohort => currentCohort%taller
end do

! Amount of trunk mass exported off site [kg/m2]
elflux_diags%exported_harvest = elflux_diags%exported_harvest + &
trunk_product_site * area_inv

! Update the amount of carbon exported from the site through logging
! operations. Currently we assume only above-ground portion
! of the tree bole that experienced "direct" logging is exported
Expand Down Expand Up @@ -1166,7 +1170,6 @@ subroutine UpdateHarvestC(currentSite,bc_out)
! Harvested C flux in HLM.
! ----------------------------------------------------------------------------------
use EDtypesMod , only : ed_site_type
use EDTypesMod , only : AREA_INV
use PRTGenericMod , only : element_pos
use PRTGenericMod , only : carbon12_element
use FatesInterfaceTypesMod , only : bc_out_type
Expand All @@ -1191,20 +1194,20 @@ subroutine UpdateHarvestC(currentSite,bc_out)
do i_pft = 1,numpft
bc_out%hrv_deadstemc_to_prod10c = bc_out%hrv_deadstemc_to_prod10c + &
currentSite%mass_balance(element_pos(carbon12_element))%wood_product_harvest(i_pft) * &
AREA_INV * EDPftvarcon_inst%harvest_pprod10(i_pft) * unit_trans_factor
area_inv * EDPftvarcon_inst%harvest_pprod10(i_pft) * unit_trans_factor
bc_out%hrv_deadstemc_to_prod100c = bc_out%hrv_deadstemc_to_prod100c + &
currentSite%mass_balance(element_pos(carbon12_element))%wood_product_harvest(i_pft) * &
AREA_INV * (1._r8 - EDPftvarcon_inst%harvest_pprod10(i_pft)) * unit_trans_factor
area_inv * (1._r8 - EDPftvarcon_inst%harvest_pprod10(i_pft)) * unit_trans_factor
end do

! land-use-change-associated wood product pools
do i_pft = 1,numpft
bc_out%hrv_deadstemc_to_prod10c = bc_out%hrv_deadstemc_to_prod10c + &
currentSite%mass_balance(element_pos(carbon12_element))%wood_product_landusechange(i_pft) * &
AREA_INV * EDPftvarcon_inst%landusechange_pprod10(i_pft) * unit_trans_factor
area_inv * EDPftvarcon_inst%landusechange_pprod10(i_pft) * unit_trans_factor
bc_out%hrv_deadstemc_to_prod100c = bc_out%hrv_deadstemc_to_prod100c + &
currentSite%mass_balance(element_pos(carbon12_element))%wood_product_landusechange(i_pft) * &
AREA_INV * (1._r8 - EDPftvarcon_inst%landusechange_pprod10(i_pft)) * unit_trans_factor
area_inv * (1._r8 - EDPftvarcon_inst%landusechange_pprod10(i_pft)) * unit_trans_factor
end do

return
Expand Down
Loading

0 comments on commit f5bd625

Please sign in to comment.