module OW_sltpar

use sep
use OW_type

implicit none

type (axis) ,public, save					:: xm, z, sh
type (mod_grid) ,public, save					:: sog
integer, public, save					:: nx,nodes,niter
integer, public, save					:: nax
real, public, save						:: dax,oax,eps
integer, public, save					:: nah,nz !nzmin,nzmax,nz
real, public, save						:: dah,oah,zmin,zmax
logical, public, save					:: teste,rot,rec,upshft

contains

subroutine owsltpar()

  call from_history("n1",sog%z%n);  call from_history("d1",sog%z%d); call from_history("o1",sog%z%o)
  call from_history("n2",sog%sh%n);call from_history("d2",sog%sh%d);call from_history("o2",sog%sh%o)
  call from_history("n3",sog%xm%n);call from_history("d3",sog%xm%d);call from_history("o3",sog%xm%o)  

  write(0,*) "============================================"
  write(0,1) " n1 = ",sog%z%n,"    d1 = ",sog%z%d,"   o1 = ",sog%z%o
  write(0,1) " n2 = ",sog%sh%n,"    d2 = ",sog%sh%d,"   o2 = ",sog%sh%o
  write(0,1) " n3 = ",sog%xm%n,"    d3 = ",sog%xm%d,"   o3 = ",sog%xm%o
  write(0,*) "============================================"
1 format(a6,i5,2(a9,f8.3))
!!  get parameters
  call from_param("nx",nx,7)
  call from_param("dax",dax,1.)
  call from_param("oax",oax,-20.)
  call from_param("nax",nax,int(2*(-oax)/dax+1))
  call from_param("dah",dah,1.)
  call from_param("oah",oah,-40.)
  call from_param("nah",nah,int(2*(-oah)/dah+1))
  call from_param("zmin",zmin,0.)
  call from_param("zmax",zmax,(sog%z%n-1)*sog%z%d+sog%z%o)
!  nzmin=zmin/sog%z%d+1
!  nzmax=zmax/sog%z%d+1
  nz=int((zmax-zmin)/sog%z%d)+1
  call from_param("nodes",nodes,9999)
  call from_param("niter",niter,9999)
  call from_param("eps",eps,1.)
  call from_param("teste",teste,.false.)
  call from_param("rot",rot,.false.)
  call from_param("rec",rec,.false.)
  call from_param("upshft",upshft,.false.)

  write(0,*) "==============================================="
  write(0,2) " nax = ",nax,"    dax = ",dax,"   oax = ",oax
  write(0,2) " nah = ",nah,"    dah = ",dah,"   oah = ",oah
  if (niter==9999) then
     write(0,*) "==============================================="
  else
     write(0,3) " niter = ",niter," eps = ",eps
     write(0,*) "==============================================="
  end if
  write(0,*) "teste = ",teste,"rot = ",rot," rec = ",rec," upshft = ",upshft 
2 format(a7,i5,2(a10,f8.3))
3 format(a9,i5,a7,f8.3)

!! set up output file 
  if (teste) then
     write(0,*) "teste = ",teste," upshft = ",upshft
     call to_history("n1",sog%z%n);call to_history("d1",sog%z%d);call to_history("o1",sog%z%o)
     call to_history("n2",sog%sh%n);call to_history("d2",sog%sh%d);call to_history("o2",sog%sh%o)
     call to_history("n3",sog%xm%n);call to_history("d3",sog%xm%d);call to_history("o3",sog%xm%o)  
     call to_history("label1","z");call to_history("label2","ah")
     call to_history("label3","x")
     call to_history("esize",4)
  else if (rot) then
     write(0,*) "rot = ",rot," upshft = ",upshft
     call to_history("n1",sog%z%n);call to_history("d1",sog%z%d);call to_history("o1",zmin)
     call to_history("n2",sog%sh%n);call to_history("d2",sog%sh%d);call to_history("o2",sog%sh%o)
     call to_history("n3",sog%xm%n);call to_history("d3",sog%xm%d);call to_history("o3",sog%xm%o)  
     call to_history("label1","z");call to_history("label2","ah")
     call to_history("label3","x")
     call to_history("esize",4)
  else
     if (upshft) then
        write(0,*) "teste = ",teste,"rot = ",rot," upshft = ",upshft 
!        write(0,*) nz,sog%sh%n,nah,nax,sog%xm%n
        call to_history("n1",nz);call to_history("d1",sog%z%d);call to_history("o1",zmin)
        call to_history("n2",sog%sh%n);call to_history("d2",sog%sh%d);call to_history("o2",sog%sh%o)
        call to_history("n3",nah);call to_history("d3",dah);call to_history("o3",oah)
        call to_history("n4",nax);call to_history("d4",dax);call to_history("o4",oax)
        call to_history("n5",sog%xm%n);call to_history("d5",sog%xm%d);call to_history("o5",sog%xm%o)  
        call to_history("n6",1);call to_history("d6",1.);call to_history("o6",0.)  
        call to_history("label1","z");call to_history("label2","h");call to_history("label3","ah")
        call to_history("label4","ax");call to_history("label5","x")
        call to_history("esize",4)
     else
        write(0,*) "teste = ",teste,"rot = ",rot," upshft = ",upshft 
!        write(0,*) nz,nah,nax,sog%xm%n
        call to_history("n1",nz);call to_history("d1",sog%z%d);call to_history("o1",zmin)
        call to_history("n2",nah);call to_history("d2",dah);call to_history("o2",oah)
        call to_history("n3",nax);call to_history("d3",dax);call to_history("o3",oax)
        call to_history("n4",sog%xm%n);call to_history("d4",sog%xm%d);call to_history("o4",sog%xm%o)  
        call to_history("label1","z");call to_history("label2","ah")
        call to_history("label3","ax");call to_history("label4","x")
        call to_history("esize",4)
     end if
  end if

end subroutine

end module
