subroutine init_src(grid, coordX, coordY, nx, ny, dx, dy, src, 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(:,:)
integer, intent(out), optional :: rc
integer :: localrc, i,j
if(present(rc)) rc = ESMF_SUCCESS
! X center
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(coordY,1), ubound(coordY,1)
src(i,j) = 0.5*sin(coordX(i)/(nx*dx)*3*3.14159)*cos(coordY(j)&
/(ny*dy)*5*3.14159)+0.5
!src(i,j) = 2.
enddo
enddo
end subroutine init_src