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,maskval
integer, 		public, 	save		:: nah,nrad,nts
real, 		public, 	save		:: dah,oah,drad,orad,dts,ots
logical, 		public, 	save		:: test,proc,tin,prc,initdip
logical, 		public, 	save		:: plunge,fold,initcurv,applw

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("plunge",plunge,.false.)
  call from_param("fold",fold,.false.)
  if (plunge) then
     call from_param("initdip",initdip,.false.)
     call from_param("dax",dax,1.)
     call from_param("oax",oax,-20.)
     nax=2*(-oax)/dax+1
     call from_param("dah",dah,1.)
     call from_param("oah",oah,-40.)
     nah=2*(-oah)/dah+1
     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
  else if (fold) then
     call from_param("applw",applw,.false.)
     call from_param("initcurv",initcurv,.false.)
     call from_param("drad",drad,10.)
     call from_param("orad",orad,-5000.)
     nrad=2*(-orad)/drad+1
     call from_param("dts",dts,1.)
     call from_param("ots",ots,-30.)
     nts=2*(-ots)/dts+1
     write(0,*) "==============================================="
     write(0,12) " nrad= ",nrad,"    drad= ",drad,"   orad= ",orad
     write(0,2) " nts = ",nts ,"    dts = ",dts ,"   ots = ",ots
     if (niter==9999) then
        write(0,*) "==============================================="
     else
        write(0,3) " niter = ",niter," eps = ",eps
        write(0,*) "==============================================="
     end if
  end if
  call from_param("nodes",nodes,9999)
  call from_param("niter",niter,9999)
  call from_param("eps",eps,1.)
  call from_param("test",test,.false.)
  call from_param("proc",proc,.false.)
  call from_param("tiny",tin,.false.)
  call from_param("prc",prc,.false.)
  if (exist_file("mask")) then
     call from_param("maskval",maskval,2000.)
  end if

2 format(a7,i5,2(a10,f8.3))
3 format(a9,i5,a7,f8.3)
12 format(a7,i5,a10,f8.3,a10,f8.1)

!! set up output file 
!  if (test.or.rot) then
!     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("n2",1);call to_history("d2",1.);call to_history("o2",0.)
!     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
     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",nah);call to_history("d2",dah);call to_history("o2",oah)
     call to_history("n2",1.);call to_history("d2",1.);call to_history("o2",0.)
     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 subroutine

end module
