# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "<stdin>"
program make_mask
  use sep
  use sep3d_struct_mod
  implicit none
  type(sep3d) :: in,out
  real, allocatable :: ina(:),outa(:,:)
  integer :: i,ih
  call init_sep3d("in",in,"INPUT")
  call init_sep3d(out,"SCRATCH","FLOAT","REGULAR",(/1,1,1/))
  out%n(1)=in%n(1)
  out%o(1)=in%o(1)
  out%d(1)=in%d(1)
  call from_param("n2",out%n(2))
  call from_param("o2",out%o(2))
  call from_param("d2",out%d(2))
  call from_param("n3",out%n(3))
  call from_param("o3",out%o(3))
  call from_param("d3",out%d(3))
  call sep3d_set_sep3d(out)
  call sep3d_write_description("out",out)
  allocate(ina(in%n(1)))
  allocate(outa(in%n(1),out%n(2)))
  call sreed("in",ina,size(ina)*4)
  outa=1
  do i=1,in%n(1)
    ih=max(1,min(out%n(2),nint((ina(i)-out%o(2))/out%d(2)+1.)))
    write(0,*) "CHECK I",i,ih,ina(i)
    outa(i,ih:)=0
  end do
  do i=1,out%n(3)
    call srite("out",outa,size(outa)*4)
  end do
end program
