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

Add constituent tendency capability #584

Merged
merged 16 commits into from
Nov 7, 2024

Conversation

peverwhee
Copy link
Collaborator

Summary
Adds constituent tendency array and enables the use of individual constituent tendency variables.

Description
In order to facilitate time-splitting, this PR adds/enables the following:

  • ccpp_constituent_tendencies: standard name for constituent tendencies array
  • standard names of the form "tendency_of_CONSTITUENT" now handled by the framework
    • must also include "constituent = True" in metadata for the tendency

User interface changes?: Yes, but optional
User can now use the following in scheme metadata:

  • ccpp_constituent_tendencies (standard name for the array of constituent tendencies)
  • tendency_of_CONSTITUENT (tendency array for a specific constituent)
  • constituent = True (specifies variable will be handled by constituents object)

Testing:
test removed: None
unit tests: Added doctests to new check_tendency_variables function in host_cap.F90
system tests: Modified advection_test to use tendency variable and tendency array
manual testing: Updates run in CAM-SIMA

@peverwhee peverwhee added enhancement capgen bugs, requests, etc. that involve ccpp_capgen labels Aug 22, 2024
Copy link
Collaborator

@mwaxmonsky mwaxmonsky left a comment

Choose a reason for hiding this comment

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

Looks great so far @peverwhee! Still working through the details but just had a few preliminary questions/comments on the python side of things.

scripts/host_cap.py Outdated Show resolved Hide resolved
scripts/host_cap.py Show resolved Hide resolved
scripts/host_cap.py Show resolved Hide resolved
scripts/constituents.py Outdated Show resolved Hide resolved
scripts/constituents.py Outdated Show resolved Hide resolved
scripts/constituents.py Show resolved Hide resolved
scripts/constituents.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@climbfuji climbfuji 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 this @peverwhee ! One or two most likely dumb questions, other than that looks fine with @mwaxmonsky's comments applied.

scripts/host_cap.py Show resolved Hide resolved
else:
tend_dim = dim
# end if
if const_dimensions[index] == 'horizontal_loop_extent':
Copy link
Collaborator

Choose a reason for hiding this comment

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

This adjustment for tendency/constituent vars is just for matching horizontal dimensions, correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yep! not a permanent change, just a way to make sure that the dimensions match between the tendency variable and the corresponding constituent "state" variable

Copy link
Collaborator

@mkavulich mkavulich left a comment

Choose a reason for hiding this comment

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

Some initial comments while I try to wrap my head around things.

Side note: the word "tendency" doesn't look real anymore.

scripts/host_cap.py Outdated Show resolved Hide resolved
scripts/host_cap.py Outdated Show resolved Hide resolved
const_kind = const_var.get_prop_value('kind')
if tend_stdname_split == const_stdname:
# We found a match! Check units
if tend_units.split('s-1')[0].strip() != const_units:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assumes that s-1 is always at the end. But it is entirely valid (from a math standpoint) to write kg s-1 m-2 instead of kg m-2 s-1. And it's of course also valid to write m s-2 for a tendency of the constituent had m s-1 ...

Probably not an issue, but we should document this in the updated (!) CCPP technical documentation

Copy link
Collaborator

@dustinswales dustinswales left a comment

Choose a reason for hiding this comment

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

@peverwhee I think this is fine.
I do have a question about extending some existing code rather than adding your own routine (See inline comments).

# end if
# end for
# end for
# Check that all tendency variables are valid
errmsg, errflg = check_tendency_variables(tend_vars, const_vars)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Most of this code/logic in check_tendency_variables already exists in the the VarCompatObj (and here).
Could the ability to check for "compatibility between any variable, not just a const variable, and its tendency" be folded into there? (This would make it more useable if someone wanted to do something similar with "state_variables" in the _pre/_post scheme calls.)
I'd be happy to help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took a stab at modifying compatible to validate tendencies. Let me know what you think!

@climbfuji
Copy link
Collaborator

@peverwhee Please re-request a review from all the reviewers once you've addressed the questions/concerns from @mwaxmonsky and @dustinswales (I keep coming back to re-review but then remind myself that there are still comments that need to be addressed). Thank you!

Copy link
Collaborator

@climbfuji climbfuji 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 addressing my comments and those of @mwaxmonsky . Looks good to me now!

Copy link
Collaborator

@dustinswales dustinswales left a comment

Choose a reason for hiding this comment

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

@peverwhee These changes look awesome!
I'm glad to see that the compatibility object was able to handle the logic w/o many modifications.

if var1_stdname != var2_stdname:
# If it's a tendency variable, it's assumed the standard name is of the
# form "tendency_of_var2_stdname"
if not is_tend and var1_stdname != var2_stdname:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add a check that starts with tendency_ when is_tend=True? Or is this handled somewhere else? If redundant, ignore.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good call! as it's currently used, it's only called when a variable starts with "tendency_of" but I added the check to prevent future (by me) implementation issues!

@climbfuji
Copy link
Collaborator

@peverwhee Can you please update the branch from develop? There are merge conflicts that need to be resolved. Thanks!

@peverwhee
Copy link
Collaborator Author

@DomHeinzeller done!

I think I'll give @gold2718 a bit more time if he'd still like to review this before merging. Say, by next wednesday (11/6)?

@mkavulich mkavulich merged commit ce381cf into NCAR:develop Nov 7, 2024
19 checks passed
peverwhee added a commit to ESCOMP/CAM-SIMA that referenced this pull request Nov 27, 2024
Tag name (required for main):
Originator(s): peverwhee

Summary (include the keyword ['closes', 'fixes', 'resolves'] and issue
number): Brings in and enables new apply_constituent_tendencies scheme
(from ESCOMP/atmospheric_physics#111)

Describe any changes made to build system: Exclude constituent
tendencies from required variables (now handled by the CCPP Framework in
NCAR/ccpp-framework#584)

Describe any changes made to the namelist: None

List any changes to the defaults for the input datasets (e.g. boundary
datasets): None

List all files eliminated and why: None

List all files added and what they do: None

List all existing files that have been modified, and describe the
changes:
(Helpful git command: `git diff --name-status
development...<your_branch_name>`)

M     .gitmodules
- update CCPP-Framework and atmospheric_physics externals to point to
updates for constituent tendencies

M     src/data/write_init_files.py
- exclude constituent tendency variables (and array) from required
variables list

If there are new failures (compare to the existing-test-failures.txt
file),
have them OK'd by the gatekeeper, note them here, and add them to the
file.
If there are baseline differences, include the test and the reason for
the
diff. What is the nature of the change? Roundoff?

derecho/intel/aux_sima:

derecho/gnu/aux_sima:

CAM-SIMA date used for the baseline comparison tests if different than
latest:

---------

Co-authored-by: Courtney Peverley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
capgen bugs, requests, etc. that involve ccpp_capgen enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants