Skip to content

Major refactor of NutrientCompetition / CNAllocation to provide hooks for AgSys crop model - #1705

Merged
billsacks merged 21 commits into
ESCOMP:masterfrom
billsacks:refactor_cnallocation
Apr 30, 2022
Merged

billsacks merged 21 commits into
ESCOMP:masterfrom
billsacks:refactor_cnallocation

Conversation

@billsacks

Copy link
Copy Markdown
Member

Description of changes

This PR separates the NutrientCompetition modules into pieces based on (1) consolidating duplicate code between the Clm45 and FlexibleCN versions, and (2) separating pieces that will vs. won't be used for crop patches when running with the upcoming AgSys crop model.

Specific notes

Contributors other than yourself, if any: Substantial consultation with @pengbinpeluo , as well as some with @danicalombardozzi and earlier conversations with @samsrabin

CTSM Issues Fixed (include github issue #):

Are answers expected to change (and if so in what way)? No

Any User Interface Changes (namelist or namelist defaults changes)? No

Testing performed, if any: Just a couple of tests so far

The two NutrientCompetition methods did exactly the same thing for the
start of calc_plant_nitrogen_demand, for the calculation of gpp, some MR
terms and availc. I have consolidated this duplicated code into a new
subroutine, calc_gpp_mr_availc.
This will support the incorporation of AgSys
I this this will become more useful as I do some further refactoring
This will facilitate splitting out different pieces into their own
subroutines.
Resolved Conflicts:
	src/biogeochem/CropType.F90
	src/biogeochem/NutrientCompetitionCLM45defaultMod.F90
	src/biogeochem/NutrientCompetitionFlexibleCNMod.F90
This way we can share this code between the different nutrient
competition methods rather than having it duplicated. It also gives us a
path towards skipping these calculations when running with AgSys.

One change I made in doing this refactor was changing allocation
fractions to always sum to 1, even in pre-emergence and when not
croplive... this shouldn't make any difference outside of the allocation
fractions themselves (and note that those aren't output to history
files, so I don't think this should lead to any answer changes).
This allows the duplicate code for the calculation of allometry (in both
nutrient competition methods) to be consolidated into a single
subroutine.
AgSys will specify time-varying C:N ratios for each plant component.
This commit provides placeholders for these, and changes the allocation
and nutrient competition code to use these potentially time-varying C:N
ratios rather than the constant parameters.

I will probably change some other uses of the C:N parameters as well,
but plan to do that in a follow-up commit.
This reverts commit 51241e8.

After further discussion, it isn't clear if we really want to get
time-varying C:N ratios from AgSys, and if we do, it isn't clear what
those should be and in which places we should use the time-varying vs.
time-constant C:N ratios. So for now we're sticking with the use of
pft-constant C:N ratios; we may revisit this later.
This lets us skip this call when running with AgSys - since the relevant
output variables will be calculated differently by AgSys.
This will make the code clearer when I introduce a similar subroutine
for use with AgSys.
@billsacks

Copy link
Copy Markdown
Member Author

I think this is close to ready. The main thing still needed is introducing a place-holder AgSys version of calc_npool_to_components_flexiblecn.

@billsacks billsacks added PR status: ready PR: this is ready to merge in, with all tests satisfactory and reviews complete and removed PR status: work in progress labels Apr 19, 2022
@billsacks
billsacks merged commit 69b9595 into ESCOMP:master Apr 30, 2022
@billsacks
billsacks deleted the refactor_cnallocation branch April 30, 2022 00:49
@slevis-lmwg slevis-lmwg mentioned this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR status: ready PR: this is ready to merge in, with all tests satisfactory and reviews complete

Projects

Status: Done (non release/external)

Development

Successfully merging this pull request may close these issues.

1 participant