module createnhelixmod  
! Create non-stationary helix filter lags and mis
  use createhelixmod
  use nhelix
  use nbound
  implicit none
  contains
  function createnhelix( nd, center, gap, na, pch) result (nsaa)
    type( nfilter)                     :: nsaa   ! needed by nhelicon
    integer, dimension(:), intent(in)  :: nd, na 
    ! data and filter axes
    integer, dimension(:), intent(in)  :: center 
    ! normally (na1/2,na2/2,...,1)
    integer, dimension(:), intent(in)  :: gap    
    ! normally ( 0,   0,  0,...,0)
    integer, dimension(:), intent(in)  :: pch	 ! (prod(nd)) patching
    type( filter)                      :: aa
    integer                            :: n123, np, ip
    integer, dimension(:), allocatable :: nh
    write(0,*) "death s"
    aa = createhelix( nd, center, gap, na)
    write(0,*) "death t"
    n123 = product( nd)
    np = maxval(pch)
    write(0,*) "death u"
    allocate (nh (np))
    nh = size (aa%lag)
    write(0,*) "death v"
    call nallocate( nsaa, nh, pch)
    write(0,*) "death w"
    do ip = 1, np
      nsaa%hlx( ip)%lag = aa%lag
    end do 
    write(0,*) "death x"
    call deallocatehelix (aa)
    write(0,*) "death y"
    call nboundn(1, nd, na, nsaa) 
    write(0,*) "death z"
  end function 
end module 
