@@ -8,6 +8,7 @@ module EDCohortDynamicsMod
88 use FatesGlobals , only : fates_log
99 use FatesInterfaceMod , only : hlm_freq_day
1010 use FatesInterfaceMod , only : bc_in_type
11+ use FatesInterfaceMod , only : hlm_use_planthydro
1112 use FatesConstantsMod , only : r8 = > fates_r8
1213 use FatesConstantsMod , only : fates_unset_int
1314 use FatesConstantsMod , only : itrue,ifalse
@@ -21,6 +22,7 @@ module EDCohortDynamicsMod
2122 use EDTypesMod , only : min_npm2, min_nppatch
2223 use EDTypesMod , only : min_n_safemath
2324 use EDTypesMod , only : nlevleaf
25+ use EDTypesMod , only : ican_upper
2426 use FatesInterfaceMod , only : hlm_use_planthydro
2527 use FatesInterfaceMod , only : hlm_parteh_mode
2628 use FatesPlantHydraulicsMod, only : FuseCohortHydraulics
@@ -30,6 +32,9 @@ module EDCohortDynamicsMod
3032 use FatesPlantHydraulicsMod, only : InitHydrCohort
3133 use FatesPlantHydraulicsMod, only : DeallocateHydrCohort
3234 use FatesPlantHydraulicsMod, only : AccumulateMortalityWaterStorage
35+ use FatesPlantHydraulicsMod, only : UpdateTreeHydrNodes
36+ use FatesPlantHydraulicsMod, only : UpdateTreeHydrLenVolCond
37+ use FatesPlantHydraulicsMod, only : SavePreviousCompartmentVolumes
3338 use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
3439 use FatesAllometryMod , only : bleaf
3540 use FatesAllometryMod , only : bfineroot
@@ -97,6 +102,13 @@ subroutine create_cohort(currentSite, patchptr, pft, nn, hite, dbh, bleaf, bfine
97102 !
98103 ! !DESCRIPTION:
99104 ! create new cohort
105+ ! There are 4 places this is called
106+ ! 1) Initializing new cohorts at the beginning of a cold-start simulation
107+ ! 2) Initializing new recruits during dynamics
108+ ! 3) Initializing new cohorts at the beginning of a inventory read
109+ ! 4) Initializing new cohorts during restart
110+ !
111+ ! It is assumed that in the first 3, this is called with a reasonable amount of starter information.
100112 !
101113 ! !USES:
102114 !
@@ -124,7 +136,8 @@ subroutine create_cohort(currentSite, patchptr, pft, nn, hite, dbh, bleaf, bfine
124136 ! !LOCAL VARIABLES:
125137 type (ed_cohort_type), pointer :: new_cohort ! Pointer to New Cohort structure.
126138 type (ed_cohort_type), pointer :: storesmallcohort
127- type (ed_cohort_type), pointer :: storebigcohort
139+ type (ed_cohort_type), pointer :: storebigcohort
140+ integer :: nlevsoi_hyd ! number of hydraulically active soil layers
128141 integer :: tnull,snull ! are the tallest and shortest cohorts allocate
129142 !- ---------------------------------------------------------------------
130143
@@ -241,12 +254,31 @@ subroutine create_cohort(currentSite, patchptr, pft, nn, hite, dbh, bleaf, bfine
241254 new_cohort% isnew = .true.
242255
243256 if ( hlm_use_planthydro.eq. itrue ) then
244- call InitHydrCohort(CurrentSite,new_cohort)
245- call updateSizeDepTreeHydProps(CurrentSite,new_cohort, bc_in)
246- call initTreeHydStates(CurrentSite,new_cohort, bc_in)
257+
258+ nlevsoi_hyd = currentSite% si_hydr% nlevsoi_hyd
259+
260+ ! This allocates array spaces
261+ call InitHydrCohort(currentSite,new_cohort)
262+
263+ ! This calculates node heights
264+ call UpdateTreeHydrNodes(new_cohort% co_hydr,new_cohort% pft, &
265+ new_cohort% hite,nlevsoi_hyd,bc_in)
266+
267+ ! This calculates volumes, lengths and max conductances
268+ call UpdateTreeHydrLenVolCond(new_cohort,nlevsoi_hyd,bc_in)
269+
270+ ! Since this is a newly initialized plant, we set the previous compartment-size
271+ ! equal to the ones we just calculated.
272+ call SavePreviousCompartmentVolumes(new_cohort% co_hydr)
273+
274+ ! This comes up with starter suctions and then water contents
275+ ! based on the soil values
276+ call initTreeHydStates(currentSite,new_cohort, bc_in)
277+
247278 if (recruitstatus== 1 )then
248- new_cohort% co_hydr% is_newly_recuited = .true.
279+ new_cohort% co_hydr% is_newly_recruited = .true.
249280 endif
281+
250282 endif
251283
252284 call insert_cohort(new_cohort, patchptr% tallest, patchptr% shortest, tnull, snull, &
@@ -602,19 +634,26 @@ subroutine terminate_cohorts( currentSite, currentPatch, level )
602634 endif ! if (.not.currentCohort%isnew .and. level == 2) then
603635
604636 if (terminate == 1 ) then
637+
605638 ! preserve a record of the to-be-terminated cohort for mortality accounting
606- if (currentCohort% canopy_layer .eq. 1 ) then
607- levcan = 1
608- else
609- levcan = 2
610- endif
639+ levcan = currentCohort% canopy_layer
611640
612- currentSite% terminated_nindivs(currentCohort% size_class,currentCohort% pft,levcan) = &
613- currentSite% terminated_nindivs(currentCohort% size_class,currentCohort% pft,levcan) + currentCohort% n
614- !
615- currentSite% termination_carbonflux(levcan) = currentSite% termination_carbonflux(levcan) + &
616- currentCohort% n * (struct_c+ sapw_c+ leaf_c+ fnrt_c+ store_c+ repro_c)
617-
641+ if ( hlm_use_planthydro == itrue ) &
642+ call AccumulateMortalityWaterStorage(currentSite,currentCohort,currentCohort% n)
643+
644+ if (levcan== ican_upper) then
645+ currentSite% term_nindivs_canopy(currentCohort% size_class,currentCohort% pft) = &
646+ currentSite% term_nindivs_canopy(currentCohort% size_class,currentCohort% pft) + currentCohort% n
647+
648+ currentSite% term_carbonflux_canopy = currentSite% term_carbonflux_canopy + &
649+ currentCohort% n * (struct_c+ sapw_c+ leaf_c+ fnrt_c+ store_c+ repro_c)
650+ else
651+ currentSite% term_nindivs_ustory(currentCohort% size_class,currentCohort% pft) = &
652+ currentSite% term_nindivs_ustory(currentCohort% size_class,currentCohort% pft) + currentCohort% n
653+
654+ currentSite% term_carbonflux_ustory = currentSite% term_carbonflux_ustory + &
655+ currentCohort% n * (struct_c+ sapw_c+ leaf_c+ fnrt_c+ store_c+ repro_c)
656+ end if
618657
619658 ! put the litter from the terminated cohorts straight into the fragmenting pools
620659 if (currentCohort% n.gt. 0.0_r8 ) then
@@ -729,6 +768,7 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
729768 real (r8 ) :: newn
730769 real (r8 ) :: diff
731770 real (r8 ) :: dynamic_fusion_tolerance
771+ real (r8 ) :: leaf_c ! leaf carbon [kg]
732772
733773 integer :: largersc, smallersc, sc_i ! indices for tracking the growth flux caused by fusion
734774 real (r8 ) :: larger_n, smaller_n
@@ -845,8 +885,11 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
845885
846886 call sizetype_class_index(currentCohort% dbh,currentCohort% pft, &
847887 currentCohort% size_class,currentCohort% size_by_pft_class)
888+
848889
849- if (hlm_use_planthydro.eq. itrue) call FuseCohortHydraulics(currentSite,currentCohort,nextc,bc_in,newn)
890+ if (hlm_use_planthydro.eq. itrue) then
891+ call FuseCohortHydraulics(currentSite,currentCohort,nextc,bc_in,newn)
892+ endif
850893
851894 ! recent canopy history
852895 currentCohort% canopy_layer_yesterday = (currentCohort% n* currentCohort% canopy_layer_yesterday + &
@@ -927,7 +970,6 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
927970 currentCohort% cmort = (currentCohort% n* currentCohort% cmort + nextc% n* nextc% cmort)/ newn
928971 currentCohort% hmort = (currentCohort% n* currentCohort% hmort + nextc% n* nextc% hmort)/ newn
929972 currentCohort% bmort = (currentCohort% n* currentCohort% bmort + nextc% n* nextc% bmort)/ newn
930- currentCohort% fmort = (currentCohort% n* currentCohort% fmort + nextc% n* nextc% fmort)/ newn
931973 currentCohort% frmort = (currentCohort% n* currentCohort% frmort + nextc% n* nextc% frmort)/ newn
932974
933975 ! logging mortality, Yi Xu
@@ -976,7 +1018,18 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
9761018 endif
9771019
9781020 ! At this point, nothing should be pointing to current Cohort
979- if (hlm_use_planthydro.eq. itrue) call DeallocateHydrCohort(nextc)
1021+ ! update hydraulics quantities that are functions of hite & biomasses
1022+ ! deallocate the hydro structure of nextc
1023+ if (hlm_use_planthydro.eq. itrue) then
1024+ call carea_allom(currentCohort% dbh,currentCohort% n,currentSite% spread, &
1025+ currentCohort% pft,currentCohort% c_area)
1026+ leaf_c = currentCohort% prt% GetState(leaf_organ, all_carbon_elements)
1027+ currentCohort% treelai = tree_lai(leaf_c, &
1028+ currentCohort% pft, currentCohort% c_area, currentCohort% n, &
1029+ currentCohort% canopy_layer, currentPatch% canopy_layer_tlai )
1030+ call updateSizeDepTreeHydProps(currentSite,currentCohort, bc_in)
1031+ call DeallocateHydrCohort(nextc)
1032+ endif
9801033
9811034 ! Deallocate the cohort's PRT structure
9821035 call nextc% prt% DeallocatePRTVartypes()
@@ -1303,7 +1356,6 @@ subroutine copy_cohort( currentCohort,copyc )
13031356 ! Mortality diagnostics
13041357 n% cmort = o% cmort
13051358 n% bmort = o% bmort
1306- n% fmort = o% fmort
13071359 n% hmort = o% hmort
13081360 n% frmort = o% frmort
13091361
0 commit comments