Skip to content

Commit 13bbb78

Browse files
committed
added some comments to help explain whats going on here.
1 parent 08bb140 commit 13bbb78

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

main/FatesHistoryInterfaceMod.F90

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,65 @@ module FatesHistoryInterfaceMod
4545
! These variables hold the index of the history output structure so we don't
4646
! have to constantly do name lookup when we want to populate the dataset
4747
! These indices are set during "define_history_vars()" call to "set_history_var()"
48-
! during the initialize phase. Definitions are not provide, for an explanation of
48+
! during the initialize phase. Definitions are not provided, for an explanation of
4949
! the variable go to its registry. (IH_ signifies "index history")
50+
!
51+
! Because of the complex sub-gridscale structure of FATES, in which multiple patches and cohorts
52+
! exist within a gridcell, along with vertical gradients within and between canopy layers, as well
53+
! as distinct classes such as PFTs or fuel size bins, there are multiple different dimensions in
54+
! which it is possible to output history variables to better understand what's going on.
55+
!
56+
! a key point is that, while the number of patches or cohorts can in principle be large, and the age
57+
! and size indices of a given patch or cohort can be finely resolved, we collapse these continuously-
58+
! varying indices into bins of time-invariant width for the purposes of history outputting. This is
59+
! because a given patch or cohort may not persist across a given interval of history averaging, so
60+
! it is better to output all patches of cohorts whose index is within a given interval along the size
61+
! or age bin.
62+
!
63+
! Another particularity of the issue of FATES shifting its subgrid structure frequently and possibly having
64+
! multiple (or zero) patches or cohorts within a given bin is that, if you want to output an average
65+
! quantities across some dimension, such as a mean carbon flux across patch area of a given age, in general
66+
! it is better to output both the numerator and denominator of the averaging calculation separately,
67+
! rather than the average itself, and then calculate the average in post-processing. So, e.g.
68+
! this means outputting both the patch area and the product of the flux within each patch and the patch area
69+
! as separate variables. Doing this allows conservation even when the weights are changing rapidly and
70+
! simplifies the logic when the number of patches or cohorts may be anywhere from zero to a large number.
71+
!
72+
! So what this means is that anything that is disaggregated at the patch area requires outputting the patch age
73+
! distribution (in units of patch area / site area) as the denominator of the average and then calculating the numerator of
74+
! the average as XXX times the patch area so (so in units of XXX * patch area / site area). For cohort-level quantities,
75+
! this requires outputting the number density (in units of individuals per site area), etc.
76+
!
77+
! For reference, some standardized abbreviations of the FATES dimensions are listed here:
78+
! scls = size-class dimension
79+
! pft = the pft dimension
80+
! age = the age bin dimension
81+
! height = the height bin dimension
82+
! cwdsc = the coarse woody debris size class dimension
83+
!
84+
! Since the netcdf interface can only handle variables with a certain number of dimensions,
85+
! we have create some "multiplexed" dimensions that combine two or more dimensions into a
86+
! single dimension. Examples of these are the following:
87+
! scpf = size class x PFT
88+
! cnlf = canopy layer x leaf layer
89+
! cnlfpft = canopy layer x leaf layer x PFT
90+
! scag = size class bin x age bin
91+
! scagpft = size class bin x age bin x PFT
92+
! agepft = age bin x PFT
93+
!
94+
! A recipe for adding a new history variable to this module:
95+
! (1) decide what time frequency it makes sense to update the variable at, and what dimension(s)
96+
! you want to output the variable on
97+
! (2) add the ih_ integer variable in the immediately following section of the module. Use the suffix as outlined
98+
! above for the dimension you are using.
99+
! (3) define a corresponding hio_ variable by associating it to the ih_ variable in the associate section
100+
! of the subroutine that corresponds to the time-updating frequency that you've chosen
101+
! (i.e. if half-hourly, then work in subroutine update_history_prod; if daily, then work in subroutine update_history_dyn)
102+
! (4) within that subroutine, add the logic that passes the information from the fates-native variable
103+
! (possibly on a patch or cohort structure) to the history hio_ variable that you've associated to.
104+
! (5) add the variable name, metadata, units, dimension, updating frequency, the ih_ variable index, etc via a call
105+
! to the set_history_var method in the subroutine define_history_vars.
106+
!
50107

51108
! Indices to 1D Patch variables
52109

@@ -158,8 +215,8 @@ module FatesHistoryInterfaceMod
158215
integer, private :: ih_h2oveg_growturn_err_si
159216
integer, private :: ih_h2oveg_pheno_err_si
160217
integer, private :: ih_h2oveg_hydro_err_si
161-
162-
! Indices to (site x scpf) variables
218+
219+
! Indices to (site x scpf [multiplexed size- and age- bins]) variables
163220
integer, private :: ih_nplant_si_scpf
164221
integer, private :: ih_gpp_si_scpf
165222
integer, private :: ih_npp_totl_si_scpf
@@ -212,7 +269,7 @@ module FatesHistoryInterfaceMod
212269
integer, private :: ih_ar_frootm_si_scpf
213270

214271

215-
! indices to (site x scls) variables
272+
! indices to (site x scls [size class bins]) variables
216273
integer, private :: ih_ba_si_scls
217274
integer, private :: ih_nplant_si_scls
218275
integer, private :: ih_nplant_canopy_si_scls

0 commit comments

Comments
 (0)