subroutine test3g(rc)
integer, intent(out) :: rc
integer :: localrc
type(ESMF_Field) :: field
type(ESMF_Grid) :: grid
real, dimension(:,:, :), allocatable :: farray
real, dimension(:,:, :), pointer :: farray1
type(ESMF_VM) :: vm
integer :: lpe
integer, dimension(2) :: ec, cc
integer, dimension(2) :: gelb, geub, gclb, gcub
type(ESMF_StaggerLoc) :: sloc
integer, dimension(3) :: felb, feub, fclb, fcub, ftlb, ftub
integer, dimension(3) :: fec, fcc, ftc
rc = ESMF_SUCCESS
localrc = ESMF_SUCCESS
grid = ESMF_GridCreateNoPeriDim(minIndex=(/1,1/), maxIndex=(/10,20/), &
regDecomp=(/2,2/), name="testgrid", rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_VMGetGlobal(vm, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_VMGet(vm, localPet=lpe, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
sloc = ESMF_STAGGERLOC_CENTER
call ESMF_GridGet(grid, localDe=0, staggerloc=sloc, &
exclusiveLBound=gelb, exclusiveUBound=geub, exclusiveCount=ec, &
computationalLBound=gclb, computationalUBound=gcub, computationalCount=cc, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
allocate(farray(max(cc(2)+7, ec(2)), 10, max(cc(1)+10, ec(1))))
!write(*, "(22I3)") lpe, ec(1:2), cc(1:2)
field = ESMF_FieldCreate(grid, farray, &
indexflag=ESMF_INDEX_DELOCAL, datacopyflag=ESMF_DATACOPY_VALUE, &
staggerloc=ESMF_STAGGERLOC_CENTER, gridToFieldMap = (/3,1/), &
ungriddedLBound=(/1/), ungriddedUBound=(/10/), &
totalLWidth=(/2,4/), totalUWidth=(/5,6/), rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_FieldGet(field, localDe=0, farrayPtr=farray1, &
exclusiveLBound=felb, exclusiveUBound=feub, exclusiveCount=fec, &
computationalLBound=fclb, computationalUBound=fcub, computationalCount=fcc, &
totalLBound=ftlb, totalUBound=ftub, totalCount=ftc, &
rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
!write(*, "(42I3)") lpe, felb, feub, fclb, fcub, ftlb, ftub
call ESMF_FieldDestroy(field, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
call ESMF_GridDestroy(grid, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
deallocate(farray)
end subroutine test3g