# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
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
    aa = createhelix( nd, center, gap, na)
    n123 = product( nd)
    np = maxval(pch)
    allocate (nh (np))
    nh = size (aa%lag)
    call nallocate( nsaa, nh, pch)
    do ip = 1, np
      nsaa%hlx( ip)%lag = aa%lag
    end do
    call deallocatehelix (aa)
    call nboundn(1, nd, na, nsaa)
  end function
end module
