Skip to content
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

Merged
merged 13 commits into from
Oct 31, 2016
Merged

Updates and fixes to maintenance respiration #138

merged 13 commits into from
Oct 31, 2016

Conversation

rgknox
Copy link
Contributor

@rgknox rgknox commented Oct 14, 2016

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

rgknox and others added 10 commits October 7, 2016 16:52
…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.
@rgknox rgknox changed the title Updates and fixes to maintenance respiratoin Updates and fixes to maintenance respiration Oct 14, 2016
@bandre-ucar
Copy link
Contributor

Seems like there is still some ongoing science discussion in #120. Please assign this to me when science review is done.

@rgknox
Copy link
Contributor Author

rgknox commented Oct 17, 2016

Sounds good, thanks @bandre-ucar

! the sapwood pools.
! Units are in (kgN/plant)
! ------------------------------------------------------------------
live_agstem_n = ED_val_ag_biomass * currentCohort%bsw / &
Copy link
Contributor Author

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)
Copy link
Contributor Author

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.
@rgknox
Copy link
Contributor Author

rgknox commented Oct 19, 2016

Tested the re-named variables and addition of the new indexing variables, edTest suite, 44d762d with regressions against fe9f7a1. All tests passed.

@rgknox
Copy link
Contributor Author

rgknox commented Oct 24, 2016

@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.

@rosiealice
Copy link
Contributor

No, the modified root fractions is good with me. Yadvinder's paper has
leaf respiration being twice as large as root at Manaus & Tapajos, so this
might even be a real thing...
Table 13
https://www.researchgate.net/profile/Yadvinder_Malhi/publication/227546900_
Comprehensive_assessment_of_carbon_productivity_allocation_and_storage_in_
three_Amazonian_forests._Glob_Change_Biol/links/0fcfd5091b425a8e17000000.pdf

On 24 October 2016 at 12:36, Ryan Knox [email protected] wrote:

@bandre-ucar https://github.com/bandre-ucar , pending final agreement
from @rosiealice https://github.com/rosiealice, this should be ok to
test on yellowstone. @rosiealice https://github.com/rosiealice reviewed
prior to my final analysis with updated root fractions. @rosiealice
https://github.com/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.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#138 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AMWsQ75MBD3MwqopJSJqg4zhPrCok4Ohks5q3PqqgaJpZM4KXTBF
.


Dr Rosie A. Fisher

Terrestrial Sciences Section
Climate and Global Dynamics
National Center for Atmospheric Research
1850 Table Mesa Drive
Boulder, Colorado, 80305
USA.
+1 303-497-1706

http://www.cgd.ucar.edu/staff/rfisher/

@@ -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.
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

@bandre-ucar bandre-ucar Oct 27, 2016

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.

Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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)
Copy link
Contributor

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.
@rgknox
Copy link
Contributor Author

rgknox commented Oct 27, 2016

I believe comments by @bandre-ucar have been addressed now.
I would be amazed if something has been broken, but stranger things have happened. I will run it through the test mill and report in tomorrow.

@bandre-ucar
Copy link
Contributor

testing on yellowstone

@rgknox
Copy link
Contributor Author

rgknox commented Oct 28, 2016

The last changeset is not b4b with previous changesets and should be. I regressed 8e2b86f against fe9f7a1 and generated large differences across many variables.
One possible source is the swapping from a fates_unset_int flag of 999 to -9999 for a list of cohort variables (this would indicate one of those variables is not being initialized correctly).
Another source may be the conversion of some of those constants to double precision.
I'm running a regression tests where I revert that unset flag back to 999.

@rgknox
Copy link
Contributor Author

rgknox commented Oct 28, 2016

I tried a couple of changes and re-ran the regression test: the following produced b4b results:

[rgknox@n0002 ed-clm]$ git diff
diff --git a/components/clm/src/ED/biogeophys/EDPhotosynthesisMod.F90 b/components/clm/src/ED/biogeophys/EDPhotosynthesisMod.F90
index a9e6cf5..f20bd6c 100644
--- a/components/clm/src/ED/biogeophys/EDPhotosynthesisMod.F90
+++ b/components/clm/src/ED/biogeophys/EDPhotosynthesisMod.F90
@@ -236,8 +236,8 @@ contains

     ! First guess on ratio between intracellular co2 and the atmosphere
     ! an iterator converges on actual
-    real(r8),parameter :: init_a2l_co2_c3 = 0.7_r8
-    real(r8),parameter :: init_a2l_co2_c4 = 0.4_r8
+    real(r8),parameter :: init_a2l_co2_c3 = 0.7 !_r8
+    real(r8),parameter :: init_a2l_co2_c4 = 0.4 !_r8


     associate(                                                &
@@ -1011,7 +1011,7 @@ contains
             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/umol_per_mmol  !convert into umol m-2 s-1 then mmol m-2 s-1. 
+            bc_out(s)%gccanopy_pa(ifp)  = 1.0_r8/rscanopy*cf/1000.0 !umol_per_mmol  !convert into umol m-2 s-1 then mmol m-2 s-1. 
          end if

          currentPatch => currentPatch%younger

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.

@ckoven
Copy link
Contributor

ckoven commented Oct 28, 2016

nice work, and, for the record, that's crazy that the single to double precision affects results so much.

@bandre-ucar
Copy link
Contributor

@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.

@bandre-ucar bandre-ucar merged commit 8e2b86f into NGEET:master Oct 31, 2016
@bandre-ucar bandre-ucar removed their assignment Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug in froot_mr calculation
4 participants