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

Select short name of variable defining ModelVerticalGrid #3182

Open
wants to merge 13 commits into
base: release/MAPL-v3
Choose a base branch
from

Conversation

pchakraborty
Copy link
Contributor

@pchakraborty pchakraborty commented Nov 15, 2024

Types of change(s)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Trivial change (affects only documentation or cleanup)
  • Refactor (no functional changes, no api changes)

Checklist

  • Tested this change with a run of GEOSgcm
  • Ran the Unit Tests (make tests)

Description

  • A Model VerticalGrid is now instantiated with standard_name, units and num_levels. The method add_short_name is used to specify variable short names corresponding to edge and center vertical staggerings, which is selected at runtime using the method get_short_name.
  • Updated ComponentSpecParse::parse_geometry_spec to use the new interface.
  • Updated Test_ModelVerticalGrid.pf to use the new interface.
  • Updated vertical regridding tests to specify standard_name instead of short_name for Model VerticalGrids.
  • Cleanup of FixedLevels VerticalGrid - we didn't need MAPL_BaseMod::MAPL_GridGet after all.

Related Issue

@pchakraborty pchakraborty self-assigned this Nov 15, 2024
@pchakraborty pchakraborty added 🎁 New Feature This is a new feature 0 Diff The changes in this pull request have verified to be zero-diff with the target branch. 📈 MAPL3 MAPL 3 Related Changelog Skip Skips the Changelog Enforcer labels Nov 15, 2024
@pchakraborty pchakraborty marked this pull request as ready for review November 15, 2024 12:55
@pchakraborty pchakraborty requested a review from a team as a code owner November 15, 2024 12:55
class(ModelVerticalGrid), intent(inout) :: this
character(*), intent(in) :: short_name
character(*), optional, intent(in) :: edge
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need an "unusable" argument here to separate out the options. Both arguments are the same type (character), so it is dangerously ambiguous which one is intended.

Copy link
Contributor Author

@pchakraborty pchakraborty Nov 15, 2024

Choose a reason for hiding this comment

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

Not sure I understand. Both edge and center are optional arguments. Did you mean something like

   subroutine add_short_names(this, edge, unusable, center)
      class(ModelVerticalGrid), intent(inout) :: this
      character(*), optional, intent(in) :: edge
      class(KeywordEnforder), optional, intent(in) :: unusable
      character(*), optional, intent(in) :: center

      if (present(edge)) this%short_name_edge = edge
      if (present(center)) this%short_name_center = center
      _UNUSED_DUMMY(unusable)
   end subroutine add_short_names

Copy link
Collaborator

Choose a reason for hiding this comment

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

No - I mean "unusable" should be even before edge. Force the user to be explicit since there is no obvious ordering of "center" vs "edge" in this context.

Copy link
Collaborator

Choose a reason for hiding this comment

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

To be explicit, consider this call:

call obj%add_short_name('x')

Is it obvious that this was adding "edge"?
Or consider:

call obj%add_short_name('x', 'y')

Which is which? Instead:

call obj%add_short_name(edge='x', center='y')

is unambiguous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I had seen the unusable argument, but was not familiar with its usage. Pushed the change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I picked up the technique from ESMF. They use it to enforce the rule that interfaces remain backward compatible. All new arguments must be optional and after the "unusable" argument. But the same technique also allows us to enforce using keywords for ambiguous situations. At one point I was going to rigorously enforce that all MAPL optional arguments be after "unusable" as a stylistic statement that makes optional arguments more obviously optional. But am no longer so dogmatic. Becomes a pain to put "unusable" in interfaces that just have optional "rc".

Copy link
Collaborator

@tclune tclune 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 minor changes requested. See inline comments.

Copy link
Collaborator

@tclune tclune 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 Diff The changes in this pull request have verified to be zero-diff with the target branch. Changelog Skip Skips the Changelog Enforcer 📈 MAPL3 MAPL 3 Related 🎁 New Feature This is a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants