module OW_slantstk

use OW_type
use OW_parms_areal
use OW_fftw_areal
use OW_exec_time

implicit none

contains

subroutine owslant(c,cs)
real				:: c(:,:),cs(:,:)
real,allocatable			:: css(:,:)
integer				:: iz,izd,ix,iax
real				:: x0,z0,hx,zm,zd

allocate(css(azn,ndip));css=0.

x0=int(-axn/2.)*img%xm%d
z0=int(-azn/2.)*img%z%d

do iax=1, ndip 
   do ix=1,axn
      hx = x0+(ix-1)*img%xm%d				! midpoint
      do iz=1,azn  
         zm=z0+(iz-1)*img%z%d				! depth
         zd=zm-tan(dips(iax))*hx
         izd = 1.5 + int((zd-z0)/img%z%d)
         if (izd<=azn .and. izd>=1) then			! out of the range
            css(iz,iax) = css(iz,iax) + c(izd,ix)
         end if
      end do
   end do
end do
cs=css
deallocate(css)
end subroutine 
end module 
