subroutine ESMF_GeomSerialize(geom, buffer, length, offset, &
attreconflag, inquireflag, skipGeomObj, &
rc)
!
! !ARGUMENTS:
type(ESMF_Geom), intent(inout) :: geom
character, pointer, dimension(:) :: buffer
integer, intent(inout) :: length
integer, intent(inout) :: offset
type(ESMF_AttReconcileFlag), intent(in), optional :: attreconflag
type(ESMF_InquireFlag), intent(in), optional :: inquireflag
logical, intent(in), optional :: skipGeomObj
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! Takes an {\tt ESMF\_Geom} object and adds all the information needed
! to recreate the object based on this information.
! Expected to be used by {\tt ESMF\_StateReconcile()}.
!
! The arguments are:
! \begin{description}
! \item [geom]
! {\tt ESMF\_Geom} object to be serialized.
! \item [buffer]
! Data buffer which will hold the serialized information.
! \item [length]
! Current length of buffer, in bytes. If the serialization
! process needs more space it will allocate it and update
! this length.
! \item [offset]
! Current write offset in the current buffer. This will be
! updated by this routine and return pointing to the next
! available byte in the buffer.
! \item[{[attreconflag]}]
! Flag to tell if Attribute serialization is to be done
! \item[{[inquireflag]}]
! Flag to tell if serialization is to be done (ESMF_NOINQUIRE)
! or if this is simply a size inquiry (ESMF_INQUIREONLY)
! \item[{[skipGeomObj]}]
! Default is false. If true, do not serialize the underlying geometry
! object associated with this base.
! \item [{[rc]}]
! Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
! \end{description}
!
!EOPI
type(ESMF_GeomClass),pointer :: gbcp
integer :: localrc
type(ESMF_AttReconcileFlag) :: lattreconflag
type(ESMF_InquireFlag) :: linquireflag
integer :: geomobj_loffset
logical :: local_skipGeomObj
! ----------
! Initialize return code; assume failure until success is certain
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Check init status of arguments
ESMF_INIT_CHECK_DEEP_SHORT(ESMF_GeomGetInit, geom, rc)
! deal with optional attreconflag and inquireflag
if (present(attreconflag)) then
lattreconflag = attreconflag
else
lattreconflag = ESMF_ATTRECONCILE_OFF
endif
if (present (inquireflag)) then
linquireflag = inquireflag
else
linquireflag = ESMF_NOINQUIRE
end if
if (present(skipGeomObj)) then
local_skipGeomObj = skipGeomObj
else
local_skipGeomObj = .false.
end if
! ----------
! Get GeomClass
gbcp=>geom%gbcp
! serialize Geom info
call c_ESMC_GeomSerialize(gbcp%type%type, &
gbcp%staggerloc%staggerloc, &
gbcp%meshloc%meshloc, &
gbcp%xgridside, &
gbcp%xgridIndex, &
buffer, length, offset, linquireflag, &
localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Leave room for the length of the serialized Geom object
geomobj_loffset = offset
if (linquireflag == ESMF_NOINQUIRE) &
buffer(offset:offset+3) = transfer (123421, buffer) ! Dummy value for the moment
offset = offset + 4
! print *, ESMF_METHOD, ': offset at start of Geom object =', offset
! Do nothing with the Geom's attached geometry object if we are skipping
if (.not. local_skipGeomObj) then
! Get info depending on type
select case(gbcp%type%type)
case (ESMF_GEOMTYPE_GRID%type) ! Grid
call ESMF_GridSerialize(grid=gbcp%grid, buffer=buffer, &
length=length, offset=offset, &
attreconflag=lattreconflag, inquireflag=linquireflag, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_MESH%type)
call ESMF_MeshSerialize(mesh=gbcp%mesh, buffer=buffer, &
length=length, offset=offset, &
inquireflag=linquireflag, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_LOCSTREAM%type)
call ESMF_LocStreamSerialize(locstream=gbcp%locstream, &
buffer=buffer,length=length, offset=offset, &
inquireflag=linquireflag, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_XGRID%type)
call ESMF_XGridSerialize(xgrid=gbcp%xgrid, &
buffer=buffer,length=length, offset=offset, &
inquireflag=linquireflag, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case default
if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
msg=" Bad type value", &
ESMF_CONTEXT, rcToReturn=rc)) return
end select
end if
! Set length of the serialized object
! print *, ESMF_METHOD, ': offset after geom object serialize =', offset
if (linquireflag == ESMF_NOINQUIRE) &
buffer(geomobj_loffset:geomobj_loffset+3) = &
transfer (offset - (geomobj_loffset+4), buffer)
! Set return value
if (present(rc)) rc = ESMF_SUCCESS
end subroutine ESMF_GeomSerialize