ESMF_XGridGeomBaseDeserialize Function

public function ESMF_XGridGeomBaseDeserialize(buffer, offset, attreconflag, rc)

Arguments

Type IntentOptional Attributes Name
character(len=1), pointer, dimension(:) :: buffer
integer, intent(inout) :: offset
type(ESMF_AttReconcileFlag), optional :: attreconflag
integer, intent(out), optional :: rc

Return Value type(ESMF_XGridGeomBase)


Source Code

      function ESMF_XGridGeomBaseDeserialize(buffer, offset, attreconflag, rc)
!
! !RETURN VALUE:
      type(ESMF_XGridGeomBase) :: ESMF_XGridGeomBaseDeserialize
!
! !ARGUMENTS:
      character, pointer, dimension(:)      :: buffer
      integer, intent(inout)                :: offset
      type(ESMF_AttReconcileFlag), optional :: attreconflag
      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 serialization is to be done
!     \item [{[rc]}]
!           Return code; equals {\tt ESMF\_SUCCESS} if there are no errors.
!     \end{description}
!
!EOPI
    type(ESMF_XGridGeomBaseClass),pointer :: gbcp
    integer :: localrc
    type(ESMF_AttReconcileFlag) :: lattreconflag

    ! 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

    ! allocate GeomBase type
    allocate(gbcp, stat=localrc)
    if (ESMF_LogFoundAllocError(localrc, msg="Allocating GeomBase type object", &
                                     ESMF_CONTEXT,  &
                                     rcToReturn=rc)) return

    ! serialize GeomBase info
    call c_ESMC_XGridGeomBaseDeserialize(gbcp%type%type,        &
                                    gbcp%staggerloc%staggerloc, &
                                    gbcp%meshloc%meshloc, &
                                    buffer, offset, localrc)
    if (ESMF_LogFoundError(localrc, &
   ESMF_ERR_PASSTHRU, &
   ESMF_CONTEXT, rcToReturn=rc)) return

    ! Get info depending on type
    select case(gbcp%type%type)

     case (ESMF_XGRIDGEOMTYPE_GRID%type) ! Grid
        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_XGRIDGEOMTYPE_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 default
       if (ESMF_LogFoundError(ESMF_RC_ARG_VALUE, &
           msg=" Bad type value", &
           ESMF_CONTEXT, rcToReturn=rc)) return
    end select


    ! Set pointer
    ESMF_XGridGeomBaseDeserialize%gbcp=>gbcp

    ! Add reference to this object into ESMF garbage collection table
    call c_ESMC_VMAddFObject(ESMF_XGridGeomBaseDeserialize, ESMF_ID_GEOMBASE%objectID)

   ! Set init status
    ESMF_INIT_SET_CREATED(ESMF_XGridGeomBaseDeserialize)

    if  (present(rc)) rc = ESMF_SUCCESS

    end function ESMF_XGridGeomBaseDeserialize