subroutine checkProxy(xgrid, rc)
type(ESMF_XGrid), intent(in) :: xgrid
integer, intent(out), optional :: rc
type(ESMF_XGrid) :: xgrid1
character, pointer :: buffer(:)
integer :: buff_length, offset, localrc
if(present(rc)) rc = ESMF_SUCCESS
! Allocate serialization buffer
buff_length = 1
allocate (buffer(0:buff_length-1))
offset = 0
call ESMF_XGridSerialize(xgrid, buffer, buff_length, offset, &
inquireflag=ESMF_INQUIREONLY, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
deallocate (buffer)
buff_length = offset
allocate (buffer(0:buff_length-1))
! call serialize and deserialize and verify again
offset = 0
call ESMF_XGridSerialize(xgrid, buffer, buff_length, offset, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
offset = 0
xgrid1 = ESMF_XGridDeserialize(buffer, offset, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
deallocate (buffer)
call ESMF_XGridValidate(xgrid1, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
end subroutine checkProxy