module killwave_params
use helix_mod
use nhelix_mod
use killwave_utils

use sep

character (len=64),save		:: dip_, A_, ATA_, FILT_, infile_, outfile_
integer, external     		:: srite_window, sreed_window, getch
integer		      		:: verb, verb1, verb2, verb3, verb4
integer				:: stat
integer		  ,save    	:: F, T
real, allocatable ,save     	:: A (:,:),ATA(:,:),FILT(:,:),infile(:), outfile(:)
type( filter)     ,save   	:: hfilt
real		  ,save		:: eps
real              ,save       	:: d1, d2, d3, o1, o2, o3
integer           ,save        	:: n1, n2, n3
real              ,save       	:: dang, oang
integer           ,save       	:: nang, nfilt
logical           ,save	        :: all

integer,allocatable,save	:: ptch(:), n_nfilt(:)
real   ,allocatable,save	:: dips(:)
real		   ,save 	:: dip
integer		   ,save	:: idip
real, parameter    		:: pi=3.1416
real 		   ,save        :: pi_1, pi_2, dip0
type(nfilter)     ,save   	:: n_filt 
type( filter)     ,save   	:: hfilt2,lapfilt
integer				:: iang,ifilt
real				:: lapfilt0
real				:: n_filt0

real				:: m,p
logical				:: destroy
logical				:: rand_in



contains

subroutine params()
	T=.true.	
	F=.false.
	pi_1=-pi/2
	pi_2=+pi/2 ! range of angles

	call from_param('all  ',all ,        .false.)
	call from_param('eps  ',eps ,        0.001)
	call from_param('nang ',nang ,       360 )
	call from_param('dang ',dang , pi/(nang-1))
	call from_param('oang ',oang ,       pi_1)
	call from_param('nfilt',nfilt,         14)
	call from_param('verb' ,verb,           1)
	call from_param('verb1',verb1,          0)
	call from_param('verb2',verb2,          0)
	call from_param('rand_in',rand_in, .false.)

	if (all)then	
		call to_history("n1",    2,A_); call to_history("d1",   1.,A_); call to_history("o1",   1.,A_)
		call to_history("n2",    2,A_); call to_history("d2",   1.,A_); call to_history("o2",   2.,A_)
		call to_history("n3", nang,A_); call to_history("d3", dang,A_); call to_history("o3", oang,A_)
		call to_history("label1", 'filt1',A_); call to_history("label2", 'filt2',A_); call to_history("label3", 'ang',A_); 
		
		call to_history("n1",    3,ATA_); call to_history("d1",    1.,ATA_); call to_history("o1",  1.,ATA_)
		call to_history("n2",    3,ATA_); call to_history("d2",    1.,ATA_); call to_history("o2",  2.,ATA_)
		call to_history("n3", nang,ATA_); call to_history("d3", dang,ATA_); call to_history("o3", oang,ATA_)
		call to_history("label1", 'filt1',ATA_); call to_history("label2", 'filt2',ATA_); call to_history("label3", 'ang',ATA_); 
		
		call to_history("n1",3*nfilt,FILT_); call to_history("d1",   1.,FILT_); call to_history("o1",   1.,FILT_)
		call to_history("n2",      2,FILT_); call to_history("d2",   1.,FILT_); call to_history("o2",   1.,FILT_)
		call to_history("n3",  nang,FILT_); call to_history("d3", dang,FILT_); call to_history("o3", oang,FILT_)
		call to_history("label1", 'coef,lag',FILT_); call to_history("label2", '1-coef,2-lag',FILT_); call to_history("label3", 'ang',FILT_); 
	else
		call to_history("n1", n1, outfile_); call to_history("d1", d1, outfile_); call to_history("o1", o1,outfile_)
		call to_history("n2", n2, outfile_); call to_history("d2", d2, outfile_); call to_history("o2", o2,outfile_)
		call to_history("n3", n3, outfile_); call to_history("d3", d3, outfile_); call to_history("o3", o3,outfile_)
		call to_history("label1", 'nz',outfile_); call to_history("label2", 'nx',outfile_); call to_history("label3", 'ny',outfile_);
	endif 
end subroutine

end module 