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

Fan 2019 ctsm #767

Draft
wants to merge 209 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 149 commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
01c1153
FAN_n05_clm4_5_18_r272
Mar 14, 2018
2b6b2a8
Merge remote-tracking branch 'remotes/escomp/release-clm5.0' into fan…
Mar 16, 2018
5127039
point externals to fancpl branch
Mar 16, 2018
e23d599
first attempt, not quite working
Mar 19, 2018
f52f159
add handling of -fan option to CLMBuildNamelist
Mar 19, 2018
36c6d1a
Merge branch 'master' into fan-clm5-cpl (fix LND_TUNING_MODE)
Mar 20, 2018
f94ac48
FAN NH3 to coupler
Mar 20, 2018
63df80b
finally correct units for manure nitrogen
Mar 20, 2018
6c5185e
output name NH3_total -> NH3_TOTAL
Mar 20, 2018
0227fd3
non-negativity checks tweaked
Mar 21, 2018
cc8c864
manure unit conversion again
Mar 21, 2018
f4b7cbb
nh->nf
Mar 21, 2018
def5ee8
remove uninitilized fert_to_soil + increase bogus n_stored limit acco…
Mar 21, 2018
f591e8d
Handle size 1 tan pools correctly
Mar 22, 2018
c65ecf6
debugging: disarray between crop pheno and ndep, lower wtgcell thresh…
Mar 22, 2018
6b256ba
fix zeroing the fluxes
Mar 26, 2018
e20a808
other-fert output
Apr 4, 2018
138e09a
change to fancpl2 cime
Apr 4, 2018
b71f54b
fanstream attempt 1
Apr 4, 2018
59478df
variable fert fractions (2)
Apr 4, 2018
44333c9
mods from the summer 2018 experiments (1)
Jul 9, 2018
0910db2
drydep mods, clm side
Jul 9, 2018
2b4ba5b
Merge branch 'drydep-mods' of https://github.com/juliusvira/ctsm into…
Jul 9, 2018
bb2dc1e
cleanup
Jul 11, 2018
761bb11
fix tan_fract + mass check
Jul 11, 2018
9292097
fix typo
Jul 12, 2018
d744560
increased housing/storage emissions
Jul 17, 2018
5b9473a
version without drydep mods
Jul 17, 2018
feba86d
output field for manure in barns
Jul 20, 2018
772a6ba
Merge branch 'fan-clm5-cpl-poolmods' into fan-clm5-cpl-poolmods-nodd
Jul 20, 2018
2a408af
changed the flux formulations to what compost.py gives
Aug 14, 2018
615c290
fix indent
Nov 9, 2018
5d51bd1
soilwater tendency for fan
Nov 9, 2018
1514aed
initialize fan-watertend in coldstart
Nov 9, 2018
a9fd431
using watertend in cnndep (commented out0
Nov 9, 2018
3861750
tsl tendency unit
Dec 3, 2018
00442aa
fan physics updates + 3-way manure split
Jan 2, 2019
69036c0
3-way manure final
Jan 3, 2019
2de3aab
fert incorp reduction
Jan 3, 2019
5d02b4b
remove old FAN flux and state variables
Jan 3, 2019
e9fb310
fertilizer incorporation
Jan 3, 2019
691f61c
Merge branch 'remove-old-fan' into fan-2019
Jan 3, 2019
1cc8868
fanmod cleanup
Jan 3, 2019
940eb89
bug fix
Jan 4, 2019
6216a13
bug fix 2
Jan 4, 2019
53b8a83
comments
Jan 4, 2019
a3a0e5f
kads for slurry
Jan 10, 2019
03eff3a
tan fraction, slurry infiltration, inc. reduction
Jan 10, 2019
c37dd7f
fix conflicts v1
Jan 22, 2019
dc05bc0
trying to merge but probably need to do it differently
Feb 14, 2019
50db0da
removed old FANv1 fluxes and states
Feb 15, 2019
e82648d
cleanup
Feb 15, 2019
269816f
Merge branch 'master' of https://github.com/ESCOMP/ctsm into fan-2019…
Feb 15, 2019
290989c
animal housing (open/closed) modifications
Feb 15, 2019
6ed438b
Merge branch 'housingmods' of /glade/u/home/juliusv/fanruns2018/cesm/…
Feb 15, 2019
bb9e526
change cime to point at the fan-enabled version
Feb 15, 2019
ec44287
Avoid referring unallocate array in land-only runs
Feb 20, 2019
ca71111
Better checking for landunit indices
Feb 20, 2019
bdcff24
ndep2dyn_nml renamed to fan_nml and removed ndep3dyn_nml
Feb 22, 2019
d11bf70
refractoring with fan2ctsm interface module + preparation for includi…
Mar 4, 2019
6c41b79
Introducing fan pools & fluxes to the soil N balance check
Mar 4, 2019
de079be
namelist parameters for fan-bgc coupling
Mar 5, 2019
a95a6e1
add call to fan_eval
Mar 5, 2019
2e36926
debug the debug checks
Mar 5, 2019
da4a8c2
Merge branch 'fan-bgc-v2' of https://github.com/juliusvira/ctsm into …
Mar 5, 2019
6c11623
more bgc coupling + initialization
Mar 5, 2019
2f70072
Merge branch 'n-balance-check' of https://github.com/juliusvira/ctsm …
Mar 5, 2019
c040263
FanMod array interfaces, comments, etc
Mar 6, 2019
c0c311d
n-balance check debugged
Mar 6, 2019
27719f6
FAN namelist setup
Mar 6, 2019
561d9c8
merge array arg mods
Mar 6, 2019
5e51050
debug fan_to_bgc_crop namelist defaults
Mar 8, 2019
9540019
10**-ph -> 10**(-ph), etc
Mar 8, 2019
8687c20
more cleanup
Mar 12, 2019
b730f66
housing mods
Mar 13, 2019
807c639
slurry infiltration without precip + slurry diffusivity
Mar 13, 2019
108a0a7
van der molen liq diffusion + kads = 1
Mar 21, 2019
00d92f4
kelvin to c
Apr 3, 2019
5c359a3
more careful checking for column gridcell weight
May 6, 2019
fc1250f
more consistent treatment of slurry resistances
May 6, 2019
c5077c1
Merge fan-2019-gmdd-rc2
Jul 4, 2019
7c56648
remove printf and other cleanup
Jul 4, 2019
e7dda27
debug previous merge + use more debug_fan for checkings
Jul 4, 2019
b06931e
Add help for the -fan options
Jul 6, 2019
35bbe00
code cleanup
Jul 6, 2019
cfde300
merge from github
Jul 9, 2019
090ec9c
debug declaration order + make water_relax_t an argument for the wate…
Jul 9, 2019
5ca3cc4
remove commented out water_relax_t
Jul 9, 2019
be597f8
remove unnecessary changes to accumulated temperatures
Jul 10, 2019
802e8e6
debug fan-bgc coupling
Jul 11, 2019
57292f8
remove unnecessary variable
Jul 11, 2019
013ff57
guard agains negative windspeed (!)
Jul 12, 2019
bc183b1
make nh4 adsorption a namelist parameter
Jul 20, 2019
46ff6f7
add comments to the tsl tend evaluation
Jul 20, 2019
9a4b1fc
change the runoff variable to qflx_surf
Jul 24, 2019
34f3af1
Changed array assignments to filter loops
Jul 29, 2019
638f58f
Moved FAN soil moisture tendency to waterstatebulktype
Jul 29, 2019
0865091
separate variables for moisture tendency and moisture before SoilWate…
Jul 30, 2019
b110e2d
add check for arctic grass in addition to others
Aug 14, 2019
f8813d4
Remove !JV and !KO comments
Aug 14, 2019
7bea1d6
make array dimensions named constants
Aug 15, 2019
60fa182
manure_nh3 -> manure_nh4
Aug 15, 2019
4acfd5a
handle_storage_v2 -> handle_storage
Aug 15, 2019
4b086ec
fix subName
Aug 15, 2019
a755fb2
remove commented out lines
Aug 15, 2019
c723a9b
renamed fertilizer tan pools to match the convetion in the FANv2 desc…
Aug 15, 2019
bb1b661
renamed fert_runoff and manure_runoff to fert_nh4_runoff and manure_n…
Aug 15, 2019
ccffea1
comments
Aug 17, 2019
17df3a2
fix description of fract_spread_gass
Aug 17, 2019
8187f7f
ndep2 -> fan
Aug 17, 2019
4bcacf4
initialize fan state variables also for special columns
Sep 4, 2019
b68f23f
option for landless/mixed manure per crop/land area
Sep 4, 2019
9a80707
correct size for fluxes array
Sep 4, 2019
33bc7c8
remove moldrup parameterizations; make dz_layer arguement everywhere;…
Sep 4, 2019
629b78a
Merge branch 'fan-2019-ctsm' of github.com:juliusvira/ctsm into fan-2…
Sep 4, 2019
91c0dbf
Merge branch 'manure-pre-crop' into fan-2019-ctsm
Sep 5, 2019
2898dea
Merge branch 'fan-2019-ctsm' of https://github.com/juliusvira/ctsm in…
Sep 5, 2019
a13a64b
Merge branch 'fan-2019-ctsm' of https://github.com/juliusvira/ctsm in…
Sep 5, 2019
fd5ffab
make manure balance check include stores/barns
Sep 5, 2019
6f0e78c
Remove defunct storage balance check + make pH filling more obvious
Sep 10, 2019
b9d97f0
remove legacy state and flux variables
Sep 10, 2019
52de87d
remove legacy state and flux variables (2)
Sep 10, 2019
0d94113
Crash if fan nh3 requested to coupler but fan is off
Sep 10, 2019
8f1180e
Merge branch 'fan-2019-ctsm' of https://github.com/juliusvira/ctsm in…
Sep 10, 2019
6841dcb
Merge tag 'ctsm1.0.dev065' into fan-2019-ctsm
ekluzek Sep 19, 2019
ec1ff0d
If fan is off, let namelist be identical to without it, remove some e…
ekluzek Sep 19, 2019
ff5f125
Add a full fan driver fields namelist test to the other drv_flds name…
ekluzek Sep 19, 2019
6fc9a0d
Add in fan test mods and add fan tests to the test list, point to Eri…
ekluzek Sep 21, 2019
56f5798
Increase wallclock for longer FAN test
ekluzek Sep 21, 2019
42b434e
Remove some extra log output for FAN, add some extra timing for FAN, …
ekluzek Oct 1, 2019
a6b124a
Some changes to get it to compile with nag compile on izumi, argument…
ekluzek Oct 1, 2019
3c8bea8
Restore comment to CNNDeposition
Oct 1, 2019
2043e3a
added commits
Oct 2, 2019
f840649
added calculation of NFERTILIZATION depending on fan-bgc mode + new o…
Oct 2, 2019
84ddc73
zero nmanure if fan_to_bgc_crop
Oct 9, 2019
5692075
Use correct intent()
Oct 9, 2019
a1f9485
Fix wrong output variable pointer
Oct 9, 2019
4d26005
Rename MAN_ -> MANURE_; revise warning messages
Oct 9, 2019
bde3383
remove unused n_stored vars
Oct 18, 2019
c9d4304
fix initialization of nsynthfert
Oct 18, 2019
38638ad
variable naming, units, comments, etc
Dec 15, 2019
c2f9448
supposedly not answer changing changes after Bill Sacks' comments
Jan 18, 2020
21628ed
resolve conflicts
Jan 18, 2020
8b51ed4
fix argument intent
Jan 18, 2020
e75844b
Merge branch 'bill-sacks' of https://github.com/juliusvira/ctsm into …
Jan 18, 2020
facec5c
Use -abstol instead of +abstol to check for negativity
Jan 29, 2020
f21e04d
Fix array bounds, etc
Jan 29, 2020
e0e2fc5
Change the code to remove dependency of column/patch ordering
Feb 9, 2020
12a9857
remove unnecessary if block
Feb 9, 2020
1646e04
Merge tag 'ctsm1.0.dev097' into fan-2019-ctsm
ekluzek Aug 20, 2022
4b40337
Variable name changed
ekluzek Aug 22, 2022
e66a347
Change fan tests to f19_f19_mg17 since f19_f19_mg16 was having troubl…
ekluzek Aug 22, 2022
b529fb7
Make these cold starts so they will run, as otherwise it has a confli…
ekluzek Aug 26, 2022
32acf32
Put the cime hash that goes with this
ekluzek Aug 26, 2022
f638983
Add smallville single point tests for FAN
ekluzek Aug 30, 2022
d5b1e4c
Add a hack to allow three problematic points in the f19 grid to be se…
ekluzek Aug 30, 2022
b436dbb
Add the check for the three bad points to more places
ekluzek Aug 30, 2022
2b13f9e
More setting of the three points in FAN to zero, so that they will ru…
ekluzek Aug 30, 2022
51374ec
Also don't abort due to a Nbalance error when fan is on for the three…
ekluzek Aug 30, 2022
4334813
Add a cycle if landunit is tiny, protect another divide by tiny landu…
ekluzek Aug 31, 2022
c635d5a
If sgrz or ngrz are infinity from the manure stream file set them to …
ekluzek Aug 31, 2022
22de9df
Use shr_infnan_isinf rather than a comparison as the comparison fails
ekluzek Aug 31, 2022
459952b
Fix error in N balance check, turn off some of the changes for small …
ekluzek Sep 2, 2022
6ff603c
Add fan input/output to the balance check error
ekluzek Sep 2, 2022
7473335
Adjust FAN tests for what we expect to work
ekluzek Sep 2, 2022
1001dce
Add a FAN test month for longer simulations that has monthly output
ekluzek Sep 2, 2022
ce03b35
Set Inifinity from manure file to a large arbitrary value rather than…
ekluzek Sep 2, 2022
b7cb2f1
Add back changes for handling small land fraction, they do seem to be…
ekluzek Sep 2, 2022
a3fd227
Add a finidat file that's explicit for FAN so that we aren't doing co…
ekluzek Sep 2, 2022
19879da
Remove the cold start setting so that the finidat file can be used
ekluzek Sep 2, 2022
dce44b9
Add threaded FAN test fail to expected fails
ekluzek Sep 3, 2022
99de107
Merge tag 'ctsm5.1.dev021' into fan-2019-ctsm
ekluzek Sep 4, 2022
285b526
Update FAN tests for existing compset and make it a CLM51 compset
ekluzek Sep 5, 2022
80ed25b
Fix xml error, and add Vmct to all FAN tests
ekluzek Sep 5, 2022
368a5fa
Document problems with the nuopc cases
ekluzek Sep 6, 2022
b7ce4e3
Merge tag 'ctsm5.1.dev042' into fan-2019-ctsm
ekluzek Sep 7, 2022
c203f2e
Add a couple tests to the expected fail, due to downloading data
ekluzek Sep 7, 2022
f68cfc9
Merge tag 'ctsm5.1.dev062' into fan-2019-ctsm
ekluzek Sep 7, 2022
07a641f
Move location of fanStreams to MCT version of streams
ekluzek Sep 7, 2022
c9169e7
Make the same changes that went into ndepStreams in fanStreams
ekluzek Sep 7, 2022
67cf886
Smallville tests of FAN need to use a compset that has ROF off, so us…
ekluzek Sep 7, 2022
169f2f6
Change FAN single point compset tests to GSWP3 since Qian data only g…
ekluzek Sep 7, 2022
ede22be
Add initial version of FAN streams, that just adds the interfaces and…
ekluzek Sep 8, 2022
07653f4
Fixes so will compile
ekluzek Sep 8, 2022
a24fb20
add missing use statement for shr_mpi_mod bcast method
ekluzek Sep 8, 2022
62f4d18
gnu compiler requires string lengths to be identical
ekluzek Sep 8, 2022
1596900
Add more files to the unit test build since they are now needed with …
ekluzek Sep 9, 2022
3427431
Update repository to point to my fork to get the branch for cpl7 and …
ekluzek Sep 9, 2022
cdee600
Merge tag 'ctsm5.1.dev108' into fan-2019-ctsm
ekluzek Sep 9, 2022
86bb9a4
Use new get_curr_days_per_year in FAN streams which is required in th…
ekluzek Sep 9, 2022
43cc324
Move shr_fan from share to cmeps, so change so share is standard, and…
ekluzek Sep 9, 2022
aa4d65b
Add path for lilac to shr_fan_mod.F90 under cmeps so that LILAC can b…
ekluzek Sep 10, 2022
521686c
Add an update to cmeps
ekluzek Sep 13, 2022
9b6a56d
Add passing of FAN fields to atm Fall_FANflxnh3 for NUOPC case
ekluzek Sep 13, 2022
ee8ef31
Add code to handle reading in the FAN streams for nuopc
ekluzek Sep 13, 2022
7ea2c77
Add a default NUOPC version of each of the FAN MCT tests
ekluzek Sep 13, 2022
757baa0
Add a test for a NEON AG site with FAN on
ekluzek Sep 13, 2022
63be0ed
Get to compile on nag compiler on izumi
ekluzek Sep 14, 2022
0fe26fc
Make KONA test case a BGC-CROP compset and add a I1PT BGC-CROP compset
ekluzek Sep 14, 2022
136d23f
Mark FAN NUOPC threaded test as an expected fail
ekluzek Sep 14, 2022
d08dbd9
Update cmeps externals with changes needed for FAN
ekluzek Sep 16, 2022
90f5e39
Set FAN meshfile and make name consistent with new CMEPS
ekluzek Sep 16, 2022
613c8bf
Merge branch 'fan-2019-ctsm' of github.com:juliusvira/ctsm into fan-2…
ekluzek Sep 16, 2022
22e0add
Update cpl7 so shr_fan_mod is included
ekluzek Sep 16, 2022
02526e5
Merge branch 'fan-2019-ctsm' of github.com:juliusvira/ctsm into fan-2…
ekluzek Sep 16, 2022
020704c
Add dummy_mesh argument, because it's required for the NUOPC interfac…
ekluzek Sep 16, 2022
625c225
Add shr_assert to check array size, and switch to loops over array co…
ekluzek Sep 21, 2022
84f9ca3
Change izumi_nag non debug tests to izumi_intel for FAN since DEBUG t…
ekluzek Sep 21, 2022
326bd8c
Add a stub ROF Hist Clm51 Bgc-Crop compset
ekluzek Sep 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ required = True
[cime]
local_path = cime
protocol = git
repo_url = https://github.com/ESMCI/cime
tag = branch_tags/cime5.8.3_chint17-05
repo_url = https://github.com/ekluzek/cime
branch = fancpl2-up-merge
required = True

[externals_description]
Expand Down
155 changes: 153 additions & 2 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# 2012-07-01 Kluzek Add some common CESM namelist options
# 2013-12 Andre Refactor everything into subroutines
# 2013-12 Muszala Add Ecosystem Demography functionality
# 2016-09-20 Oleson Add ndep2 and ndep3 streams capability
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 assuming these names are for the new manure streams, but I think @ekluzek asked for these ndep2 & 3 to be replace with more descriptive names. would it be helpful to use consistent terminology?

Copy link
Author

Choose a reason for hiding this comment

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

I guess the comment can be changed. Is this modification list still updated?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@juliusvira as you can see we don't keep that list updated very often. And only sometimes update it with something that is pretty major. Since, git keeps track of the history, I don't tend to use this revision history.

So I'd recommend just deleting this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • remove this from the PR

#--------------------------------------------------------------------------------------------

package CLMBuildNamelist;
Expand Down Expand Up @@ -162,6 +163,11 @@ OPTIONS
(can ONLY be turned on when BGC type is 'cn' or 'bgc')
This turns on the namelist variable: use_cndv
(Deprecated, this will be removed)
-fan "mode" Set how and if FAN is run: atm|soil|full|on|off
If "on", FAN is enabled but not connected to atmosphere or
soil biogeochemistry. If "full", both connections are
active. The soil and atmosphere coupling can be enabled
selectively with the "soil" and "atm" modes.
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me. @ekluzek how are multiple flags like this handled elsewhere in the code?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, should we make it clear here, or elsewhere in the code that when 'soil' is active we're really just talking about soil in crop columns, as FAN manure inputs are put onto non-crop columns, but these fluxes are not considered in the current implementation?

Copy link
Member

Choose a reason for hiding this comment

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

@ekluzek I think we have discussed moving away from having namelist opts like this, because they're confusing for the user - instead using just namelist variables where possible, or xml variables where we need something that controls a number of other things. Do you agree?

Copy link
Author

Choose a reason for hiding this comment

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

There is actually a namelist option to enable FAN fluxes also for non-crops, but it is off by default.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@juliusvira the point is that simple namelist options shouldn't be added as a command line option to build-namelist. The command line options are for things that are complicated and involve many namelist items. And as @billsacks points out if needed a xml option could also be added. But, in this case it looks like there could be a single simple namelist option that can control FAN. So it's something that can just be turned on by adding it to the user_nl_clm file. I think that's a better user interface for FAN than through the build-namelist command line.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • @ekluzek can you check this is being handled correctly & if so resolve this conversation

-fire_emis Produce a fire_emis_nl namelist that will go into the
"drv_flds_in" file for the driver to pass fire emissions to the atm.
(Note: buildnml copies the file for use by the driver)
Expand Down Expand Up @@ -265,6 +271,7 @@ sub process_commandline {
chk_res => undef,
note => undef,
drydep => 0,
fan => "default",
output_reals_filename => undef,
fire_emis => 0,
megan => "default",
Expand Down Expand Up @@ -292,6 +299,7 @@ sub process_commandline {
"clm_usr_name=s" => \$opts{'clm_usr_name'},
"envxml_dir=s" => \$opts{'envxml_dir'},
"drydep!" => \$opts{'drydep'},
"fan=s" => \$opts{'fan'},
"fire_emis!" => \$opts{'fire_emis'},
"ignore_warnings!" => \$opts{'ignore_warnings'},
"chk_res!" => \$opts{'chk_res'},
Expand Down Expand Up @@ -508,7 +516,8 @@ sub read_namelist_defaults {
"$cfgdir/namelist_files/namelist_defaults_ctsm.xml",
"$cfgdir/namelist_files/namelist_defaults_drv.xml",
"$cfgdir/namelist_files/namelist_defaults_fire_emis.xml",
"$cfgdir/namelist_files/namelist_defaults_drydep.xml" );
"$cfgdir/namelist_files/namelist_defaults_drydep.xml",
"$cfgdir/namelist_files/namelist_defaults_fan.xml" );

# Add the location of the use case defaults files to the options hash
$opts->{'use_case_dir'} = "$cfgdir/namelist_files/use_cases";
Expand Down Expand Up @@ -1504,6 +1513,7 @@ sub process_namelist_inline_logic {
setup_logic_subgrid($opts, $nl_flags, $definition, $defaults, $nl);
setup_logic_fertilizer($opts, $nl_flags, $definition, $defaults, $nl);
setup_logic_grainproduct($opts, $nl_flags, $definition, $defaults, $nl, $physv);
setup_logic_fan($opts, $nl_flags, $definition, $defaults, $nl, $physv);
setup_logic_soilstate($opts, $nl_flags, $definition, $defaults, $nl);
setup_logic_demand($opts, $nl_flags, $definition, $defaults, $nl);
setup_logic_surface_dataset($opts, $nl_flags, $definition, $defaults, $nl);
Expand Down Expand Up @@ -1562,6 +1572,11 @@ sub process_namelist_inline_logic {
###############################
setup_logic_nitrogen_deposition($opts, $nl_flags, $definition, $defaults, $nl);

################################
# namelist group: fan_nml #
################################
# setup_logic_fan_nml($opts, $nl_flags, $definition, $defaults, $nl, $physv);

##################################
# namelist group: cnmresp_inparm #
##################################
Expand Down Expand Up @@ -2971,6 +2986,61 @@ sub setup_logic_fertilizer {

#-------------------------------------------------------------------------------

sub setup_logic_fan {
#
# Flags to control FAN (Flow of Agricultural Nitrogen) nitrogen deposition (manure and fertilizer)
#
my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_;
my $fan_mode = $opts->{'fan'};

if ($fan_mode eq 'default') { $fan_mode = 'off'; }

if (!($fan_mode =~ /atm|soil|full|on|off/)) {
$log->fatal_error("fan_mode not one of atm, soil, full, on, off\n" );
}

if ( !($fan_mode eq 'off') ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_fan',
'fan_mode'=>$fan_mode );

$nl_flags->{'use_fan'} = $nl->get_value('use_fan');
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_nh3_to_atm',
'fan_mode'=>$fan_mode);
$nl_flags->{'fan_nh3_to_atm'} = $nl->get_value('fan_nh3_to_atm');

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_mapalgo');
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_fan',
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_fan',
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
# Set align year, if first and last years are different
#if ( $nl->get_value('stream_year_first_fan') != $nl->get_value('stream_year_last_fan') ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'model_year_align_fan',
'sim_year'=>$nl_flags->{'sim_year'}, 'sim_year_range'=>$nl_flags->{'sim_year_range'});
#}
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_fan');
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_to_bgc_crop',
'fan_mode'=>$fan_mode);
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_to_bgc_veg',
'fan_mode'=>$fan_mode);
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fract_spread_grass',
'fan_mode'=>$fan_mode);
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'nh4_ads_coef',
'fan_mode'=>$fan_mode);
} else {
$nl_flags->{'use_fan'} = ".false.";
}

if ( &value_is_true( $nl_flags->{'use_ed'} ) && &value_is_true( $nl_flags->{'use_fan'} ) ) {
$log->fatal_error("Cannot turn use_fan on when use_ed is on\n" );
}
if ( !&value_is_true( $nl_flags->{'use_crop'} ) && &value_is_true( $nl_flags->{'use_fan'} ) ) {
$log->fatal_error("Cannot turn use_fan on when use_crop is off\n" );
}
}

#-------------------------------------------------------------------------------

sub setup_logic_grainproduct {
#
# Flags to control 1-year grain product pool
Expand Down Expand Up @@ -3127,6 +3197,79 @@ sub setup_logic_nitrogen_deposition {
}
}

#-------------------------------------------------------------------------------

sub setup_logic_fan_nml {
my ($opts, $nl_flags, $definition, $defaults, $nl, $physv) = @_;

#
# Nitrogen deposition2 for bgc=CN
#

if ( $nl_flags->{'bgc_mode'} ne "none" && value_is_true( $nl_flags->{'use_fan'} ) ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_mapalgo', 'phys'=>$nl_flags->{'phys'},
'bgc'=>$nl_flags->{'bgc_mode'}, 'hgrid'=>$nl_flags->{'res'},
'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_fan', 'phys'=>$nl_flags->{'phys'},
'bgc'=>$nl_flags->{'bgc_mode'}, 'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_fan', 'phys'=>$nl_flags->{'phys'},
'bgc'=>$nl_flags->{'bgc_mode'}, 'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});

# Set align year, if first and last years are different
if ( $nl->get_value('stream_year_first_fan') != $nl->get_value('stream_year_last_fan') ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'model_year_align_fan', 'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
}

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_fan', 'phys'=>$nl_flags->{'phys'},
'bgc'=>$nl_flags->{'bgc_mode'},
'hgrid'=>"360x720cru" );

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_to_bgc_crop',
'use_cn'=>$nl_flags->{'use_cn'}, 'use_ed'=>$nl_flags->{'use_ed'} );
$nl_flags->{'fan_to_bgc_crop'} = $nl->get_value('fan_to_bgc_crop');
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_to_bgc_veg',
'use_cn'=>$nl_flags->{'use_cn'}, 'use_ed'=>$nl_flags->{'use_ed'} );
$nl_flags->{'use_veg'} = $nl->get_value('fan_to_bgc_veg');


} elsif ( $nl_flags->{'bgc_mode'} =~/cn|bgc/ && value_is_true( $nl_flags->{'use_fan'} ) ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'fan_mapalgo', 'phys'=>$nl_flags->{'phys'},
'use_cn'=>$nl_flags->{'use_cn'}, 'hgrid'=>$nl_flags->{'res'},
'clm_accelerated_spinup'=>$nl_flags->{'clm_accelerated_spinup'} );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_first_fan', 'phys'=>$nl_flags->{'phys'},
'use_cn'=>$nl_flags->{'use_cn'}, 'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_year_last_fan', 'phys'=>$nl_flags->{'phys'},
'use_cn'=>$nl_flags->{'use_cn'}, 'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
# Set align year, if first and last years are different
if ( $nl->get_value('stream_year_first_fan') != $nl->get_value('stream_year_last_fan') ) {
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'model_year_align_fan', 'sim_year'=>$nl_flags->{'sim_year'},
'sim_year_range'=>$nl_flags->{'sim_year_range'});
}
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_fan', 'phys'=>$nl_flags->{'phys'},
'use_cn'=>$nl_flags->{'use_cn'},
'hgrid'=>"360x720cru" );
} else {
# If bgc is NOT CN/CNDV then make sure none of the fan settings are set!
if ( value_is_true( $nl_flags->{'use_fan'} ) ) {
if ( defined($nl->get_value('stream_year_first_fan')) ||
defined($nl->get_value('stream_year_last_fan')) ||
defined($nl->get_value('model_year_align_fan')) ||
defined($nl->get_value('stream_fldfilename_fan'))
) {
fatal_error("When bgc is NOT CN or CNDV none of: stream_year_first_fan," .
"stream_year_last_fan, model_year_align_fan, nor stream_fldfilename_fan" .
" can be set!\n");
}
}
}
}


#-------------------------------------------------------------------------------

sub setup_logic_cnmresp {
Expand Down Expand Up @@ -3742,6 +3885,9 @@ sub write_output_files {
push @groups, "lifire_inparm";
push @groups, "ch4finundated";
push @groups, "clm_canopy_inparm";
if ( &value_is_true($nl_flags->{'use_fan'}) ) {
push @groups, "fan_nml";
}
if (remove_leading_and_trailing_quotes($nl->get_value('snow_cover_fraction_method')) eq 'SwensonLawrence2012') {
push @groups, "scf_swenson_lawrence_2012_inparm";
}
Expand All @@ -3753,6 +3899,9 @@ sub write_output_files {

# Drydep, fire-emission or MEGAN namelist for driver
@groups = qw(drydep_inparm megan_emis_nl fire_emis_nl carma_inparm);
if ( &value_is_true($nl_flags->{'use_fan'}) ) {
push @groups, "fan_inparm";
}
$outfile = "$opts->{'dir'}/drv_flds_in";
$nl->write($outfile, 'groups'=>\@groups, 'note'=>"$note" );
$log->verbose_message("Writing @groups namelists to $outfile");
Expand Down Expand Up @@ -3838,8 +3987,8 @@ sub add_default {

# check whether the variable has a value in the namelist object -- if so then skip to end
my $val = $nl->get_variable_value($group, $var);
if (! defined $val) {

if (! defined $val) {
# Look for a specified value in the options hash

if (defined $settings{'val'}) {
Expand Down Expand Up @@ -4372,6 +4521,7 @@ sub version {

sub main {
my %nl_flags;

$nl_flags{'cfgdir'} = dirname(abs_path($0));

my %opts = process_commandline(\%nl_flags);
Expand All @@ -4386,6 +4536,7 @@ sub main {
my $definition = read_namelist_definition($cfgdir, \%opts, \%nl_flags);
my $defaults = read_namelist_defaults($cfgdir, \%opts, \%nl_flags, $cfg);


# List valid values if asked for
list_options(\%opts, $definition, $defaults);

Expand Down
61 changes: 61 additions & 0 deletions bld/namelist_files/namelist_defaults_ctsm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,15 @@ attributes from the config_cache.xml file (with keys converted to upper-case).
<!-- Plant hydraulic stress -->
<use_hydrstress >.false.</use_hydrstress>
<use_hydrstress phys="clm5_0" use_fates=".false." configuration="clm">.true.</use_hydrstress>

<!-- flow of agricultural nitrogen (fan) model -->
<use_fan>.false.</use_fan>
<use_fan fan_mode='atm'>.true.</use_fan>
<use_fan fan_mode='on'>.true.</use_fan>
<use_fan fan_mode='soil'>.true.</use_fan>
<use_fan fan_mode='full'>.true.</use_fan>

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to see simulations that use these name list conventions, especially for use_fan = .false. (which I would assume is the default configuration. see comments in #636.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • @juliusvira I know you've shared this at some point, but maybe easier to share a link to goggle drive with slides so others (including me) can see them again

Copy link
Author

Choose a reason for hiding this comment

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


<!--

Initial condition files to use and or interpolate from
Expand Down Expand Up @@ -1026,6 +1035,58 @@ lnd/clm2/surfdata_map/surfdata_ne120np4_78pfts_CMIP6_simyr1850_c170824.nc</fsurd
<ndepmapalgo use_cn=".true." hgrid="1x1_asphaltjungleNJ" >nn</ndepmapalgo>
<ndepmapalgo use_cn=".true." hgrid="5x5_amazon" >nn</ndepmapalgo>

<!--KO-->
<!-- FAN Nitrogen (manure) deposition streams namelist defaults -->
<stream_year_first_fan sim_year="2000" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="2000" >2010</stream_year_last_fan>

<stream_year_first_fan sim_year="1850" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="1850" >2010</stream_year_last_fan>

<stream_year_first_fan sim_year="1000" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="1000" >2010</stream_year_last_fan>

<model_year_align_fan >2010</model_year_align_fan>

<stream_year_first_fan sim_year="constant" sim_year_range="1000-1002" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="constant" sim_year_range="1000-1002" >2010</stream_year_last_fan>

<stream_year_first_fan sim_year="constant" sim_year_range="1000-1004" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="constant" sim_year_range="1000-1004" >2010</stream_year_last_fan>

<stream_year_first_fan sim_year="constant" sim_year_range="1850-2000" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="constant" sim_year_range="1850-2000" >2010</stream_year_last_fan>

<stream_year_first_fan sim_year="constant" sim_year_range="1850-2100" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="constant" sim_year_range="1850-2100" >2010</stream_year_last_fan>

<stream_year_first_fan sim_year="constant" sim_year_range="2000-2100" >2010</stream_year_first_fan>
<stream_year_last_fan sim_year="constant" sim_year_range="2000-2100" >2010</stream_year_last_fan>

<stream_fldfilename_fan>lnd/clm2/paramdata/FAN_nitrogen_soilph_fv1.9x2.5_simyr2010_c20190905.nc</stream_fldfilename_fan>

<fan_mapalgo >bilinear</fan_mapalgo>

<fan_mapalgo hgrid="1x1_brazil" >nn</fan_mapalgo>
<fan_mapalgo hgrid="1x1_mexicocityMEX" >nn</fan_mapalgo>
<fan_mapalgo hgrid="1x1_vancouverCAN" >nn</fan_mapalgo>
<fan_mapalgo hgrid="1x1_urbanc_alpha" >nn</fan_mapalgo>
<fan_mapalgo hgrid="1x1_camdenNJ" >nn</fan_mapalgo>
<fan_mapalgo hgrid="1x1_asphaltjungleNJ" >nn</fan_mapalgo>
<fan_mapalgo hgrid="1x1_tropicAtl" >nn</fan_mapalgo>
<fan_mapalgo hgrid="5x5_amazon" >nn</fan_mapalgo>

ekluzek marked this conversation as resolved.
Show resolved Hide resolved
<fan_to_bgc_crop fan_mode="soil">.true.</fan_to_bgc_crop>
<fan_to_bgc_crop fan_mode="full">.true.</fan_to_bgc_crop>
<fan_to_bgc_crop fan_mode="atm">.false.</fan_to_bgc_crop>
<fan_to_bgc_crop fan_mode="on">.false.</fan_to_bgc_crop>
<fan_to_bgc_veg>.false.</fan_to_bgc_veg>
<fract_spread_grass fan_mode="on">1.0</fract_spread_grass>
<fract_spread_grass fan_mode="soil">0.0</fract_spread_grass>
wwieder marked this conversation as resolved.
Show resolved Hide resolved
<fract_spread_grass fan_mode="full">0.0</fract_spread_grass>
<fract_spread_grass fan_mode="atm">1.0</fract_spread_grass>
<nh4_ads_coef>1.0</nh4_ads_coef>

<!-- LAI streams namelist defaults -->
<use_lai_streams >.false.</use_lai_streams>
<stream_year_first_lai >2001</stream_year_first_lai>
Expand Down
20 changes: 20 additions & 0 deletions bld/namelist_files/namelist_defaults_fan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="namelist_defaults.xsl"?>

<namelist_defaults>

<!--
Values to use by default for creation of CLM model driver namelists.
The element names are the same as the corresponding namelist
variables. Values that depend on the model configuration use
attributes to express the dependency. The recognized attributes
are: RESOLUTION, defaults, mask, ic_ymd, ic_tod, sim_year and all configuration
attributes from the config_cache.xml file (with keys converted to upper-case).
-->

<fan_nh3_to_atm use_fan=".false.">.false.</fan_nh3_to_atm>
<fan_nh3_to_atm use_fan=".true." fan_mode="atm">.true.</fan_nh3_to_atm>
<fan_nh3_to_atm use_fan=".true." fan_mode="full">.true.</fan_nh3_to_atm>

</namelist_defaults>
1 change: 1 addition & 0 deletions bld/namelist_files/namelist_defaults_usr_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ provided they are in the valid list expressed above.

<!-- Surface dataset (relative to ${csmdata}) -->
<fsurdat phys="clm4_5">lnd/clm2/surfdata_map/surfdata_${clm_usr_name}_simyr${sim_year}.nc</fsurdat>
<fsurdat phys="clm5_0">lnd/clm2/surfdata_map/surfdata_${clm_usr_name}_simyr${sim_year}.nc</fsurdat>
wwieder marked this conversation as resolved.
Show resolved Hide resolved

<!-- Dynamic PFT surface dataset (relative to ${csmdata}) -->
<flanduse_timeseries sim_year_range="constant" rcp="-999.9">null</flanduse_timeseries>
Expand Down
Loading