program main
  use sep
  implicit none

  real, dimension(:), allocatable :: dat1, dat2
  real, dimension(:), allocatable :: mod1, mod2
  real                               :: dot(2)
  integer                            :: nt, ngx, ngy, nsx, nsy
  real                               :: dt, dgx, dgy, dsx, dsy
  real                               :: ot, ogx, ogy, osx, osy
  integer                            :: nz, nx, ny, nhx, nhy
  real                               :: dz, dx, dy, dhx, dhy
  real                               :: oz, ox, oy, ohx, ohy

  nt = 512   ; ngx = 101    ; ngy =    101 ; nsx = 1 ; nsy = 1
  dt = 0.004 ; dgx = 20.    ; dgy =    20. ; dsx = 1.; dsy = 1.
  ot = 0.    ; ogx = -1000. ; ogy = -1000. ; osx = 0.; osy = 0.

  nz = 100 ; nx  = 101   ; ny  = 101   ; nhx = 5 ; nhy = 5
  dz = 10.; dx  = 20.   ; dy  = 20.   ; dhx = 20; dhy = 20
  oz = 0.; ox  = -1000.; oy  = -1000.; ohx = -40.; ohy = -40.

  call initpar()

  allocate(dat1(nt*ngx*ngy*nsx*nsy))
  allocate(mod2(nz*nx*ny*nhx*nhy))

  write(0,*)"ddddddddddddddd"

  dat1 = 0.
  mod2 = 0.
 
  call random_number(dat1)
  call random_number(mod2)


  call srite("dat1", dat1, 4*size(dat1))
  call srite("mod2", mod2, 4*size(mod2))


  call to_history("n1",  nt, "dat1"); call to_history("d1",  dt, "dat1"); call to_history("o1",  ot, "dat1")
  call to_history("n2", ngx, "dat1"); call to_history("d2", dgx, "dat1"); call to_history("o2", ogx, "dat1")
  call to_history("n3", ngy, "dat1"); call to_history("d3", dgy, "dat1"); call to_history("o3", ogy, "dat1")
  call to_history("n4", nsx, "dat1"); call to_history("d4", dsx, "dat1"); call to_history("o4", osx, "dat1")
  call to_history("n5", nsy, "dat1"); call to_history("d5", dsy, "dat1"); call to_history("o5", osy, "dat1")
  call to_history("esize", 4, "dat1")

  call to_history("n1",  nx, "mod2"); call to_history("d1",  dx, "mod2"); call to_history("o1",  ox, "mod2")
  call to_history("n2",  ny, "mod2"); call to_history("d2",  dy, "mod2"); call to_history("o2",  oy, "mod2")
  call to_history("n3", nhx, "mod2"); call to_history("d3", dhx, "mod2"); call to_history("o3", ohx, "mod2")
  call to_history("n4", nhy, "mod2"); call to_history("d4", dhy, "mod2"); call to_history("o4", ohy, "mod2")
  call to_history("n5",  nz, "mod2"); call to_history("d5",  dz, "mod2"); call to_history("o5",  oz, "mod2")
  call to_history("esize", 4, "mod2")

  write(0,*)dot

end program
