!--------------------------------------------------------------------
!
!  rpltq.   jxb momentum/power due to ripple loss
!
subroutine rpltq
  !
  !  output: tqrpls
  !          tqrpl
  !
  !--------------------------------------------------------------------
  !
  use nbi_com
  !
  !--------------------------------------------------------------------
  !
  !============
  implicit none
  integer :: ingc,j
  !============
  real(fp) :: ze,zfac,zpsi,zpsinew
  !============
  if(xion.ge.1.0_fp) return ! don't do if orbit already beyond edge
  ze=xzbeami*zel ! charge
  zfac=wght*ze/zc              ! e/c   x particle weight
  !
  ingc=ngc-lcm1           ! index correction
  zpsi=plflxi(ingc)+(plflxi(ingc+1)-plflxi(ingc))* & ! psi 
       (xion-xi(ngc,1))/(xi(ngc+1,1)-xi(ngc,1)) ! at ripple loss point
  !
  do  j=ngc,ledge
     zpsinew=plflxi(j-lcm1+1)
     tqrpls(j,lsbeam)=tqrpls(j,lsbeam)-zfac*(zpsinew-zpsi) !e/c dpsi
     zpsi=zpsinew                 ! and do next zone...
  end do
  !
  return
end subroutine rpltq
