program rot_sog
  use sep
  use rotsog_mod
  use solver_tiny_mod
  use solver_prc_mod
  use cgstep_mod
  use igrad1
!  use ident_mod

  implicit none

  real, dimension(:), pointer :: modl(:,:,:), data(:,:,:)
  integer                     :: nz, nhx, nax, nmx, imx, iax, ihx, iz, stat, style, mode
  integer		      :: niter,NAop
  real                        :: z0, hx0, mx0 
  real                        :: dz, dhx, dax, dmx
  real                        :: eps, axmin, axmax, hxmin, hxmax
  real, parameter             :: PI = 3.14159265359
  logical, parameter          :: T = .true. , F = .false.
  logical	              :: adj	
  call initpar()

  call from_param("style", style, 0)
  call from_param("adj", adj, T)
  call from_param("niter", niter, 50)
  call from_param("eps", eps, 1.)
  call from_param("mode",mode,1)

!  if(adj) then
     call from_history("n1", nz ); call from_history("d1", dz ); call from_history("o1", z0 )
     call from_history("n2", nhx); call from_history("d2", dhx); call from_history("o2", hx0)  
     call from_history("n3", nmx); call from_history("d3", dmx); call from_history("o3", mx0)

     call to_history("n1", nz) ; call to_history("d1", dz) ; call to_history("o1", z0)
     call to_history("n2", nhx); call to_history("d2", dhx); call to_history("o2", hx0) 
     call to_history("n3", nmx); call to_history("d3", dmx); call to_history("o3", mx0)

     allocate(modl(nz,nhx,nmx), data(nz,nhx,nmx))

!     mask=1
!     call ident_init(nz, nax, mask) 
      data = 0;modl = 0.
      call sreed("in", data, 4*nz*nhx*nmx)
      axmin=-60.;dax=2.;nax=61
      call rotsog_init(z0, hx0, mx0, dz, dhx, dmx, nz, nhx, nmx, axmin, dax, nax)
      stat = rotsog_oper(adj, .false., modl, data)
      call srite("out", modl, 4*nz*nhx*nmx)

end program rot_sog
