Skip to content

Commit 6660c71

Browse files
authored
Merge pull request #288 from ckoven/flexible_history_bins
runtime-specified history bins for size- and age- resolved output
2 parents 87a6385 + e06869c commit 6660c71

13 files changed

+198
-134
lines changed

biogeochem/EDCanopyStructureMod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ subroutine canopy_summarization( nsites, sites, bc_in )
861861
use FatesInterfaceMod , only : bc_in_type
862862
use EDPatchDynamicsMod , only : set_patchno
863863
use EDPatchDynamicsMod , only : set_root_fraction
864-
use EDTypesMod , only : sizetype_class_index
864+
use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
865865
use EDGrowthFunctionsMod , only : tree_lai, c_area
866866
use EDtypesMod , only : area
867867
use EDPftvarcon , only : EDPftvarcon_inst

biogeochem/EDCohortDynamicsMod.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module EDCohortDynamicsMod
1818
use EDTypesMod , only : nclmax
1919
use EDTypesMod , only : ncwd
2020
use EDTypesMod , only : maxCohortsPerPatch
21-
use EDTypesMod , only : sclass_ed,nlevsclass_ed,AREA
21+
use EDTypesMod , only : AREA
2222
use EDTypesMod , only : min_npm2, min_nppatch
2323
use EDTypesMod , only : min_n_safemath
2424
use FatesInterfaceMod , only : hlm_use_planthydro
@@ -28,7 +28,7 @@ module EDCohortDynamicsMod
2828
use FatesPlantHydraulicsMod, only : initTreeHydStates
2929
use FatesPlantHydraulicsMod, only : InitHydrCohort
3030
use FatesPlantHydraulicsMod, only : DeallocateHydrCohort
31-
use EDTypesMod , only : sizetype_class_index
31+
use FatesSizeAgeTypeIndicesMod, only : sizetype_class_index
3232

3333

3434
! CIME globals

biogeochem/EDPatchDynamicsMod.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ subroutine fuse_2_patches(dp, rp)
14371437
! associated with the secnd patch
14381438
!
14391439
! !USES:
1440-
use EDTypesMod, only: get_age_class_index
1440+
use FatesSizeAgeTypeIndicesMod, only: get_age_class_index
14411441
!
14421442
! !ARGUMENTS:
14431443
type (ed_patch_type) , intent(inout), pointer :: dp ! Donor Patch

main/EDInitMod.F90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module EDInitMod
2525
use FatesInterfaceMod , only : hlm_use_inventory_init
2626
use FatesInterfaceMod , only : numpft
2727
use ChecksBalancesMod , only : SiteCarbonStock
28+
use FatesInterfaceMod , only : nlevsclass
2829

2930
! CIME GLOBALS
3031
use shr_log_mod , only : errMsg => shr_log_errMsg
@@ -38,6 +39,7 @@ module EDInitMod
3839
__FILE__
3940

4041
public :: zero_site
42+
public :: init_site_vars
4143
public :: init_patches
4244
public :: set_site_properties
4345
private :: init_cohorts
@@ -48,6 +50,24 @@ module EDInitMod
4850

4951
! ============================================================================
5052

53+
subroutine init_site_vars( site_in )
54+
!
55+
! !DESCRIPTION:
56+
!
57+
!
58+
! !ARGUMENTS
59+
type(ed_site_type), intent(inout) :: site_in
60+
!
61+
! !LOCAL VARIABLES:
62+
!----------------------------------------------------------------------
63+
!
64+
allocate(site_in%terminated_nindivs(1:nlevsclass,1:numpft,2))
65+
allocate(site_in%demotion_rate(1:nlevsclass))
66+
allocate(site_in%promotion_rate(1:nlevsclass))
67+
!
68+
end subroutine init_site_vars
69+
70+
! ============================================================================
5171
subroutine zero_site( site_in )
5272
!
5373
! !DESCRIPTION:

main/EDMainMod.F90

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module EDMainMod
3434
use EDPhysiologyMod , only : recruitment
3535
use EDPhysiologyMod , only : trim_canopy
3636
use SFMainMod , only : fire_model
37-
use EDTypesMod , only : get_age_class_index
37+
use FatesSizeAgeTypeIndicesMod, only : get_age_class_index
3838
use EDtypesMod , only : ncwd
3939
use EDtypesMod , only : ed_site_type
4040
use EDtypesMod , only : ed_patch_type
@@ -225,7 +225,6 @@ subroutine ed_integrate_state_variables(currentSite, bc_in )
225225
! FIX(SPM,032414) refactor so everything goes through interface
226226
!
227227
! !USES:
228-
use EDTypesMod, only : ageclass_ed
229228
!
230229
! !ARGUMENTS:
231230
type(ed_site_type) , intent(inout) :: currentSite
@@ -381,7 +380,6 @@ subroutine ed_integrate_state_variables(currentSite, bc_in )
381380
endif
382381
enddo
383382

384-
385383
end subroutine ed_integrate_state_variables
386384

387385
!-------------------------------------------------------------------------------!

main/EDParamsMod.F90

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ module EDParamsMod
4646
real(r8),protected :: ED_val_patch_fusion_tol
4747
real(r8),protected :: ED_val_canopy_closure_thresh ! site-level canopy closure point where trees take on forest (narrow) versus savannah (wide) crown allometry
4848

49+
! two special parameters whose size is defined in the parameter file
50+
real(r8),protected,allocatable :: ED_val_history_sizeclass_bin_edges(:)
51+
real(r8),protected,allocatable :: ED_val_history_ageclass_bin_edges(:)
52+
4953
character(len=param_string_length),parameter :: ED_name_size_diagnostic_scale = "fates_size_diagnostic_scale"
5054
character(len=param_string_length),parameter :: ED_name_mort_disturb_frac = "fates_mort_disturb_frac"
5155
character(len=param_string_length),parameter :: ED_name_comp_excln = "fates_comp_excln"
@@ -71,6 +75,10 @@ module EDParamsMod
7175
character(len=param_string_length),parameter :: ED_name_patch_fusion_tol= "fates_patch_fusion_tol"
7276
character(len=param_string_length),parameter :: ED_name_canopy_closure_thresh= "fates_canopy_closure_thresh"
7377

78+
! non-scalar parameter names
79+
character(len=param_string_length),parameter :: ED_name_history_sizeclass_bin_edges= "fates_history_sizeclass_bin_edges"
80+
character(len=param_string_length),parameter :: ED_name_history_ageclass_bin_edges= "fates_history_ageclass_bin_edges"
81+
7482
! Hydraulics Control Parameters (ONLY RELEVANT WHEN USE_FATES_HYDR = TRUE)
7583
! ----------------------------------------------------------------------------------------------
7684
real(r8),protected :: hydr_psi0 ! sapwood water potential at saturation (MPa)
@@ -162,12 +170,15 @@ subroutine FatesRegisterParams(fates_params)
162170
! that need to be synced with host values.
163171

164172
use FatesParametersInterface, only : fates_parameters_type, dimension_name_scalar1d, dimension_shape_1d
173+
use FatesParametersInterface, only : dimension_name_history_size_bins, dimension_name_history_age_bins
165174

166175
implicit none
167176

168177
class(fates_parameters_type), intent(inout) :: fates_params
169178

170179
character(len=param_string_length), parameter :: dim_names(1) = (/dimension_name_scalar1d/)
180+
character(len=param_string_length), parameter :: dim_names_sizeclass(1) = (/dimension_name_history_size_bins/)
181+
character(len=param_string_length), parameter :: dim_names_ageclass(1) = (/dimension_name_history_age_bins/)
171182

172183
call FatesParamsInit()
173184

@@ -268,6 +279,13 @@ subroutine FatesRegisterParams(fates_params)
268279
dimension_names=dim_names)
269280

270281

282+
! non-scalar parameters
283+
call fates_params%RegisterParameter(name=ED_name_history_sizeclass_bin_edges, dimension_shape=dimension_shape_1d, &
284+
dimension_names=dim_names_sizeclass)
285+
286+
call fates_params%RegisterParameter(name=ED_name_history_ageclass_bin_edges, dimension_shape=dimension_shape_1d, &
287+
dimension_names=dim_names_ageclass)
288+
271289
end subroutine FatesRegisterParams
272290

273291

@@ -376,6 +394,14 @@ subroutine FatesReceiveParams(fates_params)
376394
call fates_params%RetreiveParameter(name=logging_name_event_code, &
377395
data=logging_event_code)
378396

397+
! parameters that are arrays of size defined within the params file and thus need allocating as well
398+
call fates_params%RetreiveParameterAllocate(name=ED_name_history_sizeclass_bin_edges, &
399+
data=ED_val_history_sizeclass_bin_edges)
400+
401+
call fates_params%RetreiveParameterAllocate(name=ED_name_history_ageclass_bin_edges, &
402+
data=ED_val_history_ageclass_bin_edges)
403+
404+
379405
end subroutine FatesReceiveParams
380406

381407
! =====================================================================================

main/EDTypesMod.F90

Lines changed: 3 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,6 @@ module EDTypesMod
100100
! special mode to cause PFTs to create seed mass of all currently-existing PFTs
101101
logical, parameter :: homogenize_seed_pfts = .false.
102102

103-
!the lower limit of the size classes of ED cohorts
104-
!0-10,10-20...
105-
integer, parameter :: nlevsclass_ed = 13 ! Number of dbh size classes for size structure analysis
106-
! |0-1,1-2,2-3,3-4,4-5,5-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80,80-90,90-100,100+|
107-
! real(r8), parameter, dimension(16) :: sclass_ed = (/0.0_r8,1.0_r8,2.0_r8,3.0_r8,4.0_r8,5.0_r8,10.0_r8,20.0_r8,30.0_r8,40.0_r8, &
108-
! 50.0_r8,60.0_r8,70.0_r8,80.0_r8,90.0_r8,100.0_r8/)
109-
110-
real(r8), parameter, dimension(nlevsclass_ed) :: sclass_ed = (/0.0_r8,5.0_r8,10.0_r8,15.0_r8,20.0_r8,30.0_r8,40.0_r8, &
111-
50.0_r8,60.0_r8,70.0_r8,80.0_r8,90.0_r8,100.0_r8/)
112-
113-
integer, parameter :: nlevage_ed = 7 ! Number of patch-age classes for age structured analyses
114-
real(r8), parameter, dimension(nlevage_ed) :: ageclass_ed = (/0.0_r8,1.0_r8,2._r8,5.0_r8,10.0_r8,20.0_r8,50.0_r8/)
115-
116-
117-
! integer, parameter :: nlevsclass_ed = 17
118-
! real(r8), parameter, dimension(17) :: sclass_ed = (/0.1_r8, 5.0_r8,10.0_r8,15.0_r8,20.0_r8,25.0_r8, &
119-
! 30.0_r8,35.0_r8,40.0_r8,45.0_r8,50.0_r8,55.0_r8, &
120-
! 60.0_r8,65.0_r8,70.0_r8,75.0_r8,80.0_r8/)
121-
122103
integer, parameter :: nlevmclass_ed = 5 ! nlev "mortality" classes in ED
123104
! Number of ways to die
124105
! (background,hydraulic,carbon,impact,fire)
@@ -552,12 +533,12 @@ module EDTypesMod
552533

553534
! TERMINATION, RECRUITMENT, DEMOTION, and DISTURBANCE
554535

555-
real(r8) :: terminated_nindivs(1:nlevsclass_ed,1:maxpft,2) ! number of individuals that were in cohorts which were terminated this timestep, on size x pft x canopy array.
536+
real(r8), allocatable :: terminated_nindivs(:,:,:) ! number of individuals that were in cohorts which were terminated this timestep, on size x pft x canopy array.
556537
real(r8) :: termination_carbonflux(2) ! carbon flux from live to dead pools associated with termination mortality, per canopy level
557538
real(r8) :: recruitment_rate(1:maxpft) ! number of individuals that were recruited into new cohorts
558-
real(r8) :: demotion_rate(1:nlevsclass_ed) ! rate of individuals demoted from canopy to understory per FATES timestep
539+
real(r8), allocatable :: demotion_rate(:) ! rate of individuals demoted from canopy to understory per FATES timestep
559540
real(r8) :: demotion_carbonflux ! biomass of demoted individuals from canopy to understory [kgC/ha/day]
560-
real(r8) :: promotion_rate(1:nlevsclass_ed) ! rate of individuals promoted from understory to canopy per FATES timestep
541+
real(r8), allocatable :: promotion_rate(:) ! rate of individuals promoted from understory to canopy per FATES timestep
561542
real(r8) :: promotion_carbonflux ! biomass of promoted individuals from understory to canopy [kgC/ha/day]
562543

563544
! some diagnostic-only (i.e. not resolved by ODE solver) flux of carbon to CWD and litter pools from termination and canopy mortality
@@ -573,67 +554,6 @@ module EDTypesMod
573554

574555
contains
575556

576-
! =====================================================================================
577-
578-
function get_age_class_index(age) result( patch_age_class )
579-
580-
real(r8), intent(in) :: age
581-
582-
integer :: patch_age_class
583-
584-
patch_age_class = count(age-ageclass_ed.ge.0.0_r8)
585-
586-
end function get_age_class_index
587-
588-
! =====================================================================================
589-
590-
function get_sizeage_class_index(dbh,age) result(size_by_age_class)
591-
592-
! Arguments
593-
real(r8),intent(in) :: dbh
594-
real(r8),intent(in) :: age
595-
596-
integer :: size_class
597-
integer :: age_class
598-
integer :: size_by_age_class
599-
600-
size_class = get_size_class_index(dbh)
601-
602-
age_class = get_age_class_index(age)
603-
604-
size_by_age_class = (age_class-1)*nlevsclass_ed + size_class
605-
606-
end function get_sizeage_class_index
607-
608-
! =====================================================================================
609-
610-
subroutine sizetype_class_index(dbh,pft,size_class,size_by_pft_class)
611-
612-
! Arguments
613-
real(r8),intent(in) :: dbh
614-
integer,intent(in) :: pft
615-
integer,intent(out) :: size_class
616-
integer,intent(out) :: size_by_pft_class
617-
618-
size_class = get_size_class_index(dbh)
619-
620-
size_by_pft_class = (pft-1)*nlevsclass_ed+size_class
621-
622-
return
623-
end subroutine sizetype_class_index
624-
625-
! =====================================================================================
626-
627-
function get_size_class_index(dbh) result(cohort_size_class)
628-
629-
real(r8), intent(in) :: dbh
630-
631-
integer :: cohort_size_class
632-
633-
cohort_size_class = count(dbh-sclass_ed.ge.0.0_r8)
634-
635-
end function get_size_class_index
636-
637557
! =====================================================================================
638558

639559
subroutine val_check_ed_vars(currentPatch,var_aliases,return_code)

0 commit comments

Comments
 (0)