subroutine nbdrive_mapfast(i,ii,zflbl)

  use nbdrive_common
  implicit NONE

  !  fast ion index mapping 
  !    nbdrive fast ion index  =>  NUBEAM fast ion index
  !
  !  NUBEAM fast ion indexing is not explicitly controlled by nbdrive;
  !  rather, it is derived inside NUBEAM from union of the neutral beam
  !  species and the fusion product species specified by NUBEAM input
  !  data structures.
  !
  !  nbdrive uses its namelist to construct its own fast ion species
  !  list, but might be doing so in a way different than what NUBEAM
  !  does.  Therefore, a mapping of index species should be provided.
  !  This routine makes it available.
  !
  !-------------------------------------

  integer,intent(in) :: i  ! nbdrive fast ion specie index
  integer,intent(out) :: ii ! NUBEAM fast ion specie index
  character*(*), intent(out) :: zflbl  ! NUBEAM fast ion specie label

  !-------------------------------------

  integer iz,ia,itype,inum,idum,index_nbfi

  character*20, dimension(:), allocatable :: zflbls

  !-------------------------------------
  !  get known labels

  call nbfi_numfast(inum) ! NUBEAM call-- no. of fast species in NUBEAM

  allocate(zflbls(inum))
  call nbfi_lbl(zflbls,inum,idum) ! NUBEAM call-- the set of fast specie labels

  !-------------------------------------
  !  convert Z & A to integer form
  !
  iz = xzbeams(i)+0.1
  ia = abeams(i)+0.1

  !  set a "type code"
  !  it is possible for a run to have He4 beams and He4 (alpha) fusion 
  !  products, so, Z & A alone are not sufficient to make the determination.

  if(nlfprod(i)) then
     itype=3     !  Monte Carlo fusion product specie
  else
     itype=1     !  Monte Carlo beam specie
  endif

  ! other possibilities: fast species not computed by Monte Carlo
  !  code; species for which NUBEAM does deposition but not slowing
  !  down.  These do not occur in nbdrive, at present...
  
  ! see: NUBEAM subroutine: nubeam/nbfi_lbl.f90
  !  integer function index_nbfi(...)

  ii = index_nbfi(iz,ia,itype)   ! NUBEAM integer function call *****
  zflbl = zflbls(ii)             ! and the corresponding label...

  !-------------------------------------
  deallocate(zflbls)

end subroutine nbdrive_mapfast
