program OW_hgain
! 

  use sep

  implicit none
  real, allocatable  :: in(:,:),out(:,:),hw(:,:)
  integer 	 :: ix,ih,n1,n2,n3
  real               :: hx,w,o1,o2,o3,d1,d2,d3

   call sep_init()
   call sep_begin_prog()
   call from_history("n1",n1);call from_history("d1",d1);call from_history("o1",o1)
   call from_history("n2",n2);call from_history("d2",d2);call from_history("o2",o2)
   call from_history("n3",n3);call from_history("d3",d3);call from_history("o3",o3)  
   call to_history("n1",n1);call to_history("d1",d1);call to_history("o1",o1)
   call to_history("n2",n2);call to_history("d2",d2);call to_history("o2",o2)
   call to_history("n3",n3);call to_history("d3",d3);call to_history("o3",o3)  
   call to_history("label1","z");call to_history("label2","h")
   call to_history("label3","x")
   call to_history("esize",4)
   call from_param("w",w,4.)

   allocate(in(n1,n2),out(n1,n2),hw(n1,n2))
   do ih=1,n2
      hx=(ih-1)*d2+o2
      hw(:,ih)=1 - abs(hx)/2/abs(o2)
   end do
   hw=hw**w
   do ix=1, n3
      call sreed("in",in,4*n1*n2)
      out = in/hw
      call srite("out",out,4*n1*n2)
   end do
   deallocate(in,out,hw)
   call sep_end_prog()
end program
