subroutine tr_getnl_logvec(zname,logvec,maxval,istat)
!
  use tr_getnl
  implicit NONE
!
!  get a vector of logicals corresponding to namelist name "zname"
!
  character*(*), intent(in) :: zname       ! namelist name
  integer, intent(in) :: maxval            ! dimension of results vector
  logical, dimension(maxval), intent(out) :: logvec  ! results vector
  integer, intent(out) :: istat
!
!  on output:
!
! normal returns:
!  istat = 0 -- no values found
!  istat = N, 1.le.N.le.maxval -- N values found, stored in logvec(1:N)
!
! error returns:
!  istat = -1 -- error (e.g. namelist was never read)
!  istat = -N, N.gt.maxval -- N values were found, logvec(1:maxval) set
!          to the first maxval of them, there are too many values to
!          return them all
!
!-------------------------------------
!
  integer i,ierr,iersum,ils,str_length
!
  character(32), dimension(maxval) :: svalues
  integer nvalues
!
  integer lunzer,lt
!-------------------------------------
!
  call tr_getnl_strvals(zname,svalues,maxval,nvalues,ierr)
!
  if(ierr.ne.0) then
     istat=-1
     return
  endif
!
  if(nvalues.eq.0) then
     istat=0
     return
  endif
!
  iersum=0
  do i=1,min(nvalues,maxval)
     read(svalues(i),'(L32)',iostat=ierr) logvec(i)
     if(ierr.ne.0) then
        lt=lunzer(0)
        write(lt,*) '%tr_getnl_logvec: logical decode error:'
        ils=str_length(zname)
        write(lt,*) ' namelist item:  ',zname(1:ils),'(',i,')=',svalues(i)
        iersum=iersum+ierr
     endif
  enddo
!
  if(iersum.gt.0) then
     istat=-1
     return
  endif
!
  if(nvalues.gt.maxval) then
     istat=-nvalues
  else
     istat=nvalues
  endif
!
  return
  end
