Skip to content

Commit

Permalink
fixes #2986
Browse files Browse the repository at this point in the history
  • Loading branch information
bena-nasa committed Sep 6, 2024
1 parent 7d3348a commit 043f044
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
18 changes: 15 additions & 3 deletions generic3g/ComponentSpecParser/parse_geometry_spec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
submodule (mapl3g_ComponentSpecParser) parse_geometry_spec_smod
use mapl3g_VerticalGrid
use mapl3g_BasicVerticalGrid
use mapl3g_FixedLevelsVerticalGrid
implicit none(external,type)

contains
Expand All @@ -28,8 +29,9 @@ module function parse_geometry_spec(mapl_cfg, rc) result(geometry_spec)
type(GeomManager), pointer :: geom_mgr
class(GeomSpec), allocatable :: geom_spec
integer :: num_levels
character(:), allocatable :: vertical_grid_class
character(:), allocatable :: vertical_grid_class, standard_name, units
class(VerticalGrid), allocatable :: vertical_grid
real, allocatable :: levels(:)

has_geometry_section = ESMF_HConfigIsDefined(mapl_cfg,keyString=COMPONENT_GEOMETRY_SECTION, _RC)
_RETURN_UNLESS(has_geometry_section)
Expand Down Expand Up @@ -92,8 +94,18 @@ module function parse_geometry_spec(mapl_cfg, rc) result(geometry_spec)
if (has_vertical_grid) then
vertical_grid_class = ESMF_HConfigAsString(vertical_grid_cfg, keyString='class', _RC)
_ASSERT(vertical_grid_class == 'basic', 'unsupported class of vertical grid')
num_levels = ESMF_HConfigAsI4(vertical_grid_cfg, keyString='num_levels', _RC)
vertical_grid = BasicVerticalGrid(num_levels)
select case(vertical_grid_class)
case('basic')
num_levels = ESMF_HConfigAsI4(vertical_grid_cfg, keyString='num_levels', _RC)
vertical_grid = BasicVerticalGrid(num_levels)
case('fixedlevels')
standard_name = ESMF_HConfigAsString(vertical_grid_cfg, keyString='standard_name', _RC)
units = ESMF_HConfigAsString(vertical_grid_cfg, keyString='units', _RC)
levels = ESMF_HConfigAsR4Seq(vertical_grid_cfg, keyString='levels' ,_RC)
vertical_grid = FixedLevelsVerticalGrid(standard_name, levels, units)
case default
_FAIL('vertical grid class '//vertical_grid_class//' not supported')
end select
end if
geometry_spec = GeometrySpec(geom_spec=geom_spec, vertical_grid=vertical_grid)

Expand Down
9 changes: 5 additions & 4 deletions generic3g/vertical/FixedLevelsVerticalGrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ module mapl3g_FixedLevelsVerticalGrid
private
real(kind=REAL32), allocatable :: levels(:)
character(:), allocatable :: standard_name ! air_pressure, height, etc.
!# character(:), allocatable :: units
!# character(:), allocatable :: coordinate_name
character(:), allocatable :: units
contains
procedure :: get_num_levels
procedure :: get_coordinate_field
Expand All @@ -31,14 +30,16 @@ module mapl3g_FixedLevelsVerticalGrid

contains

function new_FixedLevelsVerticalGrid_r32(standard_name, levels) result(grid)
function new_FixedLevelsVerticalGrid_r32(standard_name, levels, units) result(grid)
type(FixedLevelsVerticalGrid) :: grid
real(REAL32), intent(in) :: levels(:)
character(*), intent(in) :: standard_name
character(*), intent(in) :: units

call grid%set_id()
grid%standard_name = standard_name
grid%levels = levels
grid%units = units

end function new_FixedLevelsVerticalGrid_r32

Expand Down Expand Up @@ -80,4 +81,4 @@ logical function can_connect_to(this, src, rc)
end function can_connect_to

end module mapl3g_FixedLevelsVerticalGrid

30 changes: 30 additions & 0 deletions generic3g/vertical/FixedLevelsVerticalGrid/can_connect_to.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "MAPL_ErrLog.h"
submodule (mapl3g_FixedLevelsVerticalGrid) can_connect_to_smod
use mapl3g_MirrorVerticalGrid
use mapl3g_ModelVerticalGrid
use mapl3g_BasicVerticalGrid

contains

logical module function can_connect_to(this, src, rc)
class(FixedLevelsVerticalGrid), intent(in) :: this
class(VerticalGrid), intent(in) :: src
integer, optional, intent(out) :: rc

select type(src)
type is (FixedLevelsVeritcalGrid)
can_connect_to =
type is (BasicVerticalGrid)
can_connect_to = (this%get_num_levels() == src%get_num_levels())
type is (MirrorVerticalGrid)
can_connect_to = .true.
type is (ModelVerticalGrid)
can_connect_to = (this%get_num_levels() == src%get_num_levels())
class default
_FAIL('BasicVerticalGrid can only connect to src BasicVerticalGrid, MirrorVerticalGrid, or ModelVerticalGrid instances.')
end select

_RETURN(_SUCCESS)
end function can_connect_to

end submodule

0 comments on commit 043f044

Please sign in to comment.