subroutine nbi_nbsums
  !
  use nbi_com
  !
  !  impose lower limits (einjmin on injection energy; 0.0 on power)
  !  and call r8_nbsums
  !
  implicit none
  real(fp) :: zminja(mib),zpinj,zminj,zcofrac
  real(fp) :: zminjs(mibs),zcofracs(mibs)
  integer :: ibeama,ib,ib0
  !
  real(fp), parameter :: zzeinj_min = 10000.0_fp  ! 10 kev global minimum
  !
  !  sanity checks first:
  !     -- for each beam, no voltage less than the maximum of a
  !        user specified minimum voltage, or (1/3) the maximum voltage
  !        ever seen on the beam (over time); einjmin can be set once at
  !        the start of a run.
  !     -- for each beam, power .ge. 0
  !
  do ib=1,mib
     einjmin(ib)=max(zzeinj_min,einjmin(ib))
     einjmin(ib)=max(einjmin(ib),einja(ib)/4.0_fp)
  end do

  do ib=1,mib
     einja(ib)=max(einja(ib),einjmin(ib))
     pinja(ib)=max(zero,pinja(ib))
  end do

  !  check trace beams...

  do ib=1,mib
     if(ntrace(ib).ne.0) then
        ib0=abs(ntrace(ib))
        einja(ib)=einja(ib0)
        if(xzbeama(ib).eq.xzbeama(ib0)) then
           ffulla(ib)=ffulla(ib0)
           fhalfa(ib)=fhalfa(ib0)
        else
           ffulla(ib)=one
           fhalfa(ib)=zero
        end if
     end if
  end do
  !
  !-----------------------------------------------
  !
  call r8_nbsums(pinja,einja,ffulla,fhalfa, &
       ibeama,xninja,zminja, &
       zpinj,einj,zminj,xninj,zcofrac, &
       pinjs,einjs,zminjs,xninjs,zcofracs)

  return
end subroutine nbi_nbsums
