program ab
 use sep
 integer :: n1,n2,n3,n4,n5,i1,i5
 real,allocatable :: buf(:,:)
 real :: cmax,sc
call sep_init()

  call from_history("n5",n5)
  call from_history("n3",n3)
  call from_history("n1",n1)

  allocate(buf(2*n1*n3,n5))
  call sreed("in",buf,size(buf)*4)
call from_param("mx",sc,8.)

  cmax=maxval(abs(buf))
write(0,*) "BBB",cmax
  do i5=1,n5
write(0,*) "1uf",maxval(buf(:,i5)),sc,cmax
    do i1=1,n1*2*n3
!if(buf(i1,i5)<0.) buf(i1,i5)=buf(i1,i5)*128/cmax
      buf(i1,i5)=nint(buf(i1,i5)*sc/cmax)
    end do
write(0,*) "2uf",maxval(buf(:,i5))
  end do
 
  call srite("out",buf,size(buf)*4)
  



end program
