module OW_shaper

 use OW_type
 use OW_parms_areal

implicit none

contains

!===============================================
subroutine owshaper(source,GGS)
 integer			:: nrepeat,ixs,irepeat,i
 complex			:: source(:),GGS(:,:)
 complex, allocatable	:: wav(:),wav0(:)

nrepeat=3
allocate(wav(2*sou%w%n),wav0(2*sou%w%n))
!do ixs=1,nx
!   wav=0;wav0=0
!   wav(1:sou%w%n)=GGS(:,ixs)
!!   if (encode.and.rand) then
!      wav0=wav
!      do irepeat=1,nrepeat
!         do i=7,2*sou%w%n-6
!            wav(i)=sum(wav0(i-6:i+6))/13
!         end do
!      end do
!!   end if
!   wav=wav/maxval(abs(wav))
!   GGS(:,ixs)=GGS(:,ixs)*abs(source)/(abs(wav(1:sou%w%n))+0.001)
!end do
do i=1,sou%w%n
   GGS(i,:)=GGS(i,:)*(cmplx(cos(pi/4.), -sin(pi/4.)) * sqrt(sou%w%all(i))) * abs(source(i))
end do
deallocate(wav,wav0)
end subroutine
end module
