module nbi_idhdr

  save

  !  module to store xplasma names of id arrays -- for standalone
  !  restart capability we want to use the names, not the id numbers

  integer :: nbi_numhdr = 0
  integer :: nbi_curhdr = 0

  character*30 :: htest,hdr1 = ' '  
  ! lengths should match nbi_xnames array element

  character*30, dimension(:), allocatable :: nbi_xnames

  logical :: nbi_idhdr_skip = .false.

  contains

    subroutine hdr_expand

      integer isaved
      character*20, dimension(:), allocatable :: hdtmp

      if(nbi_numhdr.gt.0) then

         isaved=nbi_numhdr
         allocate(hdtmp(isaved))
         hdtmp=nbi_xnames
         deallocate(nbi_xnames)

         nbi_numhdr = nbi_numhdr*2
         allocate(nbi_xnames(nbi_numhdr))

         nbi_xnames(1:isaved) = hdtmp
         nbi_xnames(isaved+1:nbi_numhdr) = ' '
         deallocate(hdtmp)

      else

         nbi_numhdr = 20
         allocate(nbi_xnames(nbi_numhdr))
         nbi_xnames = ' '

      endif

    end subroutine hdr_expand

end module nbi_idhdr
