module OW_grabvel_areal
use OW_type
use OW_parms_areal
implicit none
contains
!------------------------------------
subroutine owgrab_velim(velint,vel,ni)
integer   			:: ni
integer				:: nvx,nvy,i,j,k
real				:: velint(:), vel(kxm%n,kym%n,nz),owrkx,owrky

   nvx = floor((xmin-v%xm%o)/v%xm%d)+1
   nvy = floor((ymin-v%ym%o)/v%ym%d)+1
   vel=0
   do k=nzmin,nzmax
   do j=nvy,nvy+kym%n-1
   do i=nvx,nvx+kxm%n-1
      if (velint((k-1)*v%xm%n*v%ym%n+(j-1)*v%ym%n+i) == 0) then
         vel(i-nvx+1,j-nvy+1,k-nzmin+1)=0
      else
         vel(i-nvx+1,j-nvy+1,k-nzmin+1)=velint((k-1)*v%xm%n*v%ym%n+(j-1)*v%ym%n+i)
      end if
   end do
   end do
   end do

end subroutine
!=========================
end module
