subroutine lost_orbit_num(suffix,indep)

  ! look for xplasma data on lost orbit data 

  ! this routine does not depend on nbi_com -- just xplasma.  so, it can be
  ! called safely by a client code, when the nubeam calculation is performed
  ! as a remote service.

  use nbi_com, only: nonlin
  use xplasma_obj_instance
  implicit none

  !-------------------------------------
  ! passed:

  character*(*), intent(in) :: suffix   ! ' '

  integer, intent(out) :: indep         ! number of lost orbit
  !  (0,0) are returned if no data is found.
  !-------------------------------------
  ! local:

  integer, dimension(:), pointer :: idata
  integer :: id,ierr
  character*32 zobj_name
  integer :: ihdr,iadr,ii
  !-------------------------------------

  indep = 0

  zobj_name = 'lost_orbit' ! name of xplasma black box
  ! containing deposition data, if any exists

  call xplasma_blkbxid(s,zobj_name,id)

  if(id.eq.0) return

  !-------------------------
  ! data does exist

  call xplasma_blackbox_retrieve(s,id,ierr, ia_ptr=idata)
  if(ierr.ne.0) then
     write(nonlin,*) ' ?lost_orbit_num: unexpected error, blackbox "', &
          trim(zobj_name),'":'
     call xplasma_error(s,ierr,nonlin)
     return
  endif
  ihdr = idata(1)
  indep = idata(2)

  nullify(idata)

end subroutine lost_orbit_num
