module helderiv_mod  
        use lapfac_mod
        implicit none
        type( filter),   private  :: aa,aa1 
        contains

        subroutine helderiv_init (n1,n2,bn1,bn2,na,eps,iso )
                integer, intent (in) :: n1, n2, na,bn1,bn2
                real,    intent (in) :: eps
		logical		     ::  iso
		optional	     ::  iso		
	
		if(present (iso))then
			if(iso)then
		                aa = lapfac2_iso( eps, n1, na)
			else
		                aa = lapfac2( eps, n1, na)
			endif
		else
		        aa = lapfac2( eps, n1, na)
		endif

                call helicon_init( aa)
        end subroutine

        function helderiv_lop ( adj, add, pp, qq) result(stat)
        integer            :: stat 
        logical,intent(in) :: adj,add 
        real,dimension(:)  :: pp,qq 
                call adjnull (adj,add,pp,qq )
                call helderiv_lop2(adj,add,pp,qq )
                stat=0
        end function 

        subroutine helderiv_lop2(adj,add,pp,qq)
        logical,intent(in) :: adj,add 
        real, dimension (:)  :: pp 
        real, dimension (:)  :: qq 
        logical              :: opt
        integer stat1
                stat1 = helicon_lop( adj, .false., pp, qq,opt)
        end subroutine

        subroutine  helderiv_close()
                call deallocatehelix( aa)
        end subroutine 
end module 

