function ESMF_GeomDeserialize(buffer, offset, attreconflag, skipGeomObj, &
rc)
!
! !RETURN VALUE:
type(ESMF_Geom) :: ESMF_GeomDeserialize
!
! !ARGUMENTS:
character, pointer, dimension(:) :: buffer
integer, intent(inout) :: offset
type(ESMF_AttReconcileFlag), optional :: attreconflag
logical, intent(in), optional :: skipGeomObj
integer, intent(out), optional :: rc
!
! !DESCRIPTION:
! Takes a byte-stream buffer and reads the information needed to
! recreate a Grid object. Recursively calls the deserialize routines
! needed to recreate the subobjects.
! Expected to be used by {\tt ESMF\_StateReconcile()}.
!
! The arguments are:
! \begin{description}
! \item [buffer]
! Data buffer which holds the serialized information.
! \item [offset]
! Current read offset in the current buffer. This will be
! updated by this routine and return pointing to the next
! unread byte in the buffer.
! \item[{[attreconflag]}]
! Flag to tell if Attribute deserialization is to be done
! \item[{[skipGeomObj]}]
! Default is false. If true, do not deserialize 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
integer :: geomobj_len
logical, parameter :: trace = .false.
character(ESMF_MAXSTR) :: grid_name
logical :: local_skipGeomObj
! ----------
! Initialize return code; assume failure until success is certain
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! deal with optional attreconflag
if (present(attreconflag)) then
lattreconflag = attreconflag
else
lattreconflag = ESMF_ATTRECONCILE_OFF
endif
if (present(skipGeomObj)) then
local_skipGeomObj = skipGeomObj
else
local_skipGeomObj = .false.
end if
! ----------
! allocate Geom type
allocate(gbcp, stat=localrc)
if (ESMF_LogFoundAllocError(localrc, msg="Allocating Geom type object", &
ESMF_CONTEXT, rcToReturn=rc)) return
! deserialize Geom info
call c_ESMC_GeomDeserialize(gbcp%type%type, &
gbcp%staggerloc%staggerloc, &
gbcp%meshloc%meshloc, &
gbcp%xgridside, &
gbcp%xgridIndex, &
buffer, offset, localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
geomobj_len = transfer (buffer(offset:offset+3), geomobj_len)
if (trace) &
call ESMF_LogWrite (msg='deserialized geom object len =' // &
ESMF_UtilStringInt2String (geomobj_len), ESMF_CONTEXT)
offset = offset + 4
! 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)
gbcp%grid=ESMF_GridDeserialize(buffer=buffer, &
offset=offset, attreconflag=lattreconflag, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_MESH%type)
gbcp%mesh=ESMF_MeshDeserialize(buffer=buffer, &
offset=offset, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_LOCSTREAM%type)
gbcp%locstream=ESMF_LocStreamDeserialize(buffer=buffer, &
offset=offset, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
case (ESMF_GEOMTYPE_XGRID%type)
gbcp%xgrid=ESMF_XGridDeserialize(buffer=buffer, &
offset=offset, 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 pointer
ESMF_GeomDeserialize%gbcp=>gbcp
! Set init status
ESMF_INIT_SET_CREATED(ESMF_GeomDeserialize)
if (present(rc)) rc = ESMF_SUCCESS
end function ESMF_GeomDeserialize