Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Merge pull request #6 from rgknox/yi-logging-v4
Browse files Browse the repository at this point in the history
more revisions on logging mortality
  • Loading branch information
xuyi02 authored Sep 22, 2017
2 parents baa6eb6 + 84ab4d6 commit e1fe601
Show file tree
Hide file tree
Showing 8 changed files with 727 additions and 516 deletions.
19 changes: 18 additions & 1 deletion biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ subroutine nan_cohort(cc_p)
currentCohort%root_md = nan ! root maintenance demand: kgC/indiv/year
currentCohort%carbon_balance = nan ! carbon remaining for growth and storage: kg/indiv/year
currentCohort%dmort = nan ! proportional mortality rate. (year-1)
currentCohort%lmort_logging = nan
currentCohort%lmort_infra = nan
currentCohort%lmort_collateral = nan


currentCohort%seed_prod = nan ! reproduction seed and clonal: KgC/indiv/year
currentCohort%c_area = nan ! areal extent of canopy (m2)
currentCohort%treelai = nan ! lai of tree (total leaf area (m2) / canopy area (m2)
Expand Down Expand Up @@ -489,7 +494,9 @@ subroutine zero_cohort(cc_p)
currentcohort%dmort = 0._r8
currentcohort%gscan = 0._r8
currentcohort%treesai = 0._r8

currentCohort%lmort_logging = 0._r8
currentCohort%lmort_infra = 0._r8
currentCohort%lmort_collateral = 0._r8
! currentCohort%npp_leaf = 0._r8
! currentCohort%npp_froot = 0._r8
! currentCohort%npp_bsw = 0._r8
Expand Down Expand Up @@ -840,6 +847,13 @@ subroutine fuse_cohorts(patchptr, bc_in)

currentCohort%dmort = (currentCohort%n*currentCohort%dmort + &
nextc%n*nextc%dmort)/newn
currentCohort%lmort_logging = (currentCohort%n*currentCohort%lmort_logging + &
nextc%n*nextc%lmort_logging)/newn
currentCohort%lmort_infra = (currentCohort%n*currentCohort%lmort_infra + &
nextc%n*nextc%lmort_infra)/newn
currentCohort%lmort_collateral = (currentCohort%n*currentCohort%lmort_collateral + &
nextc%n*nextc%lmort_collateral)/newn

currentCohort%fire_mort = (currentCohort%n*currentCohort%fire_mort + &
nextc%n*nextc%fire_mort)/newn
currentCohort%leaf_litter = (currentCohort%n*currentCohort%leaf_litter + &
Expand Down Expand Up @@ -1218,6 +1232,9 @@ subroutine copy_cohort( currentCohort,copyc )
n%root_md = o%root_md
n%carbon_balance = o%carbon_balance
n%dmort = o%dmort
n%lmort_logging = o%lmort_logging
n%lmort_infra = o%lmort_infra
n%lmort_collateral= o%lmort_collateral
n%seed_prod = o%seed_prod
n%treelai = o%treelai
n%treesai = o%treesai
Expand Down
456 changes: 237 additions & 219 deletions biogeochem/EDLoggingMortalityMod.F90

Large diffs are not rendered by default.

457 changes: 227 additions & 230 deletions biogeochem/EDPatchDynamicsMod.F90

Large diffs are not rendered by default.

119 changes: 105 additions & 14 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ subroutine non_canopy_derivs( currentSite, currentPatch, bc_in )
call seed_germination(currentSite, currentPatch)

! update fragmenting pool fluxes
call cwd_input(currentPatch)
call cwd_input( currentSite, currentPatch)
call cwd_out( currentSite, currentPatch, bc_in)

do p = 1,numpft
Expand Down Expand Up @@ -761,6 +761,7 @@ subroutine Growth_Derivatives( currentSite, currentCohort, bc_in)
!
! !USES:
use EDGrowthFunctionsMod , only : Bleaf, dDbhdBd, dhdbd, hite, mortality_rates,dDbhdBl
use EDLoggingMortalityMod, only : LoggingMortality_frac

!
! !ARGUMENTS
Expand All @@ -783,14 +784,31 @@ subroutine Growth_Derivatives( currentSite, currentCohort, bc_in)
real(r8) :: cmort ! starvation mortality rate (fraction per year)
real(r8) :: bmort ! background mortality rate (fraction per year)
real(r8) :: hmort ! hydraulic failure mortality rate (fraction per year)

real(r8) :: lmort_logging ! Mortality fraction associated with direct logging
real(r8) :: lmort_collateral ! Mortality fraction associated with logging collateral damage
real(r8) :: lmort_infra ! Mortality fraction associated with logging infrastructure
real(r8) :: dndt_logging ! Mortality rate (per day) associated with the a logging event

real(r8) :: balive_loss
!----------------------------------------------------------------------

! Mortality for trees in the understorey.
!if trees are in the canopy, then their death is 'disturbance'. This probably needs a different terminology
call mortality_rates(currentCohort,cmort,hmort,bmort)
call LoggingMortality_frac(currentCohort%pft, currentCohort%dbh, &
currentCohort%lmort_logging, &
currentCohort%lmort_collateral, &
currentCohort%lmort_infra )

if (currentCohort%canopy_layer > 1)then
currentCohort%dndt = -1.0_r8 * (cmort+hmort+bmort) * currentCohort%n

! Include understory logging mortality rates not associated with disturbance
dndt_logging = (currentCohort%lmort_logging + &
currentCohort%lmort_collateral + &
currentCohort%lmort_infra)/hlm_freq_day

currentCohort%dndt = -1.0_r8 * (cmort+hmort+bmort+dndt_logging) * currentCohort%n
else
currentCohort%dndt = -(1.0_r8 - fates_mortality_disturbance_fraction) &
* (cmort+hmort+bmort) * currentCohort%n
Expand All @@ -814,7 +832,7 @@ subroutine Growth_Derivatives( currentSite, currentCohort, bc_in)
! NPP
if ( DEBUG ) write(fates_log(),*) 'EDphys 716 ',currentCohort%npp_acc

! convert from kgC/indiv/day into kgC/indiv/year
! convert from kgC/indiv/day into kgC/indiv/year
! TODO: CONVERT DAYS_PER_YEAR TO DBLE (HOLDING FOR B4B COMPARISONS, RGK-01-2017)
currentCohort%npp_acc_hold = currentCohort%npp_acc * hlm_days_per_year
currentCohort%gpp_acc_hold = currentCohort%gpp_acc * hlm_days_per_year
Expand Down Expand Up @@ -1091,7 +1109,7 @@ subroutine recruitment( t, currentSite, currentPatch, bc_in )
end subroutine recruitment

! ============================================================================
subroutine CWD_Input( currentPatch)
subroutine CWD_Input( currentSite, currentPatch)
!
! !DESCRIPTION:
! Generate litter fields from turnover.
Expand All @@ -1101,13 +1119,18 @@ subroutine CWD_Input( currentPatch)

!
! !ARGUMENTS
type(ed_site_type), intent(inout), target :: currentSite
type(ed_patch_type),intent(inout), target :: currentPatch
!
! !LOCAL VARIABLES:
type(ed_cohort_type), pointer :: currentCohort
integer :: c,p
real(r8) :: not_dead_n !projected remaining number of trees in understorey cohort after turnover
real(r8) :: dead_n !understorey dead tree density
real(r8) :: dead_n ! total understorey dead tree density
real(r8) :: dead_n_dlogging ! direct logging understory dead-tree density
real(r8) :: dead_n_ilogging ! indirect understory dead-tree density (logging)
real(r8) :: dead_n_natural ! understory dead density not associated
! with direct logging
real(r8) :: trunk_product ! carbon flux into trunk products kgC/day/site
integer :: pft
!----------------------------------------------------------------------

Expand Down Expand Up @@ -1144,29 +1167,97 @@ subroutine CWD_Input( currentPatch)
! ================================================
! Litter fluxes for understorey mortality. KgC/m2/year
! ================================================

! Total number of dead understory (n/m2)
dead_n = -1.0_r8 * currentCohort%dndt / currentPatch%area

! Total number of dead understory from direct logging
! (it is possible that large harvestable trees are in the understory)
dead_n_dlogging = ( currentCohort%lmort_logging) * &
currentCohort%n/hlm_freq_day/currentPatch%area

! Total number of dead understory from indirect logging
dead_n_ilogging = ( currentCohort%lmort_collateral + currentCohort%lmort_infra) * &
currentCohort%n/hlm_freq_day/currentPatch%area

dead_n_natural = dead_n - dead_n_dlogging - dead_n_ilogging

currentPatch%leaf_litter_in(pft) = currentPatch%leaf_litter_in(pft) + &
(currentCohort%bl+currentCohort%leaf_litter/hlm_freq_day)* dead_n
currentPatch%root_litter_in(pft) = currentPatch%root_litter_in(pft) + &
(currentCohort%br+currentCohort%bstore) * dead_n
(currentCohort%br+currentCohort%bstore) * dead_n

! Update diagnostics that track resource management
currentSite%resources_management%delta_litter_stock = &
currentSite%resources_management%delta_litter_stock + &
(currentCohort%bl+currentCohort%br+currentCohort%bstore) * &
(dead_n_ilogging+dead_n_dlogging) * &
hlm_freq_day * currentPatch%area
! Update diagnostics that track resource management
currentSite%resources_management%delta_biomass_stock = &
currentSite%resources_management%delta_biomass_stock + &
(currentCohort%bl+currentCohort%br+currentCohort%bstore) * &
(dead_n_ilogging+dead_n_dlogging) * &
hlm_freq_day * currentPatch%area

do c = 1,ncwd
currentPatch%cwd_AG_in(c) = currentPatch%cwd_AG_in(c) + (currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * dead_n * EDPftvarcon_inst%allom_agb_frac(currentCohort%pft)

currentPatch%cwd_BG_in(c) = currentPatch%cwd_BG_in(c) + (currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * dead_n * (1.0_r8-EDPftvarcon_inst%allom_agb_frac(currentCohort%pft))
SF_val_CWD_frac(c) * dead_n * (1.0_r8-EDPftvarcon_inst%allom_agb_frac(currentCohort%pft))

! Send AGB component of boles from non direct-logging activities to AGB litter pool
if (c==ncwd) then
currentPatch%cwd_AG_in(c) = currentPatch%cwd_AG_in(c) + (currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * (dead_n_natural+dead_n_ilogging) * &
EDPftvarcon_inst%allom_agb_frac(currentCohort%pft)


else
! Send AGB component of boles from direct-logging activities to export/harvest pool
! Generate trunk product (kgC/day/site)
trunk_product = (currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * dead_n_dlogging * EDPftvarcon_inst%allom_agb_frac(currentCohort%pft) * &
hlm_freq_day * currentPatch%area

currentSite%flux_out = currentSite%flux_out + trunk_product

! Update diagnostics that track resource management
currentSite%resources_management%trunk_product_site = &
currentSite%resources_management%trunk_product_site + &
trunk_product
! Update diagnostics that track resource management
currentSite%resources_management%trunk_product_site = &
currentSite%resources_management%trunk_product_site + &
trunk_product
end if

! Update diagnostics that track resource management
currentSite%resources_management%delta_litter_stock = &
currentSite%resources_management%delta_litter_stock + &
(currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * (dead_n_natural+dead_n_ilogging) * &
hlm_freq_day * currentPatch%area
! Update diagnostics that track resource management
currentSite%resources_management%delta_biomass_stock = &
currentSite%resources_management%delta_biomass_stock + &
(currentCohort%bdead+currentCohort%bsw) * &
SF_val_CWD_frac(c) * dead_n * &
hlm_freq_day * currentPatch%area

if (currentPatch%cwd_AG_in(c) < 0.0_r8)then
write(fates_log(),*) 'negative CWD in flux',currentPatch%cwd_AG_in(c), &
(currentCohort%bdead+currentCohort%bsw), dead_n
(currentCohort%bdead+currentCohort%bsw), dead_n
endif
enddo

end do
! Update diagnostics that track resource management
currentSite%resources_management%delta_individual = &
currentSite%resources_management%delta_individual + &
(dead_n_dlogging+dead_n_ilogging) * hlm_freq_day * currentPatch%area

endif !canopy layer

currentCohort => currentCohort%taller

enddo ! end loop over cohorts

do p = 1,numpft
Expand Down
50 changes: 47 additions & 3 deletions main/ChecksBalancesMod.F90
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
module ChecksBalancesMod

use shr_kind_mod , only : r8 => shr_kind_r8
use shr_kind_mod , only : r8 => shr_kind_r8
use shr_const_mod, only: SHR_CONST_CDAY

use EDtypesMod , only : ed_site_type,ed_patch_type,ed_cohort_type
use EDTypesMod , only : AREA

implicit none

private
public :: SummarizeNetFluxes
public :: FATES_BGC_Carbon_Balancecheck
public :: SiteCarbonStock

contains

Expand All @@ -24,7 +27,7 @@ subroutine SummarizeNetFluxes( nsites, sites, bc_in, is_beg_day )
!
! !USES:
use FatesInterfaceMod , only : bc_in_type
use EDtypesMod , only : ed_site_type,ed_patch_type,ed_cohort_type

use EDtypesMod , only : AREA
!
implicit none
Expand Down Expand Up @@ -234,5 +237,46 @@ subroutine FATES_BGC_Carbon_Balancecheck(nsites, sites, bc_in, is_beg_day, dtime
return
end subroutine FATES_BGC_Carbon_Balancecheck

! ==============================================================================================

subroutine SiteCarbonStock(currentSite,total_stock,biomass_stock,litter_stock,seed_stock)

type(ed_site_type),intent(inout),target :: currentSite
real(r8),intent(out) :: total_stock
real(r8),intent(out) :: litter_stock
real(r8),intent(out) :: biomass_stock
real(r8),intent(out) :: seed_stock

type(ed_patch_type), pointer :: currentPatch
type(ed_cohort_type), pointer :: currentCohort

litter_stock = 0.0_r8
biomass_stock = 0.0_r8
seed_stock = sum(currentSite%seed_bank)*AREA

currentPatch => currentSite%oldest_patch
do while(associated(currentPatch))
litter_stock = litter_stock + currentPatch%area * &
(sum(currentPatch%cwd_ag) + &
sum(currentPatch%cwd_bg) + &
sum(currentPatch%leaf_litter) + &
sum(currentPatch%root_litter))

currentCohort => currentPatch%tallest
do while(associated(currentCohort))
biomass_stock = biomass_stock + (currentCohort%bdead + currentCohort%balive + &
currentCohort%bstore) * currentCohort%n
currentCohort => currentCohort%shorter
enddo !end cohort loop
currentPatch => currentPatch%younger
enddo !end patch loop

total_stock = biomass_stock + seed_stock + litter_stock

return
end subroutine SiteCarbonStock




end module ChecksBalancesMod
28 changes: 23 additions & 5 deletions main/EDInitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ module EDInitMod
use EDGrowthFunctionsMod , only : bdead, bleaf, dbh
use EDCohortDynamicsMod , only : create_cohort, fuse_cohorts, sort_cohorts
use EDPatchDynamicsMod , only : create_patch
use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type, area
use EDTypesMod , only : ed_site_type, ed_patch_type, ed_cohort_type
use EDTypesMod , only : ncwd
use EDTypesMod , only : nuMWaterMem
use EDTypesMod , only : maxpft
use EDTypesMod , only : AREA
use FatesInterfaceMod , only : bc_in_type
use FatesInterfaceMod , only : hlm_use_planthydro
use FatesInterfaceMod , only : hlm_use_inventory_init
use FatesInterfaceMod , only : numpft
use ChecksBalancesMod , only : SiteCarbonStock

! CIME GLOBALS
use shr_log_mod , only : errMsg => shr_log_errMsg
Expand Down Expand Up @@ -63,9 +65,7 @@ subroutine zero_site( site_in )
site_in%youngest_patch => null() ! pointer to yngest patch at the site

! DISTURBANCE
site_in%disturbance_rate = 0._r8 ! site level disturbance rates from mortality and fire.
site_in%dist_type = 0 ! disturbance dist_type id.
site_in%total_burn_flux_to_atm = 0._r8 !
site_in%total_burn_flux_to_atm = 0._r8

! PHENOLOGY
site_in%status = 0 ! are leaves in this pixel on or off?
Expand Down Expand Up @@ -222,6 +222,12 @@ subroutine init_patches( nsites, sites, bc_in)
real(r8) :: leaf_litter_local(maxpft)
real(r8) :: root_litter_local(maxpft)
real(r8) :: age !notional age of this patch

! dummy locals
real(r8) :: biomass_stock
real(r8) :: litter_stock
real(r8) :: seed_stock

type(ed_patch_type), pointer :: newp

! List out some nominal patch values that are used for Near Bear Ground initializations
Expand All @@ -247,8 +253,12 @@ subroutine init_patches( nsites, sites, bc_in)
if (hlm_use_planthydro.eq.itrue) then
call updateSizeDepRhizHydProps(sites(s), bc_in(s))
end if
! For carbon balance checks, we need to initialize the
! total carbon stock
call SiteCarbonStock(sites(s),sites(s)%old_stock,biomass_stock,litter_stock,seed_stock)

enddo

else

!FIX(SPM,032414) clean this up...inits out of this loop
Expand Down Expand Up @@ -278,6 +288,11 @@ subroutine init_patches( nsites, sites, bc_in)
call updateSizeDepRhizHydProps(sites(s), bc_in(s))
end if


! For carbon balance checks, we need to initialize the
! total carbon stock
call SiteCarbonStock(sites(s),sites(s)%old_stock,biomass_stock,litter_stock,seed_stock)

enddo

end if
Expand Down Expand Up @@ -365,4 +380,7 @@ subroutine init_cohorts( patch_in, bc_in)

end subroutine init_cohorts

! ===============================================================================================


end module EDInitMod
Loading

0 comments on commit e1fe601

Please sign in to comment.