-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates and fixes to maintenance respiration #138
Conversation
…ion to be consistent with the other maintenance pools. However, the unit of kgC/plant/sec is likely to be a very very small number that is wasting precision. Contemplating changing units to umol/sec or kgC/yr.
…nce been used to calculate and update livecrootn, but the calculation had been moved to EDCanopyStructure. To resolve the conflict I had to remove the calculation of livecrootn and livestemn from its new home.
…xed a unit conversion error in maintenance respiration.
… that was unnecessary, a scalar was sufficient. It was also calculated twice in the call sequence, where the first calculation was unnecessary and unused.
Seems like there is still some ongoing science discussion in #120. Please assign this to me when science review is done. |
Sounds good, thanks @bandre-ucar |
! the sapwood pools. | ||
! Units are in (kgN/plant) | ||
! ------------------------------------------------------------------ | ||
live_agstem_n = ED_val_ag_biomass * currentCohort%bsw / & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After talking with @ckoven , changing the naming convention of "stem" to imply above ground, and use coarse root to imply below ground. New variable names will be:
live_stem_n
live_croot_n
froot_n
@@ -692,6 +711,11 @@ subroutine update_history_prod(this,nc,nsites,sites,dt_tstep) | |||
|
|||
if ( .not. ccohort%isnew ) then | |||
|
|||
! Calculate index for the scpf class | |||
ft = ccohort%pft | |||
sc = count(ccohort%dbh-sclass_ed.ge.0.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the calculation of sc is quite expensive, as it is doing some logical counting inside a cohort loop that occurs every time step.
I would like to add a new variable to the cohort structure that is calculated when dynamics are updated:
type(ed_cohort_type)
integer :: size_class ! An index that indicates which diameter size bin the cohort currently resides in
! this is used for history output. We maintain this in the main cohort memory
! because we don't want to continually re-calculate the cohort's position when
! performing size diagnostics at high-frequency calls
integer :: size_by_pft_class ! An index that indicates the cohorts position of the joint size-class x functional
! type classification. We also maintain this in the main cohort memory
! because we don't want to continually re-calculate the cohort's position when
! performing size diagnostics at high-frequency calls
…ariables were added to reduce the number of times these are re-calculated. They are in some cases needed for history diagnostics updated at the finest model time-scale on cohort variables, this was likely a very expensive calculation, so it was moved to be calculated only on the dynamics timestep.
@bandre-ucar , pending final agreement from @rosiealice, this should be ok to test on yellowstone. @rosiealice reviewed prior to my final analysis with updated root fractions. @rosiealice would you like more review on this, or any concerns you would like rectified? FYI, this change set is not a roadblock on other developments, so the time-line is open. |
No, the modified root fractions is good with me. Yadvinder's paper has On 24 October 2016 at 12:36, Ryan Knox [email protected] wrote:
Dr Rosie A. Fisher Terrestrial Sciences Section |
@@ -979,7 +1012,7 @@ real(r8) :: tc ! Temperature response function fo | |||
end if | |||
bc_out(s)%rssun_pa(ifp) = rscanopy | |||
bc_out(s)%rssha_pa(ifp) = rscanopy | |||
bc_out(s)%gccanopy_pa(ifp) = 1.0_r8/rscanopy*cf/1000 !convert into umol m02 s-1 then mmol m-2 s-1. | |||
bc_out(s)%gccanopy_pa(ifp) = 1.0_r8/rscanopy*cf/1000.0 !convert into umol m-2 s-1 then mmol m-2 s-1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This magic number needs an _r8 added. Shouldn't one of the new unit conversion constants be used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added umol_per_mmol to FatesConstants
|
||
! First guess on ratio between intracellular co2 and the atmosphere | ||
! an iterator converges on actual | ||
real(r8),parameter :: init_a2l_co2_c3 = 0.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need an _r8 on these constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
use EDCanopyStructureMod,only: calc_areaindex | ||
|
||
use FatesConstantsMod, only : umolC_to_kgC, & ! micromole conversion to kgC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLM has been actively discouraging these kinds of line continuations for several years because they make it hard to search the code for places where different names are imported. The preferred method is not using continuations and having the use statement on every line. Multiple names per line are ok.
It would be good for FATES to adopt a standard and start being consistent. I don't have a preference for what the standard is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that standard, it will certainly help in tracking down where globals are used when grepping the code
g_per_kg, & ! number of grams per kg | ||
mg_per_g, & ! number of miligrams per g | ||
sec_per_min, & ! seconds per minute (60!) | ||
rgas, & ! universal gas constant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to tfrz, rgas should be named universal_gas_constant_UNITS and then aliased.
|
||
use FatesConstantsMod, only : umolC_to_kgC, & ! micromole conversion to kgC | ||
g_per_kg, & ! number of grams per kg | ||
mg_per_g, & ! number of miligrams per g |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments aren't really contributing anything to understanding of the code. The point of using good naming conventions like this is that it removes the need for lots of explanatory comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, but if I come across a constant in the future that has a long or complex name, I might just provide the description in-line. I just want to brace you for that impact, I don't want to catch you off guard! These are important decisions.
@@ -316,6 +319,8 @@ subroutine nan_cohort(cc_p) | |||
currentCohort%canopy_layer = 999 ! canopy status of cohort (1 = canopy, 2 = understorey, etc.) | |||
currentCohort%NV = 999 ! Number of leaf layers: - | |||
currentCohort%status_coh = 999 ! growth status of plant (2 = leaves on , 1 = leaves off) | |||
currentCohort%size_class = 999 ! size class index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These magic numbers should be replaced with a parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I grabbed your definition of fates_unset_int from the history PR, I will use that, we should expect a trivial merge conflict with either this or History refactors, which every gets pulled second.
I'm going to leave the nan initialization in that subroutine as is. I will be investigating that part of the code anyway while I'm applying the fix to #133.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not concerned about the conflict, it's easy enough to resolve. There are going to be a few conflicts with the hist mod anyway. At a minimum the set_hist_var calls need to be updated.
integer,intent(out) :: size_class | ||
integer,intent(out) :: size_by_pft_class | ||
|
||
size_class = count(dbh-sclass_ed.ge.0.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need an _r8.
… name, adding _r8 to local constants, adding an unset integer to global constants, removing some text that explained a constant.
I believe comments by @bandre-ucar have been addressed now. |
testing on yellowstone |
The last changeset is not b4b with previous changesets and should be. I regressed 8e2b86f against fe9f7a1 and generated large differences across many variables. |
I tried a couple of changes and re-ran the regression test: the following produced b4b results:
The non-b4b results can be attributed to rounding errors associated with the conversion of some single to double precision variables. I am satisfied with the results of the tests and recommend pulling pending tests on yellowstone. EDIT: Note I don't want to revert the changes, I just wanted to know exactly why we didn't have b4b results on the last changeset. |
nice work, and, for the record, that's crazy that the single to double precision affects results so much. |
@rgknox Thanks for following up with that. yellowstone tests are stuck in the queue. I'll push to master or post problems as soon as they are done. |
This change group includes some unit fixes to calculations of maintenance respiration (sapwood and fine-root). Some refactoring was included with the change to make code more readable and organized. Several constants, such as unit conversions and physical constants were given named parameters. Constants that were general were added to GlobalConstants, local constants such as the base maintenance respiration rate were kept within the photosynthesis module. The code changes that generate different answers are related to fixing the unit conversion bug, associating fine-root c2n ratios with sapwood and fine roots, and also associating soil temperatures with the q10 temperature scaling on the respiration rates for below ground pools.
The changes should have an impact on plant carbon balance. Fine root respiration rates will now be a good deal larger than previously. Sapwood respiration rates, while larger, are still relatively small contributors compared to leaf (based on dark rates) and fine-roots, based on what is presumably a underestimated sapwood biomass pool.
Fixes: #120
User interface changes?: no
Code review: self, see #120 for discussions
Test suite: edTest, lawrencium-lr2
Test baseline: NA
Test namelist changes:
Test answer changes: yes, expected on FATES
Test summary: all pass