Skip to content

Commit

Permalink
Merge pull request #3118 from GEOS-ESM/bug/pchakrab/field-utils
Browse files Browse the repository at this point in the history
`get_fptr_shape` - bug fix
  • Loading branch information
pchakraborty authored Oct 25, 2024
2 parents d55e1da + d48bf3a commit d3bd437
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions field_utils/FieldCondensedArray.F90
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ function get_fptr_shape(f, rc) result(fptr_shape)
logical :: has_vertical
character(len=:), allocatable :: spec_name
character(len=*), parameter :: VERTICAL_DIM_NONE_NAME = 'VERTICAL_DIM_NONE'
integer :: dimCount
integer :: geomDimCount

call ESMF_FieldGet(f, dimCount=dimCount, rank=rank, _RC)
call ESMF_FieldGet(f, geomDimCount=geomDimCount, rank=rank, _RC)
_ASSERT(.not. rank < 0, 'rank cannot be negative.')
_ASSERT(.not. dimCount < 0, 'dimCount cannot be negative.')
_ASSERT(.not. geomDimCount < 0, 'geomDimCount cannot be negative.')
allocate(localElementCount(rank))
allocate(gridToFieldMap(dimCount))
allocate(gridToFieldMap(geomDimCount))
call ESMF_FieldGet(f, gridToFieldMap=gridToFieldMap, _RC)
! Due to an ESMF bug, getting the localElementCount must use the module function.
! See FieldGetLocalElementCount (specific function) comments.
Expand All @@ -71,6 +71,7 @@ function get_fptr_shape(f, rc) result(fptr_shape)
has_vertical = spec_name /= VERTICAL_DIM_NONE_NAME
fptr_shape = get_fptr_shape_private(gridToFieldMap, localElementCount, has_vertical, _RC)

_RETURN(_SUCCESS)
end function get_fptr_shape

end module mapl3g_FieldCondensedArray
2 changes: 1 addition & 1 deletion field_utils/FieldCondensedArray_private.F90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function get_fptr_shape_private(gridToFieldMap, localElementCount, has_vertical,

vert_dim = 0
vert_size = 1

rank = size(localElementCount)
grid_dims = pack(gridToFieldMap, gridToFieldMap /= 0)
_ASSERT(all(grid_dims <= size(grid_dims)), 'MAPL expects geom dims before ungridded.')
Expand Down

0 comments on commit d3bd437

Please sign in to comment.