Skip to content

Commit

Permalink
Fixed bug in previous commit.
Browse files Browse the repository at this point in the history
ESMF strings are fixed length.  Added allocatable accessor in
MAPL_FieldGet().
  • Loading branch information
tclune committed Nov 12, 2024
1 parent 4205f51 commit 4ecbb65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GeomIO/SharedIO.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ subroutine add_variable(metadata, field, rc)
integer :: pfio_type

variable_dim_names = get_variable_dim_names(field, geom, _RC)
call ESMF_FieldGet(field, name=short_name, typekind=typekind, _RC)
call MAPL_FieldGet(field, short_name=short_name, typekind=typekind, _RC)
pfio_type = esmf_to_pfio_type(typekind ,_RC)
v = Variable(type=pfio_type, dimensions=variable_dim_names)

Expand Down
16 changes: 14 additions & 2 deletions field/FieldGet.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ module mapl3g_FieldGet
contains

subroutine field_get(field, unusable, &
short_name, typekind, &
num_levels, vert_staggerloc, num_vgrid_levels, &
ungridded_dims, &
units, standard_name, long_name, &
units, standard_name, long_name, &
rc)

type(ESMF_Field), intent(in) :: field
class(KeywordEnforcer), optional, intent(in) :: unusable
character(len=:), optional, allocatable, intent(out) :: short_name
type(ESMF_TypeKind_Flag), optional, intent(out) :: typekind
integer, optional, intent(out) :: num_levels
type(VerticalStaggerLoc), optional, intent(out) :: vert_staggerloc
integer, optional, intent(out) :: num_vgrid_levels
Expand All @@ -43,9 +46,18 @@ subroutine field_get(field, unusable, &

integer :: status
type(ESMF_Info) :: field_info
character(len=ESMF_MAXSTR) :: fname

if (present(short_name)) then
call ESMF_FieldGet(field, name=fname, _RC)
short_name = trim(fname)
end if

if (present(typekind)) then
call ESMF_FieldGet(field, typekind=typekind, _RC)
end if

call ESMF_InfoGetFromHost(field, field_info, _RC)

call MAPL_FieldInfoGetInternal(field_info, &
num_levels=num_levels, &
vert_staggerloc=vert_staggerloc, &
Expand Down

0 comments on commit 4ecbb65

Please sign in to comment.