! written by nbigen.py
! *** do not edit *** (use nbigen.py instead)
 
subroutine nbi_alloc2_init
 
  use nbi_com
  implicit NONE
 
  !==============================================
  ! internal arrays
 
  if(allocated(ebb_rel_co)) then
     write(nonlin,*) '%nbi_alloc2: ebb_rel_co already allocated; exiting.'
     return
  endif
 
  allocate(ebb_rel_co(mimxbzf,3,mib,mibs)); ebb_rel_co = zero
  allocate(ebb_rel2_co(mimxbzf,3,mib,mibs)); ebb_rel2_co = zero
  allocate(rms_ebb_co(mimxbzf,3,mib,mibs)); rms_ebb_co = zero
  allocate(ebb_rel_cnt(mimxbzf,3,mib,mibs)); ebb_rel_cnt = zero
  allocate(ebb_rel2_cnt(mimxbzf,3,mib,mibs)); ebb_rel2_cnt = zero
  allocate(rms_ebb_cnt(mimxbzf,3,mib,mibs)); rms_ebb_cnt = zero
  allocate(bnb_ien2(mimxbzf,2,mibs)); bnb_ien2 = zero
  allocate(ebb_rel_fn(mimxbzf,3,mib,mibs)); ebb_rel_fn = zero
  allocate(ebb_rel2_fn(mimxbzf,3,mib,mibs)); ebb_rel2_fn = zero
  allocate(rms_ebb_fn(mimxbzf,3,mib,mibs)); rms_ebb_fn = zero
  allocate(bnb_fn(mimxbzf,mibs)); bnb_fn = zero
  allocate(bbnvol(mimxbz,mireact)); bbnvol = zero
  allocate(bdens2(mimxbz,mibs)); bdens2 = zero
  allocate(bdns2p(mimxbz, mibs)); bdns2p = zero
  allocate(be0cx2(mimxbz, mibs)); be0cx2 = zero
  allocate(be20cx2(mimxbz, mibs)); be20cx2 = zero
  allocate(be0x2p(mimxbz, mibs)); be0x2p = zero
  allocate(bmvol(mimxbz)); bmvol = zero
  allocate(bn002(mib, 3, 2, mimxbzf)); bn002 = zero
  allocate(bn0cx2(mimxbz, mibs)); bn0cx2 = zero
  allocate(bn0x2p(mimxbz, mibs)); bn0x2p = zero
  allocate(btiltc(5,mimxbz)); btiltc = zero
  allocate(btntn2(mimxbz,mireact)); btntn2 = zero
  allocate(bv0cx2(mimxbz, mibs)); bv0cx2 = zero
  allocate(bv0x2p(mimxbz, mibs)); bv0x2p = zero
  allocate(bvrhocx2(mimxbz, mibs)); bvrhocx2 = zero
  allocate(bvrhox2p(mimxbz, mibs)); bvrhox2p = zero
  allocate(bvthcx2(mimxbz, mibs)); bvthcx2 = zero
  allocate(bvthx2p(mimxbz, mibs)); bvthx2p = zero
  allocate(bvpllcx2(mimxbz, mibs)); bvpllcx2 = zero
  allocate(bvpllx2p(mimxbz, mibs)); bvpllx2p = zero
  allocate(balpha_gyro(mimxbz, mibs)); balpha_gyro = zero
  allocate(balpha_gyrop(mimxbz, mibs)); balpha_gyrop = zero
  allocate(eb2plp(mimxbz, mibs)); eb2plp = zero
  allocate(eb2ppp(mimxbz, mibs)); eb2ppp = zero
  allocate(eba2pl(mimxbz,mibs)); eba2pl = zero
  allocate(eba2pp(mimxbz,mibs)); eba2pp = zero
  allocate(evol02(mig,mimxbz)); evol02 = zero
  allocate(fbm(mimxbe,mimxba,mimxbzf,mibs)); fbm = zero
  if(nlfbmflr) then
  allocate(fbm_ptcl(mimxbe,mimxba,mimxbzf,mibs,mgyro))
  fbm_ptcl = zero
  endif
  if(ncx0.gt.0) then
  allocate(fbm_cx(mimxbe,mimxba,mimxbz,mibs))
  fbm_cx = zero
  endif
  allocate(hexbbcx0(mib,3,2,mimxbzf,mibs)); hexbbcx0 = zero
  allocate(hexbbxrc(mimxbz,mibs,mibs)); hexbbxrc = zero
  allocate(hexbbxrp(mimxbz,mibs,mibs)); hexbbxrp = zero
  allocate(nfbmpt(mimxbz, mibs)); nfbmpt = 0
  allocate(ovol02(mig, mimxbz)); ovol02 = zero
  allocate(sfusion(mimxbz,mireact)); sfusion = zero
  allocate(sn00i2(mib, 3, mimxbzf, mibs)); sn00i2 = zero
  allocate(sn00x2(mib, 3, mimxbzf, mibs)); sn00x2 = zero
  allocate(snb0i2(mimxbz,mig,mibs)); snb0i2 = zero
  allocate(snbn02(mimxbz,mig,mibs)); snbn02 = zero
  if(levmod_halo.eq.2) then
  allocate(svn3vii_h(mimxbe0,mimxba0,mgyro,mimxbzf,mibs))
  svn3vii_h = zero
  endif
  if(levmod_halo.eq.2) then
  allocate(svn3vii_he(mimxbe0,mimxba0,mgyro,mimxbzf,mibs))
  svn3vii_he = zero
  endif
  if(levmod_halo.eq.2) then
  allocate(svn3vcx_h(mimxbe0,mimxba0,mgyro,mimxbzf,mibs))
  svn3vcx_h = zero
  endif
  if(levmod_halo.eq.2) then
  allocate(svn3vcx_he(mimxbe0,mimxba0,mgyro,mimxbzf,mibs))
  svn3vcx_he = zero
  endif
  allocate(srbn02(mimxbz,mig,mibs)); srbn02 = zero
  allocate(srbn02_dep(mimxbz,mig,mibs)); srbn02_dep = zero
  allocate(vbtor2(mimxbz,mibs)); vbtor2 = zero
  allocate(vbtr2p(mimxbz, mibs)); vbtr2p = zero
  allocate(vcxbn0(mib, 3, 2, mimxbzf)); vcxbn0 = zero
  allocate(voln02(mig, mimxbz)); voln02 = zero
  allocate(walln02(mig, mimxbz)); walln02 = zero
  allocate(xcrb2c(mimxbz,mibs)); xcrb2c = zero
  allocate(xcurb2(mimxbz,mibs)); xcurb2 = zero
  !==============================================
  ! output arrays
 
  ! ... block: fusion .........
  ! ... block: density .........
  ! ... block: deposition .........
  ! ... block: nclass .........
  ! ... block: n0_fast .........
  ! ... block: trap_fraction .........
  ! ... block: erngfi_output .........
  ! ... block: average_energies .........
  ! ... block: excited_states .........
  ! ... block: mc_statistics .........
  ! ... block: rotation .........
  ! ... block: compression .........
  ! ... block: powers .........
  ! ... block: currents .........
  ! ... block: neutral_sources .........
  ! ... block: recapture .........
  ! ... block: neutral_sinks .........
  ! ... block: sources .........
  ! ... block: fokker_planck .........
  ! ... block: radial_current .........
  ! ... block: torques .........
  ! ... block: frantic .........
  ! ... block: hi_z_beams .........
  ! ... block: cptimes .........
  ! ... block: power_balance .........
  ! ... block: momentum_balance .........
  ! ... block: torque_work .........
  ! ... block: particle_balance .........
 
  nbi_init_flag = .TRUE.   ! nbi module is ready.
 
 write(nonlin,*)'% nbi_alloc2_init: nbi_alloc2 done'
end subroutine nbi_alloc2_init
