subroutine randcx(icx,jbe,jba,ngc_2,xzid)
!randomly choosen spatial index, pitch angle and energy indices 

  use iso_c_binding, only: fp => c_double
  use nbi_fbm_random
  implicit none
  integer, intent(in) :: icx !sample number
  integer, intent(out) :: ngc_2,jba, jbe ! spatial index, pitch angle and 
  real(fp), intent(out) :: xzid ! zone id

  jbe=jb_e(icx)
  jba=jb_a(icx)
  ngc_2=n_gc2(icx)
  xzid=xz_id(icx)

end subroutine randcx
