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

[CLOSED] Add hillslope scripts (to python/ctsm/) and external #2401

Closed
wants to merge 34 commits into from

Conversation

samsrabin
Copy link
Collaborator

@samsrabin samsrabin commented Mar 5, 2024

Work in progress! At risk of force pushes!

Description of changes

Sean Swenson has various scripts related to making files/variables for use in hillslope runs. Some of these are not CTSM-specific, so they're in a separate Representative_Hillslopes repo. Some are CTSM-specific, though, so this PR will add those to python/ctsm/. It also adds the Representative_Hillslopes repo as an optional external to CTSM.

Specific notes

Contributors other than yourself, if any: Sean Swenson (@swensosc)

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: None so far.

@samsrabin samsrabin added enhancement new capability or improved behavior of existing capability tag: support tools only bfb bit-for-bit labels Mar 5, 2024
@samsrabin samsrabin self-assigned this Mar 5, 2024
@samsrabin samsrabin linked an issue Mar 5, 2024 that may be closed by this pull request
@samsrabin samsrabin changed the base branch from b4b-dev to master March 5, 2024 18:38
@samsrabin samsrabin changed the base branch from master to b4b-dev March 5, 2024 18:39
@samsrabin
Copy link
Collaborator Author

samsrabin commented Mar 5, 2024

  • Should be rebased onto current master after the next master merge into b4b-dev (March 7).

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.

Thanks for the work on this @samsrabin and @swensosc! Nice to see this coming in.

I have some questions, requests for changes, and things I point out to do later. I think this likely would be good to go over this.

To be honest -- I thought this might be smaller than it really was -- so I took on reviewing it. But, might not have had I realized the size. LOL. That's not bad, just a personal confession.

I do wonder if someone else should review it as well? And it might be good to just go through together. So maybe the second person doesn't do much looking beforehand, just goes through the walkthrough with us?

Externals.cfg Outdated
local_path = tools/external/representative-hillslopes
protocol = git
repo_url = https://github.com/swensosc/Representative_Hillslopes
tag = 06f12b6
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be hash rather than tag.

They might both work, but better to use the right term.

Externals.cfg Outdated
[representative-hillslopes]
local_path = tools/external/representative-hillslopes
protocol = git
repo_url = https://github.com/swensosc/Representative_Hillslopes
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is OK for now. But, in the longer run we'll want this personal fork moved to ESCOMP.

We'll also want to think about repository standards and how to handle tags and such. For a small repository like this it doesn't need to be (nor should it) be as complex as CTSM.

namelst=>"origflag=0, lower_boundary_condition=2",
GLC_TWO_WAY_COUPLING=>"FALSE",
phys=>"clm4_5",
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should also add new tests for the fatal errors that hillslope error checking adds. I counted five fatal errors, so most likely that means five tests for them.

bld/namelist_files/namelist_definition_ctsm.xml Outdated Show resolved Hide resolved
my ($opts, $nl_flags, $definition, $defaults, $nl) = @_;

add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'use_hillslope' );
add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'downscale_hillslope_meteorology' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put the rest of these in a if statement that checks if use_hillslope is on. There's no reason to set any of these when hillslope is off.

@@ -555,24 +558,25 @@ subroutine InitHistory(this, bounds)
avgflag='A', long_name='atmospheric surface height', &
ptr_lnd=this%forc_topo_grc)

this%forc_solar_not_downscaled_grc(begg:endg) = spval
call hist_addfld1d (fname='FSDS_from_atm', units='W/m^2', &
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be default output?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm trying to map what is going on here. There's some sensitivity that people have for changing history variable names because they assume them in post-processing scripts as well as in user_nl_clm files.

Can you map out the basic changes here, on what is being renamed and what is removed and added?

hillslope_pft_distribution_method = 'PftLowlandUpland'
hillslope_soil_profile_method = 'Uniform'

fsurdat = '$DIN_LOC_ROOT/lnd/clm2/testdata/surfdata_10x15_78pfts_simyr2000_synthetic_cosphill_1.3.nc'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file will need to be updated with CTSM5.2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And it should have a creation date at the end. This is important for CESM since we version control files through the creation date string. You can't import a file with changes with an existing name -- as you will silently change answers for existing simulations. Obviously, that doesn't apply here, but still since we can't import a file with the same name the convention is still valid.

! The distinction between "shallow" and "deep" bedrock is not made explicitly
! elsewhere. But, since these classes have somewhat different behavior, they are
! distinguished explicitly here.
integer, parameter :: LEVGRND_CLASS_STANDARD = 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically our standard says we ONLY use uppercase for CPP tokens. But, CPP tokens are now very rare in CTSM, and that was long enough ago that we had extensive use of CPP tokens, that I think it's OK to change our standard to allow it for parameters. This is a common code convention now and it's useful.

But, we should agree to this and change the standard on the wiki.

! Set hillslope column bedrock values
if (use_hillslope) then
call SetHillslopeSoilThickness(bounds,fsurdat, &
soil_depth_lowland_in=8.5_r8,&
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the meaning of the hardcoded constants here (8.5 and 2.0)? Does it improve readability to make them a parameter?

Copy link
Collaborator

Choose a reason for hiding this comment

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

They are used in the unit tests, as well. So it might be better to have them as parameters. The latest value doesn't need to be in the tests, but it still might be useful.

@@ -257,6 +257,11 @@ subroutine control_init(dtime)

namelist /clm_inparm/ use_biomass_heat_storage

namelist /clm_inparm/ use_hillslope

namelist /clm_inparm/ downscale_hillslope_meteorology
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like downscale_hillslope_meteorology and use_hillslope_routing could be in the Hillslope specific namelist rather than here.

use_hillslope is an overall control variable, so needs to be here, but it looks like to me these two are only used if use_hillslope is on.

Copy link
Collaborator

Choose a reason for hiding this comment

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

By having namelist controls in the most specific location as possible, it makes it easier to change parameterization packages (add new versions, or remove old ones). The control variables at this level are kind of out of control (too many of them), so I like to make them specific if it can be done.

@samsrabin
Copy link
Collaborator Author

@ekluzek Thanks for the comments! This is still very much a draft, though; I really only just copied in Sean's scripts.

The commit will be much smaller once it's properly rebased as I mentioned here.

@samsrabin samsrabin added the next this should get some attention in the next week or two. Normally each Thursday SE meeting. label Mar 7, 2024
@samsrabin samsrabin changed the title Add hillslope scripts (to python/ctsm/) and external [WIP] Add hillslope scripts (to python/ctsm/) and external Mar 8, 2024
@samsrabin samsrabin changed the base branch from b4b-dev to master March 13, 2024 15:36
@samsrabin samsrabin changed the base branch from master to b4b-dev March 13, 2024 15:36
@ekluzek ekluzek removed the next this should get some attention in the next week or two. Normally each Thursday SE meeting. label Mar 14, 2024
@samsrabin
Copy link
Collaborator Author

Replacing this with #2425. @ekluzek, if you'd like to preserve your review comments, please file a new issue.

@samsrabin samsrabin closed this Mar 15, 2024
@samsrabin samsrabin changed the title [WIP] Add hillslope scripts (to python/ctsm/) and external [CLOSED] Add hillslope scripts (to python/ctsm/) and external Mar 15, 2024
@ekluzek
Copy link
Collaborator

ekluzek commented Mar 15, 2024

Thanks @samsrabin I'll leave them here for now. We may discuss if they come up after review of the new PR. Although I'll probably make an issue of all uppercase in the FORTRAN code for constants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bfb bit-for-bit enhancement new capability or improved behavior of existing capability
Projects
Status: Done (non release/external)
Development

Successfully merging this pull request may close these issues.

Add hillslope scripts
5 participants