program Repeat3
  !! Repeat a 2-D slice in the 3rd direction
  !! Paul Sava (paul@sep.stanford.edu)
  !! 08/08/01

  use sep

  implicit none
  integer :: n1,n2,n3, i3
  real    :: o3,d3
  real,    dimension(:,:), allocatable:: rdata
  complex, dimension(:,:), allocatable:: cdata
  integer :: esize

  call sep_init()

  call from_history("n1",n1)
  call from_history("n2",n2)
  call from_param  ("n3",n3,1 )
  call from_param  ("o3",o3,0.)
  call from_param  ("d3",d3,1.)

  call to_history  ("n3",n3)
  call to_history  ("o3",o3)
  call to_history  ("d3",d3)

  call from_history("esize",esize,4)
  call sep_close()

  if(esize==4) then
     allocate(rdata(n1,n2))
     call sep_read(rdata)
     do i3=1,n3
        call sep_write(rdata)
     end do
     deallocate(rdata)
  else
     allocate(cdata(n1,n2))
     call sep_read(cdata)
     do i3=1,n3
        call sep_write(cdata)
     end do
     deallocate(cdata)
  end if

  call exit(0)
end program REPEAT3













