subroutine nbi_runid(zrunid)

  ! set runid -- should be a short string, meant for filename prefixes
  !   (length limit set by nbi_com's runid string).

  use nbi_com
  implicit none

  character*(*), intent(in) :: zrunid   ! (short) runid string from driver code

  !----------------------

  integer ilenmax,ilen

  !----------------------

  ilenmax = len(runid)
  ilen = len_trim(zrunid)

  if(ilen.gt.ilenmax) then
     write(nonlin,*) ' '
     write(nonlin,*) ' %nbi_runid warning:  runid string truncated:'
     write(nonlin,*) '  "',zrunid(1:ilen),'" --> "',zrunid(1:ilenmax),'".'
     write(nonlin,*) ' '
     ilen=ilenmax
  endif

  lrunid = ilen
  runid = zrunid(1:ilen)

end subroutine nbi_runid
