program Rasp_
  use sep

  implicit none

  integer           :: n1,n2,n3, nsp
  integer           :: i1,i2,i3, isp
  real              :: d1,d2,d3
  real              :: o1,o2,o3
  real, allocatable :: dat(:,:,:)

  integer, dimension(:), allocatable :: seed,old
  integer                            :: i,k
  character(len=20)                  :: date, time, zone
  integer, dimension(8)              :: values
  integer                            :: s1,s2

  real  :: r
  
  call sep_init()

  call from_param("n1",n1,1)
  call from_param("n2",n2,1)
  call from_param("n3",n3,1)

  call from_param("d1",d1,1.)
  call from_param("d2",d2,1.)
  call from_param("d3",d3,1.)

  call from_param("o1",o1,0.)
  call from_param("o2",o2,0.)
  call from_param("o3",o3,1.)

  call from_param("nsp",nsp,1)

  call sep_close()

  allocate(dat(n1,n2,n3))

  !!init the random number generator
  call random_seed(size=k)
  allocate(seed(k),old(k))
  call date_and_time(date,time,zone,values)
  
  s1=product(values(5:6)); s1=min(s1,31328)
  s2=product(values(5:7)); s2=min(s2,30081)
  seed(1:2) = (/s1, s2/)
  call random_seed(put = seed(1:k))
  
  do isp=1,nsp
     call random_number(r); i1=ceiling((n1-1)*r); i1=max(i1,1)
     call random_number(r); i2=ceiling((n2-1)*r); i2=max(i2,1)
     call random_number(r); i3=ceiling((n3-1)*r); i3=max(i3,1)
     call random_number(r)

     dat(i1,i2,i3)=r-.5
  end do

  call sep_write(dat)

  call exit(0)
end program RASP_



