subroutine diff_ptr_sph(grid, coordX, coordY, nx, ny, dx, dy, src, error, rc)
type(ESMF_Grid), intent(in) :: grid
real(ESMF_KIND_R8), pointer :: coordX(:,:)
real(ESMF_KIND_R8), pointer :: coordY(:,:)
integer, intent(in) :: nx, ny
real, intent(in) :: dx, dy
real(ESMF_KIND_R8), pointer :: src(:,:), error(:,:)
integer, intent(out), optional :: rc
integer :: localrc, i,j
if(present(rc)) rc = ESMF_SUCCESS
call ESMF_GridGetCoord(grid, localDE=0, &
staggerLoc=ESMF_STAGGERLOC_CENTER, &
coordDim=1, farrayPtr=coordX, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
! Y center
call ESMF_GridGetCoord(grid, localDE=0, &
staggerLoc=ESMF_STAGGERLOC_CENTER, &
coordDim=2, farrayPtr=coordY, rc=localrc)
if (ESMF_LogFoundError(localrc, &
ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, rcToReturn=rc)) return
do i = lbound(coordX,1), ubound(coordX,1)
do j = lbound(coordX,2), ubound(coordX,2)
error(i,j) = src(i,j) - error(i,j)
enddo
enddo
end subroutine diff_ptr_sph