program ab
use sep
integer :: n1,n2
real :: pct
real, allocatable :: map(:,:)
integer, allocatable :: zero(:,:)
integer :: i,n
logical :: found
real :: r
integer :: iloc

  call sep_init()
  call from_history("n2",n2)
  call from_history("n1",n1)
  call from_param("pct",pct,80.)
   call sep_put_data_axis_par("map",2,n2,0.,1.,"axis1")
   call sep_put_data_axis_par("map",1,n1,0.,1.,"axis1")


  allocate(map(n1,n2),zero(n1,n2))
  zero=1
  call sreed("in",map,size(map)*4)

  n=n2*pct/100.
  do i=1,n
    found=.false.
    do while(.not. found)
       call random_number(r)
       iloc=max(1,min(n2,nint(r*n2)))
       if(zero(1,iloc)==1) then
         map(:,iloc)=0
         found=.true.
         zero(:,iloc)=0
       end  if
    end do
end do
call srite("out",map,size(map)*4)
call srite("map",zero,size(map)*4)
       
       
       
       




   







end program
