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

Extend CNFireMethodMod with a FATESFireData class #991

Merged
merged 34 commits into from
Jul 23, 2020

Conversation

slevis-lmwg
Copy link
Contributor

Description of changes

Allow FATES access to CTSM's infrastructure that reads lightning and
human population data sets for use in SPITFIRE.

Following @ekluzek's detailed recommendations in #982 #983 .

Specific notes

Contributors other than yourself, if any:
@ekluzek @rgknox @ckoven @lmkueppers @jkshuman

CTSM Issues Fixed (include github issue #):
#982 #983
Also relates directly to issue NGEET/fates#562
and to pull request NGEET/fates#635

Are answers expected to change (and if so in what way)?
Not in non-FATES simulations.
Not in FATES simulations using use_fates_spitfire < 2
Yes in FATES simulations using use_fates_spitfire >= 2

Any User Interface Changes (namelist or namelist defaults changes)?
Changing use_fates_spitfire from logical to integer with valid values of:
0 for no fire
1 for spitfire with default lightning constant
2 for spitfire with Li et al lightning data
3 for spitfire with successful ignitions data
as recommended by @rgknox here

Testing performed, if any:
Code builds. No further testing, yet.

Following @ekluzek's recommendations in ESCOMP#982.
Purpose: Allow FATES access to CTSM's infrastructure that reads lightning and
human population data sets for use in SPITFIRE.
Copy link
Collaborator

@ekluzek ekluzek left a comment

Choose a reason for hiding this comment

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

@slevisconsulting there's a little bit of misunderstanding about the object oriented class structure here. I gave some guidance, but we should probably go through this again after you've gone through it. But, it does look close!

bld/namelist_files/namelist_defaults_clm4_5.xml Outdated Show resolved Hide resolved
bld/namelist_files/namelist_definition_clm4_5.xml Outdated Show resolved Hide resolved
src/biogeochem/FATESFireNoDataMod.F90 Outdated Show resolved Hide resolved
src/biogeochem/FATESFireNoDataMod.F90 Outdated Show resolved Hide resolved
src/main/clm_initializeMod.F90 Outdated Show resolved Hide resolved
@@ -606,6 +614,14 @@ subroutine initialize2( )
call crop_inst%initAccVars(bounds_proc)
end if

! use_fates_spitfire is assigned an integer value in the namelist
! see bld/namelist_files/namelist_definition_clm4_5.xml for details
if (use_fates_spitfire > 1) then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just call the generic one rather than the specific one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment.

src/main/clm_instMod.F90 Outdated Show resolved Hide resolved
src/main/clm_instMod.F90 Outdated Show resolved Hide resolved
src/utils/clmfates_interfaceMod.F90 Outdated Show resolved Hide resolved
@slevis-lmwg
Copy link
Contributor Author

@ekluzek pls see my responses and revisions. If I am on the wrong track, let's definitely have a meeting.

Copy link
Collaborator

@ekluzek ekluzek left a comment

Choose a reason for hiding this comment

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

I updated my comments and responded to your questions...

bld/namelist_files/namelist_defaults_clm4_5.xml Outdated Show resolved Hide resolved
bld/namelist_files/namelist_defaults_clm4_5.xml Outdated Show resolved Hide resolved
src/biogeochem/FATESFireNoDataMod.F90 Outdated Show resolved Hide resolved
src/biogeochem/FATESFireNoDataMod.F90 Show resolved Hide resolved
src/biogeochem/FATESFireNoDataMod.F90 Show resolved Hide resolved
src/main/clm_driver.F90 Outdated Show resolved Hide resolved
src/main/clm_initializeMod.F90 Outdated Show resolved Hide resolved
src/main/clm_instMod.F90 Outdated Show resolved Hide resolved
@ekluzek
Copy link
Collaborator

ekluzek commented May 4, 2020

@slevisconsulting so Init2 and InterpFileInputs should go into clmfates_interface, rather than to the extensions of the Fire classes for FATES.

I think it will help to have the general conversation about the Fire class methods and the refactoring I'm proposing to make sure you are clear on some of the OO concepts being used here. So I think we should plan on that before you proceed forward. We can make sure we talk about what I specifically plan on doing, as well as what you need to do here.

I think most of the conversations can be resolved now. So I'll go through and make sure I do that. There are only a couple that will be outstanding. Once we go through there will only be a couple last changes to make.

@ekluzek ekluzek added PR status: work in progress enhancement new capability or improved behavior of existing capability labels May 4, 2020
Removed from FATESFire[No]DataMod.
Added to clmfates_interfaceMod.
Updated calls in clm_driver and clm_initialize.
...since FATES only needs lightning for now.
src/main/clm_driver.F90 Outdated Show resolved Hide resolved
@ekluzek
Copy link
Collaborator

ekluzek commented May 8, 2020

I am seeing changes that are needed now that I'm looking directly at the code. There's a couple ways to proceed. I can figure out the changes and post the diff needed, or I could try to explain inline in github, or. I could submit a PR to your branch, or lastly if you authorize me -- I can push directly to your branch. Which of those sound like the best solution?

@slevis-lmwg
Copy link
Contributor Author

I am seeing changes that are needed now that I'm looking directly at the code. There's a couple ways to proceed. I can figure out the changes and post the diff needed, or I could try to explain inline in github, or. I could submit a PR to your branch, or lastly if you authorize me -- I can push directly to your branch. Which of those sound like the best solution?

I think simplest for me would be to authorize you to push directly to my branch. How do I do that?

src/main/clm_instMod.F90 Outdated Show resolved Hide resolved
@ekluzek
Copy link
Collaborator

ekluzek commented May 8, 2020

Go to your fork to CTSM on github. Go to settings tab on the right top, and then "manage access" option on the left down one. Then you can add me as a collaborator. At some point it asks you to enter your password.

It'll send me an email and then I just need to accept it. I've done this with several people and it makes it a little easier to work on the same code together. Sometimes if there's something more extensive I'll still do a Pull Request, to their branch, so they can code review it beforehand. But, here we are talking about small changes. So I'll get it working for a simple case and then push my commits to your branch. I'll try to explain as well as I can in the commit notes.

Thanks.

@slevis-lmwg
Copy link
Contributor Author

It'll send me an email and then I just need to accept it.

Ok, you should get a email.

Thanks @ekluzek

ekluzek added 2 commits May 8, 2020 14:49
…terface

These are the changes that I see that are needed  to keep fates_fire_data_method
local to clmfates_interface. Whenever fates_fire_data is accessed it has to be
done through clmfates_interface, because that's the object that contains it and has
it instantiated. We also will want it to be private to clmfates_interface, so it
can't be accessed or changed outside of there.

There were some stubs here to pass specific instances of the class types before, but
they weren't completed. So those are all removed and the generic method is being
accessed so that you don't have to know which specific instance is being used.

Testing: I haven't tested it yet. But, will before pushing
Testing with
./create_test ERS_D_Lm36.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-Fates_nat_and_anthro_ignitions
@@ -945,18 +945,12 @@ sub setup_cmdl_fire_light_res {
}
if ( defined($fire_method) && $fire_method eq "nofire" ) {
$nl_flags->{$var} = ".false.";
} elsif ( &value_is_true($nl->get_value('use_cn')) ) {
# } elsif ( &value_is_true($nl->get_value('use_cn')) || $nl_flags->{'fates_spitfire_mode'} > 1 ) {
} elsif ( &value_is_true($nl->get_value('use_cn')) || &value_is_true($nl->get_value('use_fates')) ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New line 949 works

    } elsif ( &value_is_true($nl->get_value('use_cn')) || &value_is_true($nl->get_value('use_fates')) ) {

However, I wish the commented-out line above it would work because it would narrow things down, but it doesn't work. The run proceeds to the next else and sets cnfireson = .false..

@ekluzek do you see an obvious problem with new line 948?

@slevis-lmwg
Copy link
Contributor Author

FATES testing passes except for the restart test that was already failing as reported in #667 .

This PR is now ready for review again:
@glemieux do you recommend the reviews be done before the upcoming re-basing?
Either way, I am requesting reviews from @ekluzek and @glemieux . All others are welcome to review if interested.

@slevis-lmwg slevis-lmwg requested a review from rgknox July 12, 2020 23:59
@glemieux
Copy link
Collaborator

@slevisconsulting yes, ideally the reviews would be completed before the rebase so as to bring in the a consistent set of code that includes review change requests. That said, if there are non-critical change requests that could be brought in later without much hassle and tests are all passing, I'm inclined to rebase this sooner rather that later. Can you point me to the test directory on cheyenne for confirmation, please?

@slevis-lmwg
Copy link
Contributor Author

Can you point me to the test directory on cheyenne for confirmation, please?

You prob. already know this: While Cheyenne is down, you can access the same directory from Casper:
/glade/scratch/slevis/clmfates_tests

Note that this test
ERS_D_Lm12.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-Fates_nat_and_anthro_ignitions
came back as a FAIL because it timed out. I ran a longer variation on this test that PASSed:
/glade/scratch/slevis/ERS_D_Lm36.1x1_brazil.I2000Clm50FatesCruGs.cheyenne_intel.clm-Fates_nat_and_anthro_ignitions.20200712_122433_bhgfz5

@glemieux
Copy link
Collaborator

Can you point me to the test directory on cheyenne for confirmation, please?

You prob. already know this: While Cheyenne is down, you can access the same directory from Casper:

I didn't know that; thanks for the tip!

Copy link
Contributor

@jkshuman jkshuman left a comment

Choose a reason for hiding this comment

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

@slevisconsulting I added a few comments and questions.

bld/namelist_files/namelist_definition_clm4_5.xml Outdated Show resolved Hide resolved
@@ -822,7 +822,7 @@ sub make_env_run {
conopts=>"-phys clm4_0",
},
"usespitfireButNOTFATES" =>{ options=>"-envxml_dir . -no-megan",
Copy link
Contributor

Choose a reason for hiding this comment

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

does this allow use spitfire without FATES? The name suggests that to me...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jkshuman this belongs to a list of options that trigger namelist FAILs. The specific one triggers a failure if fates_spitfire_mode > 0 and -bgc has not been set to fates.

@@ -474,6 +474,12 @@ subroutine initialize2( )
end if
else
call SatellitePhenologyInit(bounds_proc)

! fates_spitfire_mode is assigned an integer value in the namelist
! see bld/namelist_files/namelist_definition_clm4_5.xml for details
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
! see bld/namelist_files/namelist_definition_clm4_5.xml for details
! see bld/namelist_files/namelist_definition_clm4_5.xml for details
! ignitions: 1=constant, 2=lightning, 3=obs, 4=lightning & anthro

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'm leaning against this one because it introduces the risk of being missed in a future update of fates_spitfire_mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though I see the benefit of including some explanation of the > 1 and maybe the naming of these various modes (that I introduced elsewhere) needs to be used here, as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

valid point, though it may be worth a quick explanation in more than 1 central location

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 replaced the > 1 with > scalar_lightning in the latest commit.

@@ -207,7 +207,7 @@ module clm_varctl
integer, public :: fates_parteh_mode = -9 ! 1 => carbon only
! 2 => C+N+P (not enabled yet)
! no others enabled
logical, public :: use_fates_spitfire = .false. ! true => use spitfire model
integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: see bld/namelist_files/namelist_definition_clm4_5.xml for details
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: see bld/namelist_files/namelist_definition_clm4_5.xml for details
integer, public :: fates_spitfire_mode = 0 ! > 0 => use spitfire model: ignitions: 1=constant, 2=lightning, 3=obs, 4=lightning & anthro

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as my most recent comment:

Name the various modes in a central location and then use them in all cases like this instead of hardwiring.

Copy link
Contributor Author

@slevis-lmwg slevis-lmwg Jul 18, 2020

Choose a reason for hiding this comment

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

I completed this in the current PR's latest commit and in NGEET/fates#635.

The model builds, but I get a runtime system error in my cesm.log that looks like a problem leftover from cheyenne's downtime. What do you suggest @ekluzek :

dplace failed. Verify that the numatools module is loaded.
MPT ERROR: could not run executable (case #1)
(HPE MPT 2.19 02/23/19 05:31:12)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good news:
Whatever this was, it's been fixed, and my test now runs :-)

@slevis-lmwg
Copy link
Contributor Author

Can you point me to the test directory on cheyenne for confirmation, please?

You prob. already know this: While Cheyenne is down, you can access the same directory from Casper:

I didn't know that; thanks for the tip!

@glemieux I should have pointed out that today specifically Casper will also be down. Sorry for not mentioning sooner...

slevis-lmwg and others added 2 commits July 14, 2020 14:40
Clearer documentation suggested by @jkshuman.

Co-authored-by: jkshuman <[email protected]>
…nitions/README


Clearer documentation suggestion by @jkshuman.

Co-authored-by: jkshuman <[email protected]>
src/main/clm_varctl.F90 Outdated Show resolved Hide resolved
Clearer comment.

Co-authored-by: jkshuman <[email protected]>
src/main/clm_varctl.F90 Outdated Show resolved Hide resolved
Comment clarification.

Co-authored-by: jkshuman <[email protected]>
@slevis-lmwg
Copy link
Contributor Author

@slevisconsulting yes, ideally the reviews would be completed before the rebase so as to bring in the a consistent set of code that includes review change requests. That said, if there are non-critical change requests that could be brought in later without much hassle and tests are all passing, I'm inclined to rebase this sooner rather that later. Can you point me to the test directory on cheyenne for confirmation, please?

@glemieux you may have seen that I made some minor revisions in response to @jkshuman 's review. I have a few more to make once cheyenne comes up. I just want to make sure that you will let me know when I should stop further modifications to avoid conflicts with your re-basing.

@glemieux
Copy link
Collaborator

Thanks for the heads up @slevisconsulting

@slevis-lmwg
Copy link
Contributor Author

@glemieux I reran FATES testing successfully after my revisions in response to @jkshuman 's reviews.

Testing directory:
/glade/scratch/slevis/clmfates_tests

Updating externals_clm configuration to new tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new capability or improved behavior of existing capability FATES API update Changes to the FATES version that also REQUIRE an API change in CTSM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants