!-----------------------------------------------------------------------
! fustaus -- compute tau slowing down and tau p.a. scattering profiles
!
!  the fusion product is taken as launched from the plasma frame for
!  this estimate
!
!  dmc oct 1992 -- code moved here from depfus -- now called on every
!  mc code timestep, not just when the code actually to deposit new
!  mc fusion product ions.
!
subroutine fustaus
  !
  use nbi_com
  !
  !  set .true. for reactions that produce a desired fusion product:
  !============
  implicit none
  integer :: ioffn,indf,indn,ireact,iz,j
  !============
  real(fp) :: znmax,zn,ze,zvrel,zcf,ztausl,zef,ztaupa
  !============
  logical ilreact(mireact)
  !
  !  initial energy (ev) of fusion product so produced:
  real(fp) :: zereact(mireact)
  !
  !
  !-----------------------------------------------------------------------
  !
  !  only do this calculation on the first call to depsub
  !
  call fuslis(lsbeam,ilreact,zereact)
  !
  !  indexing as in dep -- but only one profile of each type is
  !  evaluated, not two (co,ctr) per beam energy (full, half, third)
  !  as is done in dep
  !
  ioffn=6
  indf=1
  indn=indf+ioffn
  !
  !  choose the energy from the "dominant" fusion reaction
  !
  znmax=-epsinv
  !
  do ireact=1,nreact
     if(.not.ilreact(ireact)) cycle
     !
     !  total source from this reaction
     !
     zn=0.0_fp
     do iz=1,nfbzns
        zn=zn+sfusion(iz,ireact)

     end do
     !
     if(zn.gt.znmax) then
        znmax=zn
        ze=zereact(ireact)
     end if
     !
  end do
  !
  zvrel=sqrt(ze/v2toev)  ! taken in the plasma frame
  !
  !  the cf, ef profiles are evaluated in subroutine fokker
  !
  do j=lcentr,ledge
     !
     zcf=0.5_fp*(cfa(j,lsbeam,1)+cfa(j,lsbeam,2))
     ztausl=log((zvrel**3+vcrit3(j,lsbeam))/ &
          (vmin3(j,lsbeam)+vcrit3(j,lsbeam)))/(3.0_fp*zcf)
     !
     zef=0.5_fp*(efa(j,lsbeam,1)+efa(j,lsbeam,2))
     ztaupa=zvrel**3/(2.0_fp*zef)
     !
     taubsl_tmp(j,indf,lsbeam)=ztausl
     taubsl_tmp(j,indn,lsbeam)=1.0_fp
     !
     taubpa_tmp(j,indf,lsbeam)=ztaupa
     taubpa_tmp(j,indn,lsbeam)=1.0_fp
     !

  end do
  !
  !----------------------------------------
  !
  return
end subroutine fustaus
