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

Carbon allocation: bug fixes and simpler (optional) allocation approach #800

Closed
wants to merge 28 commits into from

Conversation

mpaiao
Copy link
Contributor

@mpaiao mpaiao commented Oct 30, 2021

This pull request addresses the bug discussed in #784. I changed the order of the carbon allocation fraction, to ensure that allocation to fine roots and leaves were truly proportional to demand.

Description:

  1. Bug fix in DailyPRTAllometricCarbon (parteh/PRTAllometricCarbonMod.F90). When allocating to different tissues, the code was subtracting allocation of tissues before calculating the amount for the next tissue, potentially under-allocating carbon to fine roots.
  2. Renamed variable laimemory with leafmemory. We were never tracking the LAI, but leaf carbon, and thus the name is dangerously misleading.
  3. Implemented an option carbon allocation routine (DailyPRTAllometricCarbonSimpler in parteh/PRTAllometricCarbonMod.F90). In this routine, I applied much simpler rules for maintenance allocation: it simply checks how much each pool is in deficit, and allocates carbon (storage + carbon_balance) to the pools according to the debt. If there is any carbon left, then the plant finishes filling the storage pool and then allocates to growth. This option is set by fates_parteh_mode=0, and will require changing the valid options in the host land models (see example of changes for CTSM in here).

This addresses issue #784

Collaborators:

@rgknox @jkshuman

Expectation of Answer Changes:

This fixes the carbon allocation priorities, so it should cause higher use of carbon balance and storage than the current master.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the in-code documentation .AND. (the technical note .OR. the wiki) accordingly.
  • I have read the CONTRIBUTING document.
  • FATES PASS/FAIL regression tests were run
  • If answers were expected to change, evaluation was performed and provided

Test Results:

CTSM (or) E3SM (specify which) test hash-tag:

CTSM (or) E3SM (specify which) baseline hash-tag:

FATES baseline hash-tag:

Test Output:

mpaiao added 2 commits August 12, 2021 23:17
1. Bug fix in DailyPRTAllometricCarbon (parteh/PRTAllometricCarbonMod.F90). When
   allocating to different tissues, the code was subtracting allocation of tissues before
   calculating the amount for the next tissue, potentially under-allocating carbon to fine
   roots.
2. Renamed variable laimemory with leafmemory. We were never tracking the LAI, but leaf
   carbon, and thus the name is dangerously misleading.
3. Implemented an option carbon allocation routine (DailyPRTAllometricCarbonSimpler in
   parteh/PRTAllometricCarbonMod.F90).  In this routine, I applied much simpler rules for
   maintenance allocation: it simply checks how much each pool is in deficit, and allocates
   carbon (storage + carbon_balance) to the pools according to the debt. If there is any
   carbon left, then the plant finishes filling the storage pool and then allocates to
   growth.
@ckoven ckoven requested a review from rgknox November 22, 2021 20:25
@glemieux glemieux mentioned this pull request Dec 3, 2021
5 tasks
@glemieux glemieux requested a review from rosiealice December 20, 2021 21:13
@glemieux glemieux self-assigned this Jan 24, 2022
Copy link
Contributor

@glemieux glemieux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good pretty good to me. I only have one question in the comments below.

main/EDMainMod.F90 Outdated Show resolved Hide resolved
! IV. If carbon balance is negative, reduce the storage pool. Otherwise, try to
! fill the storage pool before growing.
! -----------------------------------------------------------------------------------
update_storage: if ( carbon_balance < 0.0_r8 .or. is_hydecid_dormant ) then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpaiao could you provide some text here on why we perform this flux for hydro deciduous dormant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm @mpaiao , explained below

…streamline the code.

1. Removed some of the excessively cautious checks on carbon balance and storage for
   drought deciduous. Instead, the code now prevents growth by setting the target storage
   to include any positive carbon balance (currently unlikely, but will be common with
   semi-deciduous plants).

2. Streamline some of the allocation steps, by using an allocation factor that is shared
   across all tissues. This is mathematically equivalent to the previous code, but a bit
   safer.

3. Included some detailed checks on allometry, with longer reports in case the model
   fails to converge, which can be useful for debugging.
@@ -4069,7 +4079,7 @@ subroutine update_history_hydraulics(this,nc,nsites,sites,bc_in,dt_tstep)

jsoil = jrhiz + jr1-1
vwc = bc_in(s)%h2o_liqvol_sl(jsoil)
psi = site_hydr%wrf_soil(jrhiz)%p%psi_from_th(vwc)
psi = site_hydr%wrf_soil(jrhiz)%p%psi_from_th(vwc) ! MLO: Any reason for not using smp_sl?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, not sure why we are using this method, it does seem circuitous

@rgknox
Copy link
Contributor

rgknox commented Mar 8, 2022

Tests on cheyenne are expected, but the bug fix does change results: /glade/scratch/rgknox/tests_0308-101142ch

Also running a multi-decade smoke test on the f45. will report when completed

@mpaiao
Copy link
Contributor Author

mpaiao commented Mar 9, 2022

@rgknox Thanks for testing. This fix certainly changes the results because it effectively increases allocation to fine roots.

@rgknox
Copy link
Contributor

rgknox commented Mar 10, 2022

I merged in the bug fix PR sci1.55.3, and ran a multi decade simulation on the f45 grid. The simulation is crashing after 15 years, 5 months. Still investigating, but here is the traceback and relevant lines:

412: The leaf and stem are predicted for a cohort, maxed out the array size
412: lai:    28.8159170788368
412: sai:    1.61438526553054
412: target_lai:    16.1438526553054
412: lai+sai:    30.4303023443674
412: dinc_vai:   1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000        1.00000000000000        1.00000000000000
412:   1.00000000000000
412: nlevleaf,sum(dinc_vai):          30   30.0000000000000
412: pft:            6
412: call id:            4
412: n:   3.578557075491508E-002
412: c_area:   0.261857553271898
412: dbh:    10.6451383108649       dbh_max:    90.0000000000000
412: h:    10.6506677618998
412: canopy_trim:    1.00462475971335
412: target_bleaf:    1.25084224567712
412: canopy layer:            2
412: canopy_tlai:    6.11041719980801        1.15930565543891
412: vcmax25top:    58.0000000000000
412: ENDRUN:
412: ERROR in FatesAllometryMod.F90 at line 756

/glade/u/home/rgknox/ctsm/src/fates/biogeochem/FatesAllometryMod.F90:756
/glade/u/home/rgknox/ctsm/src/fates/biogeochem/EDCanopyStructureMod.F90:1987
412:MPT: 0x00002b5d8a55a6da in waitpid () from /glade/u/apps/ch/os/lib64/libpthread.so.0
412:MPT: Missing separate debuginfos, use: zypper install glibc-debuginfo-2.22-49.16.x86_64
412:MPT: (gdb) #0  0x00002b5d8a55a6da in waitpid ()
412:MPT:    from /glade/u/apps/ch/os/lib64/libpthread.so.0
412:MPT: #1  0x00002b5d8b22b306 in mpi_sgi_system (
412:MPT: #2  MPI_SGI_stacktraceback (
412:MPT:     header=header@entry=0x7fffc3d2bd30 "MPT ERROR: Rank 412(g:412) is aborting with error code 1001.\n\tProcess ID: 16176, Host: r6i6
n15, Program: /glade/scratch/rgknox/fates-clm-tests/carbon-alloc-fix-terminate-f45_f45_mg37/bld/cesm.exe\n\tMPT"...) at sig.c:340
412:MPT: #3  0x00002b5d8b1616e9 in print_traceback (ecode=ecode@entry=1001)
412:MPT:     at abort.c:246
412:MPT: #4  0x00002b5d8b1619ba in PMPI_Abort (comm=<optimized out>, errorcode=1001)
412:MPT:     at abort.c:68
412:MPT: #5  0x00002b5d8b161ca1 in pmpi_abort__ ()
412:MPT:    from /glade/u/apps/ch/opt/mpt/2.22/lib/libmpi.so
412:MPT: #6  0x0000000000faede9 in shr_mpi_mod_mp_shr_mpi_abort_ ()
412:MPT:     at /glade/u/home/rgknox/ctsm/share/src/shr_mpi_mod.F90:2127
412:MPT: #7  0x0000000000ee77e6 in shr_abort_mod_mp_shr_abort_abort_ ()
412:MPT:     at /glade/u/home/rgknox/ctsm/share/src/shr_abort_mod.F90:69
412:MPT: #8  0x00000000008cef20 in fatesglobals_mp_fates_endrun_ ()
412:MPT:     at /glade/u/home/rgknox/ctsm/src/fates/main/FatesGlobals.F90:65
412:MPT: #9  0x00000000008c8252 in fatesallometrymod_mp_tree_sai_ ()
412:MPT:     at /glade/u/home/rgknox/ctsm/src/fates/biogeochem/FatesAllometryMod.F90:756
412:MPT: #10 0x0000000000867baf in edcanopystructuremod_mp_update_hlm_dynamics_ ()
412:MPT:     at /glade/u/home/rgknox/ctsm/src/fates/biogeochem/EDCanopyStructureMod.F90:1987
412:MPT: #11 0x00000000005f8e4f in clmfatesinterfacemod_mp_wrap_update_hlmfates_dyn_ ()
...

@rgknox
Copy link
Contributor

rgknox commented Mar 30, 2022

@mpaiao I created another branch that just had the re-ordering fix in the existing allocation scheme: master...rgknox:sci.1.55.4_api.22.1.0-calloc-onlyfix

My intention here is to run a comparison simulation between this new branch and your branch to see if they generate indistinguishable results with a default setup on a 10 year global simulation. If they do, then we can be assured that the changes to results from your branch are sourced exactly from the code we think it is.

Can you take a look at that branch and tell me if this all makes sense?

@mpaiao
Copy link
Contributor Author

mpaiao commented Mar 31, 2022

@rgknox I checked the branch and it looks fine, thanks!

mpaiao and others added 8 commits April 4, 2022 09:13
Removed the if statements for hydro-deciduous when dormant. These changes will be included in the drought deciduous pull request.
Replaced 1 with "itrue" in some logical tests.
The target leaf carbon should be zero when leaves are off.  This was accidentally removed when deleting some code that should be incorporated when pull request NGEET#801 (Multiple updates to drought deciduous phenology) is incorporated.
…y (another PR)

and to reduce differences between branch and master.
…on. This requires

a change in the host land models.
…is not related to

carbon allocation but semi-deciduous leaf phenology.
Copy link
Contributor Author

@mpaiao mpaiao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rgknox I went through every file once again, and I cannot find any change besides the carbon allocation that would explain the changes. I made a few minor edits to reconcile the PR with the main line, but they shouldn't have any effect on results.

If you prefer, I could withdraw this PR and re-submit the carbon allocation and the other minor changes as multiple pull requests, let me know what you think.

parteh/PRTAllometricCarbonMod.F90 Show resolved Hide resolved
parteh/PRTAllometricCarbonMod.F90 Show resolved Hide resolved
parteh/PRTParametersMod.F90 Show resolved Hide resolved
parteh/PRTAllometricCarbonMod.F90 Show resolved Hide resolved
parteh/PRTAllometricCarbonMod.F90 Outdated Show resolved Hide resolved
@rgknox rgknox added the PR status: Not Ready The author is signaling that this PR is a work in progress and not ready for integration. label Apr 27, 2022
mpaiao added a commit to mpaiao/fates that referenced this pull request May 3, 2022
…ots and leaves are truly

proportional to demand.

Description:

1. Bug fix in DailyPRTAllometricCarbon (parteh/PRTAllometricCarbonMod.F90). When allocating
to different tissues, the code was subtracting allocation of tissues before calculating
the amount for the next tissue, potentially under-allocating carbon to fine roots.
2. Minor code updates to simplify allocation calculations. It now uses a single
allocation factor based on availability and total need, which is applied to all tissues.
3.  Replaced a few if statements with select case, which simplifies adding other hypotheses
in the future (and it's safer for selecting cases).

This pull request addresses the bug discussed in NGEET#784 and supersedes pull request NGEET#800.
Additional minor changes in former PR NGEET#800 will be added as subsequent pull requests.
@mpaiao
Copy link
Contributor Author

mpaiao commented May 4, 2022

Closing this pull request as it was superseded by #863, #864, #865, #866, and #867.

@mpaiao mpaiao closed this May 4, 2022
mpaiao added a commit to mpaiao/fates that referenced this pull request May 4, 2022
Implemented an option carbon allocation routine (DailyPRTAllometricCarbonSimpler
in parteh/PRTAllometricCarbonMod.F90). In this routine, I applied much simpler rules
for maintenance allocation: it simply checks how much each pool is in deficit, and
allocates carbon (storage + carbon_balance) to the pools according to the debt. If
there is any carbon left, then the plant finishes filling the storage pool and then
allocates to growth. This option is set by fates_parteh_mode=0, and will require
changing the valid options in the host land models (see example of changes for
CTSM in here).

This was extracted from the now defunct PR NGEET#800. Kept as a separate pull request if
we ever want to bring it to the mainline.
@mpaiao mpaiao deleted the carbon-alloc branch May 4, 2022 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - software engineering PR status: Not Ready The author is signaling that this PR is a work in progress and not ready for integration.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potentially incorrect allocation to fine roots in PRTAllometricCarbonMod.F90?
3 participants