subroutine radcur(zxiold,zxinew,zwght,zcur)
  !
  !  dmc 27 sep 1994:  add to radial current profile (mc sum)
  !
  use nbi_com
  !
  !============
  implicit none
  integer :: izold,iznew,izmin,izmax,izs
  !============
  real(fp) :: zsign,zswght
  !============
  real(fp) :: zxiold   ! starting xi location
  real(fp) :: zxinew   ! ending xi location
  real(fp) :: zwght    ! mc ion weight
  real(fp) :: zcur(mj,mibs)   ! the current profile to add
  !
  !
  !  this is a general purpose routine.  the radial current profile sum
  !  is passed, so this routine can be used for summing various radial
  !  currents.
  !
  !  method:  add increment to each numerical surface crossed.
  !  note:  there may be no surfaces; this ion may be moving in or out.
  !
  !  common input:  xzbeami = the charge carried by the mc ion
  !                 lsbeam  = the current specie of mc ion
  !----------------------------------------------
  !  zone indices:
  !
  if((zxiold.ge.lep1).or.(nzones*zxiold.ge.lep1-lcentr)) then
     izold=lep1
  else
     izold=lcentr+int(nzones*zxiold)
  end if
  if((zxinew.ge.lep1).or.(nzones*zxinew.ge.lep1-lcentr)) then
     iznew=lep1
  else
     iznew=lcentr+int(nzones*zxinew)
  end if
  !
  !  no current if zone indices unchanged
  !
  if(izold.eq.iznew) return
  !
  !  direction
  !
  if(iznew.gt.izold) then
     zsign=1.0_fp
  else
     zsign=-1.0_fp
  end if
  zswght=zsign*zwght
  !
  !  do the sum
  !
  izmin=min(izold,iznew)
  izmax=max(izold,iznew)
  !
  !  loop over crossed surfaces
  !
  do izs=izmin+1,izmax
     zcur(izs,lsbeam)=zcur(izs,lsbeam)+xzbeami*zswght
  end do
  !
  return
end subroutine radcur

