module OW_grabvel

use OW_type
use OW_parms

implicit none

contains

subroutine owgrab_vel(ixs,velint,vel,ni)

integer						:: ixs, ni, nv
real						:: velint(:,:), vel(:,:)
real						:: owrk


! workspace origin 

    owrk=(ixs-1)*rec%x%d+rec%x%o+rec%h%o
! grab velocity in the workspace       
    nv = ceiling((owrk-v%xm%o)/v%xm%d)
    ni = ceiling((owrk-img%xm%o)/img%xm%d)

   write(0,*) owrk,nv,ni


    vel=0;
    vel(:,:)=velint(:,nv:nv+rec%h%n-1);
    if (owrk < img%xm%o .or. owrk > img%xm%o+img%xm%d*(img%xm%n-1)) then
         call seperr('WORKING SPACE GREATER THAN ')
         write(0,*)  'THE IMAGE SPACE FOR SHOT # ',ixs
    end if

end subroutine

end module
