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

part of cam6_4_033: Wrap MPAS longitude values to [0,2pi) range #1095

Merged
merged 7 commits into from
Sep 13, 2024

Conversation

gdicker1
Copy link
Collaborator

@gdicker1 gdicker1 commented Jul 18, 2024

This PR addresses issues that were seen when using ncdata with longitudes in the $[-\pi, \pi]$ range in cases with full physics. This would cause the atmosphere to become unphysical and runs to fail. This change is made just after the longitude values are read to ensure they are correct for the remainder of execution.

Fixes #1094

This commit addresses issues that were seen when using ncdata with
longitudes in the [-pi, pi] range in cases with full physics.  This
would cause the atmosphere to become unphysical and runs to fail. This
change is made just after the longitude values are read to ensure they
are correct for the remainder of execution.
@gdicker1 gdicker1 self-assigned this Jul 18, 2024
@gdicker1
Copy link
Collaborator Author

NOTE: This PR branch is based on cam6_3_148 for compatibility with EarthWorks. This can be updated at any time, in whatever way reviewers would prefer.

Changes in this PR should also allow #1029 to proceed.

NOTE: this is before the 'aux_cam' tests have been run
Previous versions of the lonCell_arr adjustment used an explicit loop. Without this loop, the nCells variable and the routine to fetch it are no longer needed.
Copy link
Collaborator

@jtruesdal jtruesdal 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 have one small request. Append the kind to the number literal. After that it should be good to go.

call mpas_pool_get_array(meshPool, 'lonCell', lonCell_arr)

! Ensure longitudes w/i [0, 2*pi) range
lonCell_arr(:) = lonCell_arr(:) - (2.*pii) * floor(lonCell_arr(:) / (2.*pii))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
lonCell_arr(:) = lonCell_arr(:) - (2.*pii) * floor(lonCell_arr(:) / (2.*pii))
lonCell_arr(:) = lonCell_arr(:) - (2._RKIND*pii) * floor(lonCell_arr(:) / (2._RKIND*pii))

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 reminder! Addressed by 288f3ed

@mgduda mgduda self-requested a review July 23, 2024 23:41
@gdicker1
Copy link
Collaborator Author

@jtruesdal before I push to address your comment, I just noticed that I didn't wrap the commit message for f3dfa51 appropriately. In other repos, I would fix the message and force-push the branch.

How should I proceed here? Just ignore it?

@jtruesdal
Copy link
Collaborator

I'm not sure what you mean by "wrap the commit message". Everything looks Ok to me when I look at the 3 commits and their associated messages. We mostly go by the Changelog and the commit messages are useful but not critical.

Makes code consistent with CAM coding standards: 'All variables of type
real must have a specified kind, including literals.'
@gdicker1
Copy link
Collaborator Author

gdicker1 commented Jul 24, 2024

Fair enough, I won't worry about it.

I'm not sure what you mean by "wrap the commit message".

Most resources on git commit messages suggest to break body text at 72 characters and continue on the next line.

Copy link
Collaborator

@mgduda mgduda left a comment

Choose a reason for hiding this comment

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

Besides giving some consideration to the two comments I've left, I think it would be worth using a loop with a conditional to only modify longitudes that aren't already in the interval [0, 2*Pi). It's ultimately likely to be slower, but this only happens once when the model starts up, and the cost is almost certainly negligible when compared with the cost of filesystem accesses. The benefit would be that, for meshes that provide longitudes in CAM's required range, those values would remain bitwise identical to their values in the input file.

This commit also extends the comment that was with this code block,
includes an if condition so valid values aren't modified, uses kinds and
constants (pi) that are already used in the new file, and updates the
ChangeLog so the correct file is referenced.
@gdicker1
Copy link
Collaborator Author

@mgduda I implemented your suggestions in fabe37a. Thanks for the explanation you gave on the "loop with a conditional".

src/dynamics/mpas/dyn_grid.F90 Outdated Show resolved Hide resolved
src/dynamics/mpas/dyn_grid.F90 Outdated Show resolved Hide resolved
Conform to CAM Coding Standards: 'Use symbolic numerical comparison
operators (e.g., ==, /=, <, >=) not old character versions (e.g.,
.eq.).'
@gdicker1 gdicker1 requested a review from mgduda July 26, 2024 22:16
Copy link
Collaborator

@mgduda mgduda left a comment

Choose a reason for hiding this comment

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

Approved by inspection.

@cacraigucar cacraigucar changed the title Wrap MPAS longitude values to [0,2pi) range cam6_4_021?: Wrap MPAS longitude values to [0,2pi) range Aug 13, 2024
@cacraigucar cacraigucar changed the title cam6_4_021?: Wrap MPAS longitude values to [0,2pi) range : Wrap MPAS longitude values to [0,2pi) range Aug 14, 2024
@gdicker1 gdicker1 changed the title : Wrap MPAS longitude values to [0,2pi) range part of cam6_4_033: Wrap MPAS longitude values to [0,2pi) range Sep 11, 2024
@gdicker1 gdicker1 merged commit 87a4b80 into ESCOMP:cam_development Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answer changing answer changing tag enhancement New feature or request
Projects
Status: Tag
Development

Successfully merging this pull request may close these issues.

3 participants