# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"

module nhelix
! Define nonstationary filter type
  use helix
implicit none
  type nfilter
! nd is data length.
    logical, dimension(:), pointer :: mis
    ! (nd) boundary conditions
    integer, dimension(:), pointer :: pch ! (nd) patches
    type( filter), dimension(:), pointer :: hlx ! (np) filters
  end type
  contains
  subroutine nallocate( aa, nh, pch)
! allocate a filter
    type( nfilter) :: aa
    integer, dimension(:), intent( in) :: nh, pch
    integer :: ip, np, nd
    np = size( nh)
    allocate( aa%hlx( np))
    do ip = 1, np
      call allocatehelix( aa%hlx( ip), nh( ip))
    end do
    nd = size( pch)
    allocate( aa%pch( nd))
    aa%pch = pch
    nullify( aa%mis) ! set null pointer for mis.
  end subroutine
  subroutine ndeallocate( aa)
! destroy a filter
    type( nfilter) :: aa
    integer :: ip
    do ip = 1, size( aa%hlx)
      call deallocatehelix( aa%hlx( ip))
    end do
    deallocate( aa%hlx, aa%pch)
    if ( associated( aa%mis)) then
! if logicals were allocated
      deallocate( aa%mis) ! free them
    end if
  end subroutine
end module
