Skip to content

Conversation

@jtruesdal
Copy link
Collaborator

@jtruesdal jtruesdal commented Dec 18, 2020

PR mods:
. Update CIME external to include NUOPC compliance for MPAS
. Update MPAS external: NUOPC compliance, timer output, new sponge layer diffusion
. Remove MPAS Streams generation (unused)
. dyn_in and dyn_out refactored to point to the same structure.
. Fixes to allow NAG compilation
. Fix to allow running on 1 pe.
. Refactor for weak scaling.
. bug fixed in MPAS sub stepping.
. fixed a small discrepancy in the diagnosed pressure of one of the simple model cases.
. Update default MPASA grids, initial files, and boundary data for newly supported resolutions
. New defaults for MPAS dycore timestep. Changed the 3rd-order scaler transport upwind coefficient
from 600s to 900s.
. Add functionality to output initial condition files.
. Add new sponge layer diffusion options for model stability 1) Rayleigh 2) diffusion similar to SE

Fixes #385

@cacraigucar cacraigucar added this to the CESM2.3 milestone Dec 19, 2020
MiCurry and others added 5 commits January 7, 2021 10:35
This commit enable the MPAS dycore to build successfully with the physics,
dynamics introduced in e3630ff.

This commit updates the CAM configure script to use the infrastructure changes
when using the MPAS dycore, creates a stub function of get_dyn_grid_info in
dyn_grid, and comments out the logic of both d_p_coupling and p_d_coupling.

Because get_dyn_grid_info, d_p_coupling, and p_d_coupling do not contain any
logic, any CAM-MPAS simulations ran on this commit will not run correctly.
This commit fills out the physics_column_t array, where one indice of the array
relates to one MPAS cell. This commit also removes the allocations of global
arrays in dyn_grid_init, which were used in the previous physics, dynamics
implementation.

Because d_p_coupling and p_d_coupling are still commented out, CAM-MPAS
simulations will not run succsfully.
This commit updates the d_p_coupling function of the MPAS dycore to use the new
weak scaling changes implemented in a previous PR.

As of this commit, p_d_coupling has not been updated and is currently commented
out, so any CAM-MPAS simulation will not be correct.
This commit updates the p_d_coupling function of the MPAS dycore to use the new
changes that resolve the weak scaling problems.

Now that p_d_coupling is complete, it is now possible to run CAM-MPAS
simulations successfully.
Copy link
Collaborator

@cacraigucar cacraigucar left a comment

Choose a reason for hiding this comment

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

@jtruesdal Are these all the expected changes from the development side of things for this PR? If so, I believe this is ready to be sent out for others to review.

@cacraigucar cacraigucar marked this pull request as draft February 22, 2021 22:28
@cacraigucar cacraigucar changed the title MPAS bug fixes, performance enhancements, allow initial files writes, refactor/cleanup cam6_3_011: MPAS bug fixes, performance enhancements, allow initial files writes, refactor/cleanup Feb 26, 2021
@cacraigucar cacraigucar changed the title cam6_3_011: MPAS bug fixes, performance enhancements, allow initial files writes, refactor/cleanup MPAS bug fixes, performance enhancements, allow initial files writes, refactor/cleanup Mar 1, 2021
@jtruesdal
Copy link
Collaborator Author

@cacraigucar This PR is ready for review again. I've updated the cime external to a newer version to fix a bug we had with MPAS restart writes. The MPAS dycore external has been updated to allow it to use the CESM version of ESMF. The MPAS update was requested to allow NUOPC compatibility. @gold2718 We still have the outstanding issue of having an MPAS hash from a branch that could be removed in the future. I can open an issue on that if we don't have a fix right now but I don't think it should hold up the PR. It's not an immediate problem and we have assurances from the MPAS team that they won't delete anything until this issue is resolved.

@cacraigucar
Copy link
Collaborator

@jtruesdal - The problem with the hash and its possible removal occurs if a user checks out the CAM tag and uses it as a base for their branch or long-term work. Even if they are not using MPAS, a future run of manage_externals/checkout_externals could break their entire branch if the hash were removed. The likelihood of this happening is small, but it is not zero. As a result, I believe we (at least I) would be much more comfortable if the hash issue were resolved before this PR is put onto the CAM trunk. If its not fixed now, it will continue to be a problem for all CAM tags until it is fixed. If the CAM tag without the "forever hash" gets into a CESM tag, then the odds of it creating a problem goes up.

@jtruesdal jtruesdal requested a review from cacraigucar April 27, 2021 15:05
…lopment, remove unused code for weak scaling, Makefile - toggle use of External ESMF library CPP define when using NUOPC driver
@jtruesdal
Copy link
Collaborator Author

@cacraigucar This PR is ready for review again. I pushed the change to make MPAS an optional component.


[cime]
tag = cime5.8.37
tag = cime5.8.42
Copy link
Collaborator

Choose a reason for hiding this comment

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

If regression tests for non-MPAS tests have answer changes, you may need to update this cime tag in a separate CAM tag all by itself.

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 will test that now. Would the following failure against baseline be acceptable?

FAIL SMS_D_Ln9.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.cheyenne_intel.cam-outfrq9s_refined_camchem BASELINE /glade/p/cesm/amwg/cesm_baselines/cam6_3_017: FIELDLIST field lists differ (otherwise bit-for-bit)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, fieldlist differences are fine. Answer changes due to cime would not be good mixed in with this tag, if there are any.


List all files added and what they do:

List all existing files that have been modified, and describe the changes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Double check that all the modified files are accurately reflected here. (Externals.cfg is not listed though it now has change)

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 added documentation for Externals.cfg, diagnostics.F90 and listed subroutines that were removed when adopting weak scaling fixes. I'll have one more update when I run the official regression tests and will push this file before tagging.

Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Looks good! I do have one recommendation about wrapping an endrun call in an if-statement, but the rest are all just minor things like typos or error message text additions.

@gold2718
Copy link
Collaborator

I'm not sure where this should be documented, however, there is a bug in manage_externals. If the hash for MPAS is updated, you have to rerun checkout_externals with the --optional flag or the MPAS external will not be updated.
See ESMCI/manage_externals#155

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 few change requests

doc/ChangeLog Outdated
Comment on lines 6 to 7
One-line Summary:
Github PR URL:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fill these in

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 11 to 50
. Remove unused code in build-namelist for generating MPAS streams files.

. Fix to allow MPAS to run with 1 task.

. Fix to allow MPAS to run with NAG/debug.

. Replace bad grid file for running 480-km res with no topo.

. Fix for bug when MPAS dycore is substepping during physics timestep.

. Update calculation of hydrostatic pressure from MPAS state.

. Add ability to write initial file when using MPAS dycore.

. Correct interface error when calculation CAM pressures from MPAS height.

. update the MPAS-A dycore tag and CAM files associated with namelists in order
to support building with the ESMF/NUOPC driver and to introduce two new
absorbing layer options

1. A diffusion scheme similar to CAM-SE. Using a mpas_cam_coef = 1.0 will give
a damping coefficient of 0.2216E7, 0.6482E6, 0.1927E6 in the top-most three layers on
the dynamics variables u, w, and theta. The top 3 damping coefficients scale
linearly with mpas_cam_coef.

This option is controlled by the namelist variable mpas_cam_coef.

2. A Rayleigh damping on the horizontal momentum with a user-specified damping
timescale and a linear ramp over a user-specified number of levels from
the model top.

This option is controlled by the namelist variables mpas_rayleigh_damp_u,
mpas_rayleigh_damp_u_timescale_days, and mpas_number_rayleigh_damp_u_levels.

. Add calls to MPAS framework routines to write out detailed timers
for individual components of the MPAS-A dycore at the end of a simulation. This
can be helpful in comparing the runtime performance of CAM-MPAS with stand-
alone MPAS-Atmosphere, which already had detailed timers.

. Port weak scaling mods to MPAS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please point to issues that describe the need for each of these changes (as noted in the instructions). I do not currently see any issues addressed by this PR, please link to them or open them as needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New issue: #385
MPAS is currently under development so in this case, I've opened a general issue for all of these items. I will be better about opening issues in the future as we anticipate more updates as the dycore port matures. While MPAS is under heavy development and in the interest of making efficient use of the reviewers' time, it is very likely that each of the next PR's will include several changes. I will make sure to update the issue, in the case of last-minute additions to a PR that weren't documented in the original.

Copy link
Collaborator

Choose a reason for hiding this comment

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

While this looks like efficiency on the surface, it costs us a lot of time on the back end. The issues are our record and database for discussions of what needed fixing and why. Please trim #385 to match what is fixed in this PR and add a line to that effect in the PR title (see item 10 of the CAM SE PR procedures or the GitHub issue-closing syntax.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do.

doc/ChangeLog Outdated
to translate between physics and dynamics columns.

src/physics/cam/geopotential.F90
. fix calculation of CAM pressure from MPAS height coordinate.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code change looks more like it is for FV3, I do not see any change specific to MPAS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This particular if statement is applicable to all the dycores. MPAS is listed as a comment in the else part of the statement. This is one of Peter's changes, I think he just wanted to make explicit the differences between the dycores in the setting of the hydrostatic elements. If you would like more comments or something please 'at' PeterHjortLauritzen and I'll let him put the wording together.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My point is that while the additional comments mention MPAS, there is a code change that affects FV3. @PeterHjortLauritzen, is the FV3 change appropriate? If so, there should be an issue discussing the change as I expect it would change answers for FV3 runs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The changelog comment for this mod is incorrect and I will replace that. The change is a no-op for FV3 and the rest of the dycores. Peter just removed a logical that obscured which dycores were involved and replaced it with the complete expression and comment explicitly listing them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, thanks for the explanation. I see now that the new version still has the fvdyn variable but is no longer using it. Please remove that variable from geopotential.F90.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed variable and associated code.

end subroutine shift_time_levels
call cam_mpas_write_restart(initial_stream, endrun)

call pio_closefile(fh)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use cam_pio_closefile (which will do more work in the future):

Suggested change
call pio_closefile(fh)
call cam_pio_closefile(fh)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I changed it.

real(r8), allocatable, dimension(:) :: bbuffer, cbuffer ! transpose buffers
real(r8), allocatable:: pmid(:,:) !mid-level pressure consisten with MPAS discrete state

real(r8), allocatable, dimension(:) :: bbuffer, cbuffer ! transpose buffers
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are not used anymore, delete (same for p_d_coupling).

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 catch. Removed from both subroutines.

@jtruesdal jtruesdal requested a review from gold2718 June 3, 2021 05:34
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.

Looks good now (pending input from @PeterHjortLauritzen).

doc/ChangeLog Outdated
to translate between physics and dynamics columns.

src/physics/cam/geopotential.F90
. fix calculation of CAM pressure from MPAS height coordinate.
Copy link
Collaborator

Choose a reason for hiding this comment

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

My point is that while the additional comments mention MPAS, there is a code change that affects FV3. @PeterHjortLauritzen, is the FV3 change appropriate? If so, there should be an issue discussing the change as I expect it would change answers for FV3 runs.

@gold2718 gold2718 requested a review from nusbaume June 3, 2021 15:38
@cacraigucar cacraigucar changed the title MPAS bug fixes, performance enhancements, allow initial files writes, refactor/cleanup cam6_3_020: MPAS bug fixes, performance enhancements, allow initial files writes, refactor/cleanup Jun 3, 2021
Copy link
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

Looks like a couple of my requested edits were missed (?). Once they are fixed (or you have a reason to not make those changes) then this PR should be good to go on my end.

@jtruesdal jtruesdal linked an issue Jun 3, 2021 that may be closed by this pull request
…umbers added to similar error messages to aid debug, ChangeLog updates, remove unused variable and code in geopotential.F90, Make MPAS external non-optional again
@jtruesdal jtruesdal requested a review from nusbaume June 3, 2021 19:39
Copy link
Collaborator

@nusbaume nusbaume 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 now, thanks!

@jtruesdal jtruesdal merged commit fbc2289 into ESCOMP:cam_development Jun 5, 2021
cacraigucar added a commit to cacraigucar/CAM that referenced this pull request Aug 4, 2022
Merge pull request ESCOMP#303 from jtruesdal/mpas_fixes - MPAS updates and bugfixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

MPAS updates to add new functionality, bug fixes, refactor cleanup

8 participants