Skip to content

Commit 03186af

Browse files
authored
Merge pull request #246 from ckoven/koven-biomasstendency_merge
Bugfix on tendency terms and a few new vars
2 parents ed915ea + 7301abf commit 03186af

File tree

3 files changed

+100
-8
lines changed

3 files changed

+100
-8
lines changed

biogeochem/EDCohortDynamicsMod.F90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,12 @@ subroutine fuse_cohorts(patchptr, bc_in)
860860
currentCohort%npp_bseed = (currentCohort%n*currentCohort%npp_bseed + nextc%n*nextc%npp_bseed)/newn
861861
currentCohort%npp_store = (currentCohort%n*currentCohort%npp_store + nextc%n*nextc%npp_store)/newn
862862

863+
! biomass and dbh tendencies
864+
currentCohort%ddbhdt = (currentCohort%n*currentCohort%ddbhdt + nextc%n*nextc%ddbhdt)/newn
865+
currentCohort%dbalivedt = (currentCohort%n*currentCohort%dbalivedt + nextc%n*nextc%dbalivedt)/newn
866+
currentCohort%dbdeaddt = (currentCohort%n*currentCohort%dbdeaddt + nextc%n*nextc%dbdeaddt)/newn
867+
currentCohort%dbstoredt = (currentCohort%n*currentCohort%dbstoredt + nextc%n*nextc%dbstoredt)/newn
868+
863869
do i=1, nlevleaf
864870
if (currentCohort%year_net_uptake(i) == 999._r8 .or. nextc%year_net_uptake(i) == 999._r8) then
865871
currentCohort%year_net_uptake(i) = &
@@ -1242,6 +1248,10 @@ subroutine copy_cohort( currentCohort,copyc )
12421248

12431249
if( use_fates_plant_hydro ) call CopyCohortHydraulics(n,o)
12441250

1251+
! indices for binning
1252+
n%size_class = o%size_class
1253+
n%size_by_pft_class = o%size_by_pft_class
1254+
12451255
!Pointers
12461256
n%taller => NULL() ! pointer to next tallest cohort
12471257
n%shorter => NULL() ! pointer to next shorter cohort

main/EDTypesMod.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module EDTypesMod
1111
save
1212

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

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

26+
integer, parameter :: maxCohortsPerPatch = nclmax * numpft_ed * nlevleaf ! maximum number of cohorts to live on a patch
27+
2728
! TODO: we use this cp_maxSWb only because we have a static array q(size=2) of
2829
! land-ice abledo for vis and nir. This should be a parameter, which would
2930
! get us on track to start using multi-spectral or hyper-spectral (RGK 02-2017)

main/FatesHistoryInterfaceMod.F90

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ module FatesHistoryInterfaceMod
8282

8383
! Indices to site by size-class by pft variables
8484
integer, private :: ih_nplant_si_scag
85+
integer, private :: ih_nplant_canopy_si_scag
86+
integer, private :: ih_nplant_understory_si_scag
87+
integer, private :: ih_ddbh_canopy_si_scag
88+
integer, private :: ih_ddbh_understory_si_scag
89+
integer, private :: ih_mortality_canopy_si_scag
90+
integer, private :: ih_mortality_understory_si_scag
8591

8692
! Indices to (site) variables
8793
integer, private :: ih_nep_si
@@ -169,6 +175,8 @@ module FatesHistoryInterfaceMod
169175
integer, private :: ih_trimming_understory_si_scls
170176
integer, private :: ih_crown_area_canopy_si_scls
171177
integer, private :: ih_crown_area_understory_si_scls
178+
integer, private :: ih_ddbh_canopy_si_scls
179+
integer, private :: ih_ddbh_understory_si_scls
172180

173181
! lots of non-default diagnostics for understanding canopy versus understory carbon balances
174182
integer, private :: ih_rdark_canopy_si_scls
@@ -1186,6 +1194,8 @@ subroutine update_history_dyn(this,nc,nsites,sites)
11861194
hio_nplant_understory_si_scpf => this%hvars(ih_nplant_understory_si_scpf)%r82d, &
11871195
hio_ddbh_canopy_si_scpf => this%hvars(ih_ddbh_canopy_si_scpf)%r82d, &
11881196
hio_ddbh_understory_si_scpf => this%hvars(ih_ddbh_understory_si_scpf)%r82d, &
1197+
hio_ddbh_canopy_si_scls => this%hvars(ih_ddbh_canopy_si_scls)%r82d, &
1198+
hio_ddbh_understory_si_scls => this%hvars(ih_ddbh_understory_si_scls)%r82d, &
11891199
hio_gpp_canopy_si_scpf => this%hvars(ih_gpp_canopy_si_scpf)%r82d, &
11901200
hio_gpp_understory_si_scpf => this%hvars(ih_gpp_understory_si_scpf)%r82d, &
11911201
hio_ar_canopy_si_scpf => this%hvars(ih_ar_canopy_si_scpf)%r82d, &
@@ -1258,7 +1268,13 @@ subroutine update_history_dyn(this,nc,nsites,sites)
12581268
hio_cwd_bg_out_si_cwdsc => this%hvars(ih_cwd_bg_out_si_cwdsc)%r82d, &
12591269
hio_crownarea_si_cnlf => this%hvars(ih_crownarea_si_cnlf)%r82d, &
12601270
hio_crownarea_si_can => this%hvars(ih_crownarea_si_can)%r82d, &
1261-
hio_nplant_si_scag => this%hvars(ih_nplant_si_scag)%r82d)
1271+
hio_nplant_si_scag => this%hvars(ih_nplant_si_scag)%r82d, &
1272+
hio_nplant_canopy_si_scag => this%hvars(ih_nplant_canopy_si_scag)%r82d, &
1273+
hio_nplant_understory_si_scag => this%hvars(ih_nplant_understory_si_scag)%r82d, &
1274+
hio_ddbh_canopy_si_scag => this%hvars(ih_ddbh_canopy_si_scag)%r82d, &
1275+
hio_ddbh_understory_si_scag => this%hvars(ih_ddbh_understory_si_scag)%r82d, &
1276+
hio_mortality_canopy_si_scag => this%hvars(ih_mortality_canopy_si_scag)%r82d, &
1277+
hio_mortality_understory_si_scag => this%hvars(ih_mortality_understory_si_scag)%r82d)
12621278

12631279

12641280
! ---------------------------------------------------------------------------------
@@ -1450,13 +1466,18 @@ subroutine update_history_dyn(this,nc,nsites,sites)
14501466

14511467
! update SCPF/SCLS- and canopy/subcanopy- partitioned quantities
14521468
if (ccohort%canopy_layer .eq. 1) then
1469+
hio_nplant_canopy_si_scag(io_si,iscag) = hio_nplant_canopy_si_scag(io_si,iscag) + ccohort%n
1470+
hio_mortality_canopy_si_scag(io_si,iscag) = hio_mortality_canopy_si_scag(io_si,iscag) + &
1471+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
1472+
hio_ddbh_canopy_si_scag(io_si,iscag) = hio_ddbh_canopy_si_scag(io_si,iscag) + &
1473+
ccohort%ddbhdt*ccohort%n
14531474
hio_bstor_canopy_si_scpf(io_si,scpf) = hio_bstor_canopy_si_scpf(io_si,scpf) + &
14541475
ccohort%bstore * ccohort%n
14551476
hio_bleaf_canopy_si_scpf(io_si,scpf) = hio_bleaf_canopy_si_scpf(io_si,scpf) + &
14561477
ccohort%bl * ccohort%n
14571478
hio_canopy_biomass_pa(io_pa) = hio_canopy_biomass_pa(io_pa) + n_density * ccohort%b * g_per_kg
14581479
hio_mortality_canopy_si_scpf(io_si,scpf) = hio_mortality_canopy_si_scpf(io_si,scpf)+ &
1459-
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
1480+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
14601481
hio_nplant_canopy_si_scpf(io_si,scpf) = hio_nplant_canopy_si_scpf(io_si,scpf) + ccohort%n
14611482
hio_nplant_canopy_si_scls(io_si,scls) = hio_nplant_canopy_si_scls(io_si,scls) + ccohort%n
14621483
hio_trimming_canopy_si_scls(io_si,scls) = hio_trimming_canopy_si_scls(io_si,scls) + &
@@ -1470,11 +1491,13 @@ subroutine update_history_dyn(this,nc,nsites,sites)
14701491
! growth increment
14711492
hio_ddbh_canopy_si_scpf(io_si,scpf) = hio_ddbh_canopy_si_scpf(io_si,scpf) + &
14721493
ccohort%ddbhdt*ccohort%n
1494+
hio_ddbh_canopy_si_scls(io_si,scls) = hio_ddbh_canopy_si_scls(io_si,scls) + &
1495+
ccohort%ddbhdt*ccohort%n
14731496
! sum of all mortality
14741497
hio_mortality_canopy_si_scls(io_si,scls) = hio_mortality_canopy_si_scls(io_si,scls) + &
1475-
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
1498+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
14761499
hio_canopy_mortality_carbonflux_si(io_si) = hio_canopy_mortality_carbonflux_si(io_si) + &
1477-
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * &
1500+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * &
14781501
ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2
14791502
!
14801503
hio_leaf_md_canopy_si_scls(io_si,scls) = hio_leaf_md_canopy_si_scls(io_si,scls) + &
@@ -1509,13 +1532,18 @@ subroutine update_history_dyn(this,nc,nsites,sites)
15091532
hio_yesterdaycanopylevel_canopy_si_scls(io_si,scls) + &
15101533
ccohort%canopy_layer_yesterday * ccohort%n
15111534
else
1535+
hio_nplant_understory_si_scag(io_si,iscag) = hio_nplant_understory_si_scag(io_si,iscag) + ccohort%n
1536+
hio_mortality_understory_si_scag(io_si,iscag) = hio_mortality_understory_si_scag(io_si,iscag) + &
1537+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
1538+
hio_ddbh_understory_si_scag(io_si,iscag) = hio_ddbh_understory_si_scag(io_si,iscag) + &
1539+
ccohort%ddbhdt*ccohort%n
15121540
hio_bstor_understory_si_scpf(io_si,scpf) = hio_bstor_understory_si_scpf(io_si,scpf) + &
15131541
ccohort%bstore * ccohort%n
15141542
hio_bleaf_understory_si_scpf(io_si,scpf) = hio_bleaf_understory_si_scpf(io_si,scpf) + &
15151543
ccohort%bl * ccohort%n
15161544
hio_understory_biomass_pa(io_pa) = hio_understory_biomass_pa(io_pa) + n_density * ccohort%b * g_per_kg
15171545
hio_mortality_understory_si_scpf(io_si,scpf) = hio_mortality_understory_si_scpf(io_si,scpf)+ &
1518-
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
1546+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
15191547
hio_nplant_understory_si_scpf(io_si,scpf) = hio_nplant_understory_si_scpf(io_si,scpf) + ccohort%n
15201548
hio_nplant_understory_si_scls(io_si,scls) = hio_nplant_understory_si_scls(io_si,scls) + ccohort%n
15211549
hio_trimming_understory_si_scls(io_si,scls) = hio_trimming_understory_si_scls(io_si,scls) + &
@@ -1529,11 +1557,13 @@ subroutine update_history_dyn(this,nc,nsites,sites)
15291557
! growth increment
15301558
hio_ddbh_understory_si_scpf(io_si,scpf) = hio_ddbh_understory_si_scpf(io_si,scpf) + &
15311559
ccohort%ddbhdt*ccohort%n
1560+
hio_ddbh_understory_si_scls(io_si,scls) = hio_ddbh_understory_si_scls(io_si,scls) + &
1561+
ccohort%ddbhdt*ccohort%n
15321562
! sum of all mortality
15331563
hio_mortality_understory_si_scls(io_si,scls) = hio_mortality_understory_si_scls(io_si,scls) + &
1534-
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * ccohort%n
1564+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * ccohort%n
15351565
hio_understory_mortality_carbonflux_si(io_si) = hio_understory_mortality_carbonflux_si(io_si) + &
1536-
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%imort + ccohort%fmort) * &
1566+
(ccohort%bmort + ccohort%hmort + ccohort%cmort + ccohort%fmort) * &
15371567
ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2
15381568
!
15391569
hio_leaf_md_understory_si_scls(io_si,scls) = hio_leaf_md_understory_si_scls(io_si,scls) + &
@@ -1569,6 +1599,17 @@ subroutine update_history_dyn(this,nc,nsites,sites)
15691599
ccohort%canopy_layer_yesterday * ccohort%n
15701600
endif
15711601
!
1602+
! consider imort as understory mortality even if it happens in cohorts that may have been promoted as part of the patch creation...
1603+
hio_mortality_understory_si_scpf(io_si,scpf) = hio_mortality_understory_si_scpf(io_si,scpf)+ &
1604+
(ccohort%imort) * ccohort%n
1605+
hio_mortality_understory_si_scls(io_si,scls) = hio_mortality_understory_si_scls(io_si,scls) + &
1606+
(ccohort%imort) * ccohort%n
1607+
hio_understory_mortality_carbonflux_si(io_si) = hio_understory_mortality_carbonflux_si(io_si) + &
1608+
(ccohort%imort) * &
1609+
ccohort%b * ccohort%n * g_per_kg * days_per_sec * years_per_day * ha_per_m2
1610+
hio_mortality_understory_si_scag(io_si,iscag) = hio_mortality_understory_si_scag(io_si,iscag) + &
1611+
(ccohort%imort) * ccohort%n
1612+
!
15721613
ccohort%canopy_layer_yesterday = real(ccohort%canopy_layer, r8)
15731614

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

2956+
call this%set_history_var(vname='NPLANT_CANOPY_SCAG',units = 'plants/ha', &
2957+
long='number of plants per hectare in canopy in each size x age class', use_default='inactive', &
2958+
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
2959+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_nplant_canopy_si_scag )
2960+
2961+
call this%set_history_var(vname='NPLANT_UNDERSTORY_SCAG',units = 'plants/ha', &
2962+
long='number of plants per hectare in understory in each size x age class', use_default='inactive', &
2963+
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
2964+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_nplant_understory_si_scag )
2965+
2966+
call this%set_history_var(vname='DDBH_CANOPY_SCAG',units = 'cm/yr/ha', &
2967+
long='growth rate of canopy plantsnumber of plants per hectare in canopy in each size x age class', use_default='inactive', &
2968+
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
2969+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_canopy_si_scag )
2970+
2971+
call this%set_history_var(vname='DDBH_UNDERSTORY_SCAG',units = 'cm/yr/ha', &
2972+
long='growth rate of understory plants in each size x age class', use_default='inactive', &
2973+
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
2974+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_understory_si_scag )
2975+
2976+
call this%set_history_var(vname='MORTALITY_CANOPY_SCAG',units = 'plants/ha/yr', &
2977+
long='mortality rate of canopy plants in each size x age class', use_default='inactive', &
2978+
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
2979+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_mortality_canopy_si_scag )
2980+
2981+
call this%set_history_var(vname='MORTALITY_UNDERSTORY_SCAG',units = 'plants/ha/yr', &
2982+
long='mortality rate of understory plantsin each size x age class', use_default='inactive', &
2983+
avgflag='A', vtype=site_scag_r8, hlms='CLM:ALM', flushval=0.0_r8, &
2984+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_mortality_understory_si_scag )
2985+
29152986

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

31533224
! size-class only variables
31543225

3226+
call this%set_history_var(vname='DDBH_CANOPY_SCLS', units = 'cm/yr/ha', &
3227+
long='diameter growth increment by pft/size',use_default='inactive', &
3228+
avgflag='A', vtype=site_size_r8, hlms='CLM:ALM', flushval=0.0_r8, &
3229+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_canopy_si_scls )
3230+
3231+
call this%set_history_var(vname='DDBH_UNDERSTORY_SCLS', units = 'cm/yr/ha', &
3232+
long='diameter growth increment by pft/size',use_default='inactive', &
3233+
avgflag='A', vtype=site_size_r8, hlms='CLM:ALM', flushval=0.0_r8, &
3234+
upfreq=1, ivar=ivar, initialize=initialize_variables, index = ih_ddbh_understory_si_scls )
3235+
31553236
call this%set_history_var(vname='YESTERDAYCANLEV_CANOPY_SCLS', units = 'indiv/ha', &
31563237
long='Yesterdays canopy level for canopy plants by size class', use_default='inactive', &
31573238
avgflag='A', vtype=site_size_r8, hlms='CLM:ALM', flushval=0.0_r8, &

0 commit comments

Comments
 (0)