      integer function istkqu (itype)
c
c returns the number of items of type itype that remain
c to be allocated in one request.
c
c error states -
c
c   1 - one or more of first eight words in stack overwritten
c   2 - itype .le. 0 .or. itype .ge. 7
c
      common /cstak / dstak
c
      double precision dstak(500)
      integer istak(1000)
      integer isize(6)
      logical init
c
      equivalence (dstak(1), istak(1))
      equivalence (istak(1), lout)
      equivalence (istak(2), lnow)
      equivalence (istak(3), lused)
      equivalence (istak(4), lbnd)
      equivalence (istak(5), lmax)
      equivalence (istak(6), lalc)
      equivalence (istak(7), lneed)
      equivalence (istak(8), lbook)
      equivalence (istak(11), isize(1))
c
      data init / .true. /
c
      if (init) call i0tk00 (init, 500, 4)
c
      if (lnow.lt.lbook .or. lnow.gt.lused .or. lused.gt.lmax .or. lnow
     1  .ge.lbnd .or. lout.gt.lalc) call seterr (
     2  61histkgt  one or more of first eight words in stack overwritten
     3  , 61, 1, 2)
c
      if (itype.le.0 .or. itype.ge.7) call
     1  seterr (33histkqu - itype.le.0.or.itype.ge.7, 33, 2, 2)
c
      istkqu =
     1  max0 (((lbnd-3)*isize(2))/isize(itype)-(lnow*isize(2)-1)/isize(
     2  itype)-1,0)
c
      return
c
      end