Skip to content

Commit

Permalink
Merge pull request #246 from ckoven/koven-biomasstendency_merge
Browse files Browse the repository at this point in the history
Bugfix on tendency terms and a few new vars
  • Loading branch information
rgknox authored Jul 24, 2017
2 parents ed915ea + 7301abf commit 03186af
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 8 deletions.
10 changes: 10 additions & 0 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,12 @@ subroutine fuse_cohorts(patchptr, bc_in)
currentCohort%npp_bseed = (currentCohort%n*currentCohort%npp_bseed + nextc%n*nextc%npp_bseed)/newn
currentCohort%npp_store = (currentCohort%n*currentCohort%npp_store + nextc%n*nextc%npp_store)/newn

! biomass and dbh tendencies
currentCohort%ddbhdt = (currentCohort%n*currentCohort%ddbhdt + nextc%n*nextc%ddbhdt)/newn
currentCohort%dbalivedt = (currentCohort%n*currentCohort%dbalivedt + nextc%n*nextc%dbalivedt)/newn
currentCohort%dbdeaddt = (currentCohort%n*currentCohort%dbdeaddt + nextc%n*nextc%dbdeaddt)/newn
currentCohort%dbstoredt = (currentCohort%n*currentCohort%dbstoredt + nextc%n*nextc%dbstoredt)/newn

do i=1, nlevleaf
if (currentCohort%year_net_uptake(i) == 999._r8 .or. nextc%year_net_uptake(i) == 999._r8) then
currentCohort%year_net_uptake(i) = &
Expand Down Expand Up @@ -1242,6 +1248,10 @@ subroutine copy_cohort( currentCohort,copyc )

if( use_fates_plant_hydro ) call CopyCohortHydraulics(n,o)

! indices for binning
n%size_class = o%size_class
n%size_by_pft_class = o%size_by_pft_class

!Pointers
n%taller => NULL() ! pointer to next tallest cohort
n%shorter => NULL() ! pointer to next shorter cohort
Expand Down
3 changes: 2 additions & 1 deletion main/EDTypesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module EDTypesMod
save

integer, parameter :: maxPatchesPerSite = 10 ! maximum number of patches to live on a site
integer, parameter :: maxCohortsPerPatch = 160 ! maximum number of cohorts to live on a patch
integer, parameter :: nclmax = 2 ! Maximum number of canopy layers
integer, parameter :: ican_upper = 1 ! Nominal index for the upper canopy
integer, parameter :: ican_ustory = 2 ! Nominal index for understory in two-canopy system
Expand All @@ -24,6 +23,8 @@ module EDTypesMod

integer, parameter :: numpft_ed = 2 ! number of PFTs used in ED.

integer, parameter :: maxCohortsPerPatch = nclmax * numpft_ed * nlevleaf ! maximum number of cohorts to live on a patch

! TODO: we use this cp_maxSWb only because we have a static array q(size=2) of
! land-ice abledo for vis and nir. This should be a parameter, which would
! get us on track to start using multi-spectral or hyper-spectral (RGK 02-2017)
Expand Down
95 changes: 88 additions & 7 deletions main/FatesHistoryInterfaceMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ module FatesHistoryInterfaceMod

! Indices to site by size-class by pft variables
integer, private :: ih_nplant_si_scag
integer, private :: ih_nplant_canopy_si_scag
integer, private :: ih_nplant_understory_si_scag
integer, private :: ih_ddbh_canopy_si_scag
integer, private :: ih_ddbh_understory_si_scag
integer, private :: ih_mortality_canopy_si_scag
integer, private :: ih_mortality_understory_si_scag

! Indices to (site) variables
integer, private :: ih_nep_si
Expand Down Expand Up @@ -169,6 +175,8 @@ module FatesHistoryInterfaceMod
integer, private :: ih_trimming_understory_si_scls
integer, private :: ih_crown_area_canopy_si_scls
integer, private :: ih_crown_area_understory_si_scls
integer, private :: ih_ddbh_canopy_si_scls
integer, private :: ih_ddbh_understory_si_scls

! lots of non-default diagnostics for understanding canopy versus understory carbon balances
integer, private :: ih_rdark_canopy_si_scls
Expand Down Expand Up @@ -1186,6 +1194,8 @@ subroutine update_history_dyn(this,nc,nsites,sites)
hio_nplant_understory_si_scpf => this%hvars(ih_nplant_understory_si_scpf)%r82d, &
hio_ddbh_canopy_si_scpf => this%hvars(ih_ddbh_canopy_si_scpf)%r82d, &
hio_ddbh_understory_si_scpf => this%hvars(ih_ddbh_understory_si_scpf)%r82d, &
hio_ddbh_canopy_si_scls => this%hvars(ih_ddbh_canopy_si_scls)%r82d, &
hio_ddbh_understory_si_scls => this%hvars(ih_ddbh_understory_si_scls)%r82d, &
hio_gpp_canopy_si_scpf => this%hvars(ih_gpp_canopy_si_scpf)%r82d, &
hio_gpp_understory_si_scpf => this%hvars(ih_gpp_understory_si_scpf)%r82d, &
hio_ar_canopy_si_scpf => this%hvars(ih_ar_canopy_si_scpf)%r82d, &
Expand Down Expand Up @@ -1258,7 +1268,13 @@ subroutine update_history_dyn(this,nc,nsites,sites)
hio_cwd_bg_out_si_cwdsc => this%hvars(ih_cwd_bg_out_si_cwdsc)%r82d, &
hio_crownarea_si_cnlf => this%hvars(ih_crownarea_si_cnlf)%r82d, &
hio_crownarea_si_can => this%hvars(ih_crownarea_si_can)%r82d, &
hio_nplant_si_scag => this%hvars(ih_nplant_si_scag)%r82d)
hio_nplant_si_scag => this%hvars(ih_nplant_si_scag)%r82d, &
hio_nplant_canopy_si_scag => this%hvars(ih_nplant_canopy_si_scag)%r82d, &
hio_nplant_understory_si_scag => this%hvars(ih_nplant_understory_si_scag)%r82d, &
hio_ddbh_canopy_si_scag => this%hvars(ih_ddbh_canopy_si_scag)%r82d, &
hio_ddbh_understory_si_scag => this%hvars(ih_ddbh_understory_si_scag)%r82d, &
hio_mortality_canopy_si_scag => this%hvars(ih_mortality_canopy_si_scag)%r82d, &
hio_mortality_understory_si_scag => this%hvars(ih_mortality_understory_si_scag)%r82d)


! ---------------------------------------------------------------------------------
Expand Down Expand Up @@ -1450,13 +1466,18 @@ subroutine update_history_dyn(this,nc,nsites,sites)

! update SCPF/SCLS- and canopy/subcanopy- partitioned quantities
if (ccohort%canopy_layer .eq. 1) then
hio_nplant_canopy_si_scag(io_si,iscag) = hio_nplant_canopy_si_scag(io_si,iscag) + ccohort%n
hio_mortality_canopy_si_scag(io_si,iscag) = hio_mortality_canopy_si_scag(io_si,iscag) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
hio_ddbh_canopy_si_scag(io_si,iscag) = hio_ddbh_canopy_si_scag(io_si,iscag) + &
ccohort%ddbhdt*ccohort%n
hio_bstor_canopy_si_scpf(io_si,scpf) = hio_bstor_canopy_si_scpf(io_si,scpf) + &
ccohort%bstore * ccohort%n
hio_bleaf_canopy_si_scpf(io_si,scpf) = hio_bleaf_canopy_si_scpf(io_si,scpf) + &
ccohort%bl * ccohort%n
hio_canopy_biomass_pa(io_pa) = hio_canopy_biomass_pa(io_pa) + n_density * ccohort%b * g_per_kg
hio_mortality_canopy_si_scpf(io_si,scpf) = hio_mortality_canopy_si_scpf(io_si,scpf)+ &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
hio_nplant_canopy_si_scpf(io_si,scpf) = hio_nplant_canopy_si_scpf(io_si,scpf) + ccohort%n
hio_nplant_canopy_si_scls(io_si,scls) = hio_nplant_canopy_si_scls(io_si,scls) + ccohort%n
hio_trimming_canopy_si_scls(io_si,scls) = hio_trimming_canopy_si_scls(io_si,scls) + &
Expand All @@ -1470,11 +1491,13 @@ subroutine update_history_dyn(this,nc,nsites,sites)
! growth increment
hio_ddbh_canopy_si_scpf(io_si,scpf) = hio_ddbh_canopy_si_scpf(io_si,scpf) + &
ccohort%ddbhdt*ccohort%n
hio_ddbh_canopy_si_scls(io_si,scls) = hio_ddbh_canopy_si_scls(io_si,scls) + &
ccohort%ddbhdt*ccohort%n
! sum of all mortality
hio_mortality_canopy_si_scls(io_si,scls) = hio_mortality_canopy_si_scls(io_si,scls) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
hio_canopy_mortality_carbonflux_si(io_si) = hio_canopy_mortality_carbonflux_si(io_si) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * &
ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2
!
hio_leaf_md_canopy_si_scls(io_si,scls) = hio_leaf_md_canopy_si_scls(io_si,scls) + &
Expand Down Expand Up @@ -1509,13 +1532,18 @@ subroutine update_history_dyn(this,nc,nsites,sites)
hio_yesterdaycanopylevel_canopy_si_scls(io_si,scls) + &
ccohort%canopy_layer_yesterday * ccohort%n
else
hio_nplant_understory_si_scag(io_si,iscag) = hio_nplant_understory_si_scag(io_si,iscag) + ccohort%n
hio_mortality_understory_si_scag(io_si,iscag) = hio_mortality_understory_si_scag(io_si,iscag) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
hio_ddbh_understory_si_scag(io_si,iscag) = hio_ddbh_understory_si_scag(io_si,iscag) + &
ccohort%ddbhdt*ccohort%n
hio_bstor_understory_si_scpf(io_si,scpf) = hio_bstor_understory_si_scpf(io_si,scpf) + &
ccohort%bstore * ccohort%n
hio_bleaf_understory_si_scpf(io_si,scpf) = hio_bleaf_understory_si_scpf(io_si,scpf) + &
ccohort%bl * ccohort%n
hio_understory_biomass_pa(io_pa) = hio_understory_biomass_pa(io_pa) + n_density * ccohort%b * g_per_kg
hio_mortality_understory_si_scpf(io_si,scpf) = hio_mortality_understory_si_scpf(io_si,scpf)+ &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
hio_nplant_understory_si_scpf(io_si,scpf) = hio_nplant_understory_si_scpf(io_si,scpf) + ccohort%n
hio_nplant_understory_si_scls(io_si,scls) = hio_nplant_understory_si_scls(io_si,scls) + ccohort%n
hio_trimming_understory_si_scls(io_si,scls) = hio_trimming_understory_si_scls(io_si,scls) + &
Expand All @@ -1529,11 +1557,13 @@ subroutine update_history_dyn(this,nc,nsites,sites)
! growth increment
hio_ddbh_understory_si_scpf(io_si,scpf) = hio_ddbh_understory_si_scpf(io_si,scpf) + &
ccohort%ddbhdt*ccohort%n
hio_ddbh_understory_si_scls(io_si,scls) = hio_ddbh_understory_si_scls(io_si,scls) + &
ccohort%ddbhdt*ccohort%n
! sum of all mortality
hio_mortality_understory_si_scls(io_si,scls) = hio_mortality_understory_si_scls(io_si,scls) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
hio_understory_mortality_carbonflux_si(io_si) = hio_understory_mortality_carbonflux_si(io_si) + &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * &
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * &
ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2
!
hio_leaf_md_understory_si_scls(io_si,scls) = hio_leaf_md_understory_si_scls(io_si,scls) + &
Expand Down Expand Up @@ -1569,6 +1599,17 @@ subroutine update_history_dyn(this,nc,nsites,sites)
ccohort%canopy_layer_yesterday * ccohort%n
endif
!
! consider imort as understory mortality even if it happens in cohorts that may have been promoted as part of the patch creation...
hio_mortality_understory_si_scpf(io_si,scpf) = hio_mortality_understory_si_scpf(io_si,scpf)+ &
(ccohort%imort) * ccohort%n
hio_mortality_understory_si_scls(io_si,scls) = hio_mortality_understory_si_scls(io_si,scls) + &
(ccohort%imort) * ccohort%n
hio_understory_mortality_carbonflux_si(io_si) = hio_understory_mortality_carbonflux_si(io_si) + &
(ccohort%imort) * &
ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2
hio_mortality_understory_si_scag(io_si,iscag) = hio_mortality_understory_si_scag(io_si,iscag) + &
(ccohort%imort) * ccohort%n
!
ccohort%canopy_layer_yesterday = real(ccohort%canopy_layer, r8)

end associate
Expand Down Expand Up @@ -2912,6 +2953,36 @@ subroutine define_history_vars(this, initialize_variables)
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_nplant_si_scag )

call this%set_history_var(vname='NPLANT_CANOPY_SCAG',units = 'plants/ha', &
long='number of plants per hectare in canopy in each size x age class', use_default='inactive', &
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_nplant_canopy_si_scag )

call this%set_history_var(vname='NPLANT_UNDERSTORY_SCAG',units = 'plants/ha', &
long='number of plants per hectare in understory in each size x age class', use_default='inactive', &
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_nplant_understory_si_scag )

call this%set_history_var(vname='DDBH_CANOPY_SCAG',units = 'cm/yr/ha', &
long='growth rate of canopy plantsnumber of plants per hectare in canopy in each size x age class', use_default='inactive', &
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_canopy_si_scag )

call this%set_history_var(vname='DDBH_UNDERSTORY_SCAG',units = 'cm/yr/ha', &
long='growth rate of understory plants in each size x age class', use_default='inactive', &
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_understory_si_scag )

call this%set_history_var(vname='MORTALITY_CANOPY_SCAG',units = 'plants/ha/yr', &
long='mortality rate of canopy plants in each size x age class', use_default='inactive', &
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_mortality_canopy_si_scag )

call this%set_history_var(vname='MORTALITY_UNDERSTORY_SCAG',units = 'plants/ha/yr', &
long='mortality rate of understory plantsin each size x age class', use_default='inactive', &
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_mortality_understory_si_scag )


! Carbon Flux (grid dimension x scpf) (THESE ARE DEFAULT INACTIVE!!!
! (BECAUSE THEY TAKE UP SPACE!!!
Expand Down Expand Up @@ -3152,6 +3223,16 @@ subroutine define_history_vars(this, initialize_variables)

! size-class only variables

call this%set_history_var(vname='DDBH_CANOPY_SCLS', units = 'cm/yr/ha', &
long='diameter growth increment by pft/size',use_default='inactive', &
avgflag='A', vtype=site_size_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_canopy_si_scls )

call this%set_history_var(vname='DDBH_UNDERSTORY_SCLS', units = 'cm/yr/ha', &
long='diameter growth increment by pft/size',use_default='inactive', &
avgflag='A', vtype=site_size_r8, hlms='CLM:ALM', flushval=0.0_r8, &
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_understory_si_scls )

call this%set_history_var(vname='YESTERDAYCANLEV_CANOPY_SCLS', units = 'indiv/ha', &
long='Yesterdays canopy level for canopy plants by size class', use_default='inactive', &
avgflag='A', vtype=site_size_r8, hlms='CLM:ALM', flushval=0.0_r8, &
Expand Down

0 comments on commit 03186af

Please sign in to comment.