subroutine checkGrid(grid,staggerloc,rc)
type (ESMF_Grid) :: grid
type(ESMF_StaggerLoc) :: staggerloc
integer, intent(out), optional :: rc
type(ESMF_GridDecompType) :: decompType
integer :: localDECount, lDE, ec(ESMF_MAXDIM)
integer :: localrc, i, dimCount
if (present(rc)) rc = ESMF_RC_NOT_IMPL
! Make sure Grid isn't arbitrarily distributed
call ESMF_GridGetDecompType(grid, decompType, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Error if decompType is ARBITRARY
if (decompType .eq. ESMF_GRID_ARBITRARY) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, &
msg="- can't currently regrid an arbitrarily distributed Grid", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
! Make sure Grid doesn't contain width 1 DEs
call ESMF_GridGet(grid,localDECount=localDECount, dimCount=dimCount, &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! loop through checking DEs
do lDE=0,localDECount-1
! Get bounds of DE
call ESMF_GridGet(grid,staggerloc=staggerloc, localDE=lDE, &
exclusivecount=ec,rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! loop and make sure they aren't too small in any dimension
do i=1,dimCount
if (ec(i) .eq. 1) then
call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, &
msg=" some types of regridding (e.g. bilinear) are not supported on Grids that contain a DE of width 1.", &
ESMF_CONTEXT, rcToReturn=rc)
return
endif
enddo
enddo
if(present(rc)) rc = ESMF_SUCCESS
end subroutine checkGrid