module OW_sst1

implicit none

real,private		:: oang,dang,o1,o2,d1,d2
integer,private		:: n1,n2,nang

contains

!--------------------------------------------------------
subroutine owss1_init(oangb,dangb,o1b,o2b,d1b,d2b,n1b,n2b,nangb)
real			:: oangb,dangb,o1b,o2b,d1b,d2b
integer			:: n1b,n2b,nangb

oang=oangb
dang=dangb
o1=o1b
o2=o2b
d1=d1b
d2=d2b
n1=n1b
n2=n2b
nang=nangb

end subroutine

!--------------------------------------------------------
subroutine owss1(c,cs)
real			:: c(:,:),cs(:,:)
integer			:: iz,izd,ix,iax
real			:: x0,z0,hx,zm,zd,tang

x0=o2
z0=o1

do iax=1, nang 
   tang=tan(((iax-1)*dang+oang)*3.14159/180.)
   do ix=1,n2
      hx = x0+(ix-1)*d2				! midpoint
      do iz=1,n1  
         zm=z0+(iz-1)*d1				! depth
         zd=zm-tang*hx
         izd = 1.5 + int((zd-z0)/d1)
         if (izd<=n1 .and. izd>=1) then			! out of the range
            cs(iz,iax) = cs(iz,iax) + c(izd,ix)
         end if
      end do
   end do
end do
end subroutine 
end module 
