-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: release/MAPL-v3
Are you sure you want to change the base?
Select short name of variable defining ModelVerticalGrid #3182
Conversation
…hakrab/vertical-regridding
…hakrab/vertical-regridding
if (standard_name == "air_pressure") then | ||
call vertical_grid%add_short_names(edge="PLE", center="PL") | ||
else if (standard_name == "height") then | ||
call vertical_grid%add_short_names(edge="ZLE", center="ZL") | ||
else | ||
_FAIL("unsupported standard name ["//standard_name//"]") | ||
end if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cannot be hardwired here. At least not in the long term. How about requiring them in the yaml file when you try to specify the vertical grid that way:
vertical_grid:
coordinate:
dimension: pressure
stagger: edge
field: PLE
coordinate:
dimension: height
stagger: center
field: ZL
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #3184. I'll do it in a separate PR
end function new_ModelVerticalGrid_basic | ||
|
||
integer function get_num_levels(this) result(num_levels) | ||
class(ModelVerticalGrid), intent(in) :: this | ||
num_levels = this%num_levels | ||
end function get_num_levels | ||
|
||
subroutine add_variant(this, short_name) | ||
subroutine add_short_names(this, edge, center) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that this is what we want here. It is conceivable that someone could provide just the edge and not the center. or vice versa. The center can in theory be derived from the edge (with some assumptions that appear to be nigh universal.)
It can stay for now, but be prepared for something where instead you specify name and staggerloc.
class(ModelVerticalGrid), intent(inout) :: this | ||
character(*), intent(in) :: short_name | ||
character(*), optional, intent(in) :: edge |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
if (vertical_dim_spec == VERTICAL_DIM_EDGE) then | ||
short_name = this%short_name_edge | ||
_RETURN(_SUCCESS) | ||
else if (vertical_dim_spec == VERTICAL_DIM_CENTER) then | ||
short_name = this%short_name_center | ||
_RETURN(_SUCCESS) | ||
else | ||
_FAIL("unsupported vertical_dim_spec") | ||
end if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
War on nesting ... (Makes it more obvious that a final _RETURN(_SUCCESS)
is not needed also)
if (vertical_dim_spec == VERTICAL_DIM_EDGE) then | |
short_name = this%short_name_edge | |
_RETURN(_SUCCESS) | |
else if (vertical_dim_spec == VERTICAL_DIM_CENTER) then | |
short_name = this%short_name_center | |
_RETURN(_SUCCESS) | |
else | |
_FAIL("unsupported vertical_dim_spec") | |
end if | |
if (vertical_dim_spec == VERTICAL_DIM_EDGE) then | |
short_name = this%short_name_edge | |
_RETURN(_SUCCESS) | |
end if | |
if (vertical_dim_spec == VERTICAL_DIM_CENTER) then | |
short_name = this%short_name_center | |
_RETURN(_SUCCESS) | |
end if | |
_FAIL("unsupported vertical_dim_spec") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no nesting here. Also I don't see how separate if blocks is any more readable than the if/else if/else block.
There was a problem hiding this 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.
Types of change(s)
Checklist
make tests
)Description
standard_name
,units
andnum_levels
. The methodadd_short_names
is used to specify variable short names corresponding to edge and center vertical staggerings, which is selected at runtime using the methodget_short_name
.ComponentSpecParse::parse_geometry_spec
to use the new interface.Test_ModelVerticalGrid.pf
to use the new interface.standard_name
instead ofshort_name
for Model VerticalGrids.MAPL_BaseMod::MAPL_GridGet
after all.Related Issue