program main
  use base_struct_mod
  use hes_convol_mod
  use sep
  implicit none

  type(hes_grid)                      :: hgrid
  real, dimension(:,:,:), allocatable :: modl
  real, dimension(:,:,:), allocatable :: data 
  real, dimension(:,:,:), allocatable :: hess

  character(len=256)                  :: modl_, data_, hess_
  integer                             :: stat

  call sep_init(SOURCE)
  call getch_add_string("head=/dev/null")
  call getch_add_string("noheader=y")
  call set_no_putch()
  call sep_begin_prog()

  modl_ = "modl"
  data_ = "data"
  hess_ = "hess"

  call auxin (modl_)
  call auxin (hess_)
  call auxout(data_)

  call hinaxis(hess_, hgrid%ax_modl, 1) 
  call hinaxis(hess_, hgrid%ay_modl, 2)
  call hinaxis(hess_, hgrid%az_modl, 3)
  call hinaxis(hess_, hgrid%ax_offd, 4)
  call hinaxis(hess_, hgrid%ay_offd, 5)
  call hinaxis(hess_, hgrid%az_offd, 6)

  call houaxis(data_, hgrid%ax_modl, 1)
  call houaxis(data_, hgrid%ay_modl, 2)
  call houaxis(data_, hgrid%az_modl, 3)

  allocate(modl(hgrid%ax_modl%n, hgrid%ay_modl%n, hgrid%az_modl%n))
  allocate(data(hgrid%ax_modl%n, hgrid%ay_modl%n, hgrid%az_modl%n))
  allocate(hess(hgrid%ax_modl%n, hgrid%ay_modl%n, hgrid%az_modl%n))

  call sep_read(modl, modl_)

  stat = hes_convol_init(hgrid, hess_)
  stat = hes_convol_oper(modl, data, hess)
  stat = hes_convol_clos()

  call sep_write(data, data_)

  deallocate(modl, data, hess)

end program
