Skip to content

Commit

Permalink
Fixes related to VerticalGrid
Browse files Browse the repository at this point in the history
This PR crossed paths with outher work on VerticalGrid.  Patches here
let the tests run, but more work is needed to clean this up.
  • Loading branch information
tclune committed Nov 4, 2024
1 parent 6dbf257 commit 5fe042d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 24 deletions.
4 changes: 2 additions & 2 deletions generic3g/ComponentSpecParser.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ module mapl3g_ComponentSpecParser
module function parse_component_spec(hconfig, registry, rc) result(spec)
type(ComponentSpec) :: spec
type(ESMF_HConfig), target, intent(inout) :: hconfig
type(StateRegistry), optional, intent(in) :: registry
type(StateRegistry), optional, target, intent(in) :: registry
integer, optional, intent(out) :: rc
end function parse_component_spec

module function parse_geometry_spec(mapl_cfg, registry, rc) result(geometry_spec)
type(GeometrySpec) :: geometry_spec
type(ESMF_HConfig), intent(in) :: mapl_cfg
type(StateRegistry), optional, intent(in) :: registry
type(StateRegistry), optional, target, intent(in) :: registry
integer, optional, intent(out) :: rc
end function parse_geometry_spec

Expand Down
2 changes: 1 addition & 1 deletion generic3g/ComponentSpecParser/parse_component_spec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module function parse_component_spec(hconfig, registry, rc) result(spec)
type(ComponentSpec) :: spec
type(ESMF_HConfig), target, intent(inout) :: hconfig
type(StateRegistry), optional, intent(in) :: registry
type(StateRegistry), optional, target, intent(in) :: registry
integer, optional, intent(out) :: rc

integer :: status
Expand Down
2 changes: 1 addition & 1 deletion generic3g/ComponentSpecParser/parse_geometry_spec.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
module function parse_geometry_spec(mapl_cfg, registry, rc) result(geometry_spec)
type(GeometrySpec) :: geometry_spec
type(ESMF_HConfig), intent(in) :: mapl_cfg
type(StateRegistry), optional, intent(in) :: registry
type(StateRegistry), optional, target, intent(in) :: registry
integer, optional, intent(out) :: rc

integer :: status
Expand Down
4 changes: 2 additions & 2 deletions generic3g/OuterMetaComponent.F90
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ end subroutine I_child_Op
interface

recursive module subroutine SetServices_(this, rc)
class(OuterMetaComponent), intent(inout) :: this
integer, intent(out) ::rc
class(OuterMetaComponent), target, intent(inout) :: this
integer, intent(out) :: rc
end subroutine

module recursive subroutine add_child_by_name(this, child_name, setservices, hconfig, rc)
Expand Down
2 changes: 1 addition & 1 deletion generic3g/OuterMetaComponent/SetServices.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

recursive module subroutine SetServices_(this, rc)
use mapl3g_GenericGridComp, only: generic_setservices => setservices
class(OuterMetaComponent), intent(inout) :: this
class(OuterMetaComponent), target, intent(inout) :: this
integer, intent(out) :: rc

integer :: status
Expand Down
49 changes: 32 additions & 17 deletions generic3g/vertical/FixedLevelsVerticalGrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module mapl3g_FixedLevelsVerticalGrid

use mapl_ErrorHandling
use mapl3g_VerticalGrid
use mapl3g_VerticalStaggerLoc
use mapl3g_FieldCreate
use mapl3g_GriddedComponentDriver
use mapl3g_VerticalDimSpec
use mapl3g_InfoUtilities, only: MAPL_InfoSetInternal
Expand Down Expand Up @@ -90,7 +92,7 @@ subroutine get_coordinate_field(this, field, coupler, standard_name, geom, typek
_FAIL("invalid vertical_dim_spec")
end if

field = esmf_field_create_(geom, adjusted_levels, vloc, _RC)
field = esmf_field_create_(geom, adjusted_levels, _RC)

_RETURN(_SUCCESS)
_UNUSED_DUMMY(coupler)
Expand Down Expand Up @@ -149,36 +151,49 @@ end function not_equal_FixedLevelsVerticalGrid

! Create an ESMF_Field containing a 3D array that is replicated from
! a 1D array at each point of the horizontal grid
function esmf_field_create_(geom, farray1d, vloc, rc) result(field)
function esmf_field_create_(geom, farray1d, rc) result(field)
type(ESMF_Field) :: field ! result
type(ESMF_Geom), intent(in) :: geom
real(kind=REAL32), intent(in) :: farray1d(:)
character(len=*), intent(in) :: vloc
!# character(len=*), intent(in) :: vloc
integer, optional, intent(out) :: rc

integer, allocatable :: local_cell_count(:)
real(kind=REAL32), allocatable :: farray3d(:, :, :)
real(kind=REAL32), pointer :: farray3d(:, :, :)
integer :: i, j, IM, JM, status

! First, copy the 1D array, farray1d, to each point on the horz grid
!# ! First, copy the 1D array, farray1d, to each point on the horz grid
!# allocate(farray3d(IM, JM, size(farray1d)))
!# do concurrent (i=1:IM, j=1:JM)
!# farray3d(i, j, :) = farray1d(:)
!# end do

! Create an ESMF_Field containing farray3d
field = MAPL_FieldCreate( &
geom=geom, typekind=ESMF_TYPEKIND_R4, &
num_levels=size(farray1d), &
vert_staggerloc=VERTICAL_STAGGER_CENTER, &
_RC)

!# ! First, copy the 1D array, farray1d, to each point on the horz grid
call ESMF_FieldGet(field, fArrayPtr=farray3d, _RC)
call MAPL_GeomGet_(geom, localCellCount=local_cell_count, _RC)
IM = local_cell_count(1); JM = local_cell_count(2)
allocate(farray3d(IM, JM, size(farray1d)))
do concurrent (i=1:IM, j=1:JM)
farray3d(i, j, :) = farray1d(:)
end do

! Create an ESMF_Field containing farray3d
field = ESMF_FieldCreate( &
geom=geom, &
farray=farray3d, &
indexflag=ESMF_INDEX_DELOCAL, &
datacopyFlag=ESMF_DATACOPY_VALUE, &
ungriddedLBound=[1], &
ungriddedUBound=[size(farray1d)], &
_RC)
call MAPL_InfoSetInternal(field, key=KEY_NUM_LEVELS, value=size(farray1d), _RC)
call MAPL_InfoSetInternal(field, key=KEY_VLOC, value=vloc, _RC)
!# field = ESMF_FieldCreate( &
!# geom=geom, &
!# farray=farray3d, &
!# indexflag=ESMF_INDEX_DELOCAL, &
!# datacopyFlag=ESMF_DATACOPY_VALUE, &
!# ungriddedLBound=[1], &
!# ungriddedUBound=[size(farray1d)], &
!# _RC)
!#
!# call MAPL_InfoSetInternal(field, key=KEY_NUM_LEVELS, value=size(farray1d), _RC)
!# call MAPL_InfoSetInternal(field, key=KEY_VEVLOC, value=vloc, _RC)

_RETURN(_SUCCESS)
end function esmf_field_create_
Expand Down

0 comments on commit 5fe042d

Please sign in to comment.