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
Add FAN and fertilizer for crops #5981
Add FAN and fertilizer for crops #5981
Conversation
This adds the first round of the Flow of Agricultural Nitrogen (FAN) code which includes three new files, two with the FAN algorithms and one with the data stream.
Adds gridded nitrogen and phosphorus fertilizer. Adds fixed manure application if FAN is not used. If FAN is on, then uses FAN manure applications.
This commit allows ammonia emissions from FAN to couple with the atmosphere. Note that this feature is off by default and has not been tested with the full atmosphere or chemistry model.
There are several items addressed in this commit to improve the crop model. 1. First it resolves a bug in the crop model preventing bfb restart 2. Adds the missing components needed to collapse crop types that are not calibrated into ones that are known to the model. This allows placeholders of cfts so we don't have to keep changing the surface data files. 3. Resolves an issue with the cropseedc, cropseedn, and cropseedp so they don't keep growing negative every time the initial seed is given at planting.
This is the last of the FAN subroutine. It updates the mksurfdat routine to include the gridded fertilizer. Also updates some parameter and surface data files with the fertilizer. Finally, a test for FAN is included (default mode) only.
Bugfixes to get tests to pass
The land developer tests all passed, with diffs for all the smallvilleIA tests due to the new fertilizer datasets. All the tests with CN also fail the namelist check because there is a new fan namelist. A description of the feature can be found at: https://acme-climate.atlassian.net/wiki/spaces/DOC/pages/2237465109/B14+Flow+of+Agriculture+Nitrogen+Design+Document |
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.
Great job @bbye for getting the FAN implemented in E3SM and submitting the PR.
I only have minor edits for your consideration.
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.
- Please add units for
manure_n_transf_col
,nh3_otherfert_col
, andnh3_total_col
- Parenthesis are missing or not closed for few units.
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.
Thanks, this was due to a copy paste, it's fixed now.
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.
Minor typo - 'ammoniacal'
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 is the actual spelling (I looked it up to make sure), it refers to the ammonia component of nitrogen
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.
For the FanMod.F90 and FanUpdateMod.F90, please consider listing name of all subroutines after contains
.
For e.g.,
contains
procedure , public :: fanInit
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 didn't do this because I think it's generally done when defining a type. All the public subroutines are listed at the beginning of the module and I added some extra description about the flow of the FAN model in each of FanUpdateMod and FanMod.
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.
The listing of public functions is before the "contains" and there is a small block in each of the new files like this one in FanMod.F90.
private
public update_org_n
public eval_fluxes_storage
public update_npool
public update_4pool
public update_urea
You might want to add an inline comment for each of those explaining what they do.
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 went through FanMod and FanUpdateMod and added inline comments to all the public functions to briefly explain what they do.
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.
- Minor typo - The comment for tan_s3
! (gN/m2) total ammoniacal N in FAN pool S2
incorrectly calls it FAN pool S2. Same typo was incomponents/elm/src/biogeochem/CNNitrogenStateType.F90
- Initialization of all FAN variables - should it be nan or spval?
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.
Thanks, the typos are fixed and the initialization was changed to spval.
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 module has various subroutines and functions. Consider adding short notes on the top that explain the flow through various subroutines.
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.
Thanks, I added more description about the flow of the modules.
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.
Lines 9397 to 9430 can all be in a single crop_prog
loop instead of five separate if loops for crop_prog
.
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.
Thanks, this is now one loop.
Fixes some initialization, loop configuration, typos, and adds some more text describing FAN module.
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.
All comments have been addressed. I approve the PR for merging to the master.
Add more comments to FanMod and FanUpdateMod
Nice to see that this feature will be in master. Will this be turned on by default for BGC? |
@mingxuanwupnnl Sorry, I just saw your comment. This feature won't be on by default in v3 sims because it requires the crop model to be turned on and that won't be on by default in v3. However, we are planning to do some simulations with the crop model on and we can have FAN on with those. |
…tilizer_for_crops' into next (PR #5981) Adds Flow of Agriculture Nitrogen (ammonia emissions) to crop model. Adds gridded fertilizer for nitrogen and phosphorus. Adds manure application. All tests with CN biogeochemistry will have a namelist change. [BFB] except for crop tests. [NML] diff
merged to next |
@bbye some tests failed due to missing inputdata file |
@bbye I went ahead and added that file to the data server. Just have to check if any others are missing |
@bbye Also, it seems that I always get the error message
Attempting to use |
Reverted this PR for now. Need to investigate how the changes to the namelists are done. |
In Maybe there's a better solution, but having a missing file result in a fatal error seems to contradict the idea behind being able to download files from the data server to begin with. |
That sounds like the right solution. |
Update: There's another error message for a couple of Just haven't been able to properly test the fix the past couple of days due to perlmutter being down for maintenance |
@peterdschwartz any further progress? |
ELMBuilNamelist.pm : removed fatal_error call if missing files so that they can be downloaded from data server. shr_fan_mod.F90 : initialized fan_nh3_to_atm to .false. in case drv_flds_in doesn't exist for certain configs.
With the last round of testing, there were a few parameter and surfdata_map files that had to be added to the data server, and so far that seems to have fixed all the fails (though still waiting on a few). Hopefully it's straightforward to push these changes to your fork @bbye |
Thanks @peterdschwartz! I appreciate your help getting the PR fixed. |
…tilizer_for_crops' into next (PR #5981) Adds Flow of Agriculture Nitrogen (ammonia emissions) to crop model. Adds gridded fertilizer for nitrogen and phosphorus. Adds manure application. All tests with CN biogeochemistry will have a namelist change. [non-BFB] for crop tests. [NML]
Merged to next. Sucessfully re-ran the new FAN test to make sure the revert and re-merge worked as intended, so hopefully everything checks out tomorrow |
Merged to master. Submitted bless requests except for pm-cpu_intel which hasn't finished yet |
Thank you Peter for your help getting this PR in! |
Adds Flow of Agriculture Nitrogen (ammonia emissions) to crop model.
Adds gridded fertilizer for nitrogen and phosphorus.
Adds manure application.
All tests with CN biogeochemistry will have a namelist change.
[NML]
[non-BFB] for crop tests