module nbdep_debug
 
  use iso_c_binding, only: fp => c_double
  implicit none
  private :: fp
  save
 
  ! beam deposition calculation -- debugging module
  ! if activated, extra data is recorded during the deposition 
  ! calculation
 
  logical :: nbdep_debug_active = .false.  ! default: not active.

  logical :: nbdep_centerline = .false.    ! .true. for nbline to send
                                           ! beamlet down middle of beam line

  integer :: nbdep_set_beam =0 ! set to control which beamline
  integer :: nbdep_set_ien = 0 ! set to control full/half/third energy

  ! this module is used in conjunction with module nbi
  !  nzcrtk = no. zones    no. of bdy's = no. zones + 1 + #int.vac.segs
  !                        #int.vac.segs = no. of interior vacuum segments
  !                          i.e. vacuum segments btw plasma segments

  integer :: nbdep_nzbdys  ! no. of bdy's (calculated for this module)

  ! coordinate arrays (dim. by no. of bdys):

  real(fp), dimension(:), allocatable :: lb_nbdep,r_nbdep,y_nbdep,phi_nbdep
  real(fp), dimension(:), allocatable :: xi_nbdep,th_nbdep
  real(fp), dimension(:), allocatable :: fbeam_nbdep  ! surviving fraction @bdys

  ! parameter arrays (@zones)

  real(fp), dimension(:), allocatable :: lz_nbdep ! length along beamlet
  real(fp), dimension(:), allocatable :: ebplas_nbdep ! plasma frame energy (ev)
  real(fp), dimension(:), allocatable :: ti_nbdep,te_nbdep ! temperatures (ev)
  real(fp), dimension(:), allocatable :: ne_nbdep ! electron density (cm**-3)
  ! summed over isotopes:
  real(fp), dimension(:), allocatable :: nhs_nbdep ! hydrogenic density (cm**-3)
  real(fp), dimension(:), allocatable :: nhes_nbdep ! helium density (cm**-3)
  real(fp), dimension(:), allocatable :: nlis_nbdep ! lithium density (cm**-3)
  real(fp), dimension(:), allocatable :: nimp_nbdep ! sum impurity density (cm**-3)
  real(fp), dimension(:), allocatable :: nfas_nbdep ! sum fast ion density (cm**-3)
  real(fp), dimension(:), allocatable :: ahs_nbdep  ! hydrogenic <a>
  real(fp), dimension(:), allocatable :: ahes_nbdep ! helium <a>
  real(fp), dimension(:), allocatable :: alis_nbdep ! lithium <a>
  real(fp), dimension(:), allocatable :: aimp_nbdep ! impurity <a>
  real(fp), dimension(:), allocatable :: zimp_nbdep ! impurity <z>

  ! mean free path of beam neutral

  real(fp), dimension(:), allocatable :: lmfp_nbdep

  ! deposition, per zone, total and by processes...

  real(fp), dimension(:), allocatable :: delf_nbdep
  real(fp), dimension(:), allocatable :: delfie_nbdep
  real(fp), dimension(:), allocatable :: delfii_nbdep
  real(fp), dimension(:), allocatable :: delfix_nbdep
  real(fp), dimension(:), allocatable :: delflo_nbdep
  real(fp), dimension(:), allocatable :: delfcxh_nbdep
  real(fp), dimension(:), allocatable :: delfcxhe_nbdep
  real(fp), dimension(:), allocatable :: delfbbii_nbdep
  real(fp), dimension(:), allocatable :: delfbbcx_nbdep

  ! deposition in terms of <sigma*v> stopping rate coeffs

  real(fp), dimension(:), allocatable :: svie_nbdep,svie2_nbdep
  real(fp), dimension(:), allocatable :: svii_nbdep,svii2_nbdep
  real(fp), dimension(:), allocatable :: svix_nbdep,svix2_nbdep
  real(fp), dimension(:), allocatable :: svcxh_nbdep,svcxh2_nbdep
  real(fp), dimension(:), allocatable :: svcxhe_nbdep,svcxhe2_nbdep
  real(fp), dimension(:), allocatable :: excit_nbdep
  integer :: icount_depall
  real(fp), dimension(4) :: znubeam_nbltes
end module nbdep_debug
