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

Port SE dycore to CAMDEN #135

Merged
merged 46 commits into from
Sep 27, 2021
Merged

Port SE dycore to CAMDEN #135

merged 46 commits into from
Sep 27, 2021

Conversation

nusbaume
Copy link
Collaborator

@nusbaume nusbaume commented Jun 16, 2021

Adds the SE dycore to CAMDEN from CAM, including bug fixes that impacted the use of the dycore in CAMDEN.

Fixes #44
Fixes #71
Fixes #76
Fixes #78
Fixes #86
Fixes #136

Addresses #91
Addresses #123
Addresses #150

Tests ran:

Ran an FKESSLER compset at ne5_ne5_mg37 and ne5pg2_ne5pg2_mg37 (for CSLAM) resolution for five time steps for both NTASKS=1 and NTASKS=2 pe layouts. Performed smoke tests with Intel, PGI, and NAG compilers, and ensured bit-for-bit reproducibility with CAM when using Intel. I also ran a regular null dycore kessler run to make sure I didn't break anything.

It should be noted that in order to have bit-for-bit agreement the physics interfaces in CAM needed to be modified to more closely match CAMDEN (which was easier than modifying CAMDEN given that many of the interfaces were auto-generated). Those modifications (assuming you are using cam6_3_019) can be found on cheyenne here:

/glade/u/home/nusbaume/CAMDEN_backup_files/SE-dycore/bit-for-bit/cam_kessler

Finally, most of the lines of code being added by this PR are straight copies from CAM, particularly for files in the dyn/se/dycore directory. However, I did make minor modifications to most of those files, so it might be easiest to review this PR by diffing these files with the same files from CAM (tag = cam6_3_019). Of course if you really want to review the entire SE dycore then I certainly won't stop you.

Anyways, thanks in advance for your comments and suggestions, and have a great day!

nusbaume added 27 commits June 15, 2021 20:38
(Please note that this commit excludes a required Kessler physics
and/or registry temperature tendency variable name change, which
should be brought in separately.  Until that change is implemented
either registry.xml or kessler_update.meta must be modified manually.)
@nusbaume nusbaume added enhancement New feature or request bug-fix This PR was created to fix a specific bug. labels Jun 16, 2021
@nusbaume nusbaume requested a review from gold2718 June 16, 2021 19:02
Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

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

Wow, this turned out to be a huge project!
Lots of great work.
I have a bunch of questions, comments and some change requests.

cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Show resolved Hide resolved
cime_config/cam_config.py Show resolved Hide resolved
test/unit/cam_config_unit_tests.py Outdated Show resolved Hide resolved
test/unit/cam_config_unit_tests.py Outdated Show resolved Hide resolved
cime_config/namelist_definition_cam.xml Show resolved Hide resolved
cime_config/namelist_definition_cam.xml Outdated Show resolved Hide resolved
cime_config/namelist_definition_cam.xml Outdated Show resolved Hide resolved
@nusbaume nusbaume requested a review from gold2718 August 26, 2021 17:30
@nusbaume
Copy link
Collaborator Author

@gold2718 this PR is ready to be reviewed again. Thanks!

cime_config/cam_config.py Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/namelist_definition_cam.xml Show resolved Hide resolved
cime_config/namelist_definition_cam.xml Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

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

This is my review based on 0f9daf1. My earlier comments were published prematurely by GitHub (I think it happened because I commented on a conversation while my review was in progress). Please add these changes to the previous ones and then ask for a re-review. Sorry for the confusion.

src/data/generate_registry_data.py Show resolved Hide resolved
src/data/generate_registry_data.py Outdated Show resolved Hide resolved
src/data/generate_registry_data.py Outdated Show resolved Hide resolved
src/data/physconst.F90 Outdated Show resolved Hide resolved
src/data/physconst.F90 Outdated Show resolved Hide resolved
src/dynamics/utils/dyn_thermo.F90 Outdated Show resolved Hide resolved
real(kind_phys) :: dp_dry_phys(i0:i1,j0:j1,k0:k1)
real(kind_phys) :: dp_phys(i0:i1,j0:j1,k0:k1)
real(kind_phys), allocatable :: ps(:,:)
real(kind_phys), allocatable :: ptop
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does a scalar real need to be allocatable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In this case, yes, because it is an optional input that needs to be converted, and so having it allocated (or not) is how the receiving subroutine knows whether the converted value is "present".

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice technique but should probably document that intent in the code because I forgot and now I recall having the discussion a few weeks ago.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add this documentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment has been added explaining why the scalar real variable is allocatable.

src/dynamics/utils/dyn_thermo.F90 Outdated Show resolved Hide resolved
src/dynamics/utils/dyn_thermo.F90 Outdated Show resolved Hide resolved
src/dynamics/utils/dyn_thermo.F90 Outdated Show resolved Hide resolved
@nusbaume nusbaume requested a review from gold2718 September 21, 2021 14:58
@nusbaume
Copy link
Collaborator Author

@gold2718 This code is ready for review again. Thanks!

cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Show resolved Hide resolved
@@ -27,7 +29,7 @@
from cam_autogen import generate_init_routines


# Determine regular rexpression type (for later usage in Config_string)
# Determine regular rexpression type (for later usage in check_string_val)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might be able to replace these checks with:

isinstance(<x>, re.Pattern)

which is more pythonic. Python seems to support this by documenting the re.Pattern class (https://docs.python.org/3/library/re.html#re-objects).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That re.Pattern object doesn't appear to be available in Python 3.6 or earlier.  We could restrict CAMDEN to Python 3.7 or later, but that would put us out-of-sync with CIME in terms of python requirements. I am already planning to create an issue describing the need to update the python version and listing all of the various associated code changes, so if you want I can include this change in that list.  

Also, in terms of the python version, I have found that for a complete python version restriction to work we'll need to update the CIME tag to ensure that all shebangs are python3.  Otherwise, at least on Izumi, there is at least one section in the CIME run sequence where the python version will automatically use the default python version (which is 2.7).  I went ahead and added the code change needed for CAMDEN to still run on Izumi, which is also included in the python 3.7 modification list, but at this point I would like to avoid updating the CIME tag for this PR, given that we are so close already and most of these changes aren't really required for the SE dycore port.  Let me know if you disagree, however.   For now you can look at issue #156 for more info.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed on #156 but I would say that we are overdue for a CIME upgrade so please make sure this is prioritized.

cime_config/cam_config.py Outdated Show resolved Hide resolved
cime_config/cam_config.py Show resolved Hide resolved
cime_config/cam_config.py Outdated Show resolved Hide resolved
src/data/generate_registry_data.py Outdated Show resolved Hide resolved
src/data/generate_registry_data.py Outdated Show resolved Hide resolved
src/data/physconst.F90 Show resolved Hide resolved
src/data/registry.xml Show resolved Hide resolved
Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

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

This is Xeno's review of a012973.
A few more tweaks please.

src/dynamics/se/dyn_comp.F90 Outdated Show resolved Hide resolved
src/dynamics/se/dp_coupling.F90 Outdated Show resolved Hide resolved
src/dynamics/se/dp_coupling.F90 Outdated Show resolved Hide resolved
src/dynamics/se/dp_coupling.F90 Show resolved Hide resolved
src/dynamics/se/dp_coupling.F90 Outdated Show resolved Hide resolved
@nusbaume nusbaume requested a review from gold2718 September 24, 2021 22:45
@nusbaume
Copy link
Collaborator Author

@gold2718 this PR is ready for re-review again. Thanks!

Copy link
Collaborator

@gold2718 gold2718 left a comment

Choose a reason for hiding this comment

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

A couple of suggested changes but generally okay.

Comment on lines 203 to 210
# Check that all tuple elements are integers:
for valid_val in valid_vals:
if valid_val is not None and not isinstance(valid_val, int):
emsg = ("ERROR: Valid value, '{}', for variable '{}', must be "
"either None or an integer. Currently it is '{}'.")
raise CamConfigTypeError(emsg.format(valid_val, name, type(valid_val)))
# End if
# End for
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider checking all values:

Suggested change
# Check that all tuple elements are integers:
for valid_val in valid_vals:
if valid_val is not None and not isinstance(valid_val, int):
emsg = ("ERROR: Valid value, '{}', for variable '{}', must be "
"either None or an integer. Currently it is '{}'.")
raise CamConfigTypeError(emsg.format(valid_val, name, type(valid_val)))
# End if
# End for
# Check that all tuple elements are integers:
emsg = ""
for valid_val in valid_vals:
if valid_val is not None and not isinstance(valid_val, int):
emsg += ("ERROR: Valid value, '{}', for variable '{}', must be "
"either None or an integer. Currently it is '{}'.\n")
# End if
# End for
if emsg:
raise CamConfigTypeError(emsg.format(valid_val, name, type(valid_val)))
# end if

Copy link
Collaborator Author

@nusbaume nusbaume Sep 27, 2021

Choose a reason for hiding this comment

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

I swear that someday I'll remember to do this before the code review! All values are now checked.

Comment on lines 151 to 158
# Check that all tuple elements are integers:
for valid_val in valid_vals:
if valid_val is not None and not isinstance(valid_val, int):
emsg = ("ERROR: Valid value, '{}', for variable '{}', must be "
"either None or an integer. Currently it is '{}'.")
raise CamConfigTypeError(emsg.format(valid_val, name, type(valid_val)))
# End if
# End for
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be nicer if you did "check that all tuple elements are integers".

Suggested change
# Check that all tuple elements are integers:
for valid_val in valid_vals:
if valid_val is not None and not isinstance(valid_val, int):
emsg = ("ERROR: Valid value, '{}', for variable '{}', must be "
"either None or an integer. Currently it is '{}'.")
raise CamConfigTypeError(emsg.format(valid_val, name, type(valid_val)))
# End if
# End for
emsg = ""
# Check that all tuple elements are integers:
for valid_val in valid_vals:
if valid_val is not None and not isinstance(valid_val, int):
emsg += ("ERROR: Valid value, '{}', for variable '{}', must be "
"either None or an integer. Currently it is '{}'.\n")
# End if
# End for
if emsg:
raise CamConfigTypeError(emsg.format(valid_val, name, type(valid_val)))
# end if

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

All elements are now checked (even if a bad value is found).

@nusbaume nusbaume merged commit 14bb4a2 into ESCOMP:development Sep 27, 2021
@nusbaume nusbaume deleted the se_dycore branch October 8, 2021 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix This PR was created to fix a specific bug. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants