      integer function istkmd (nitems)
c
c changes the length of the frame at the top of the stack
c to nitems.
c
c error states -
c
c   1 - lnow overwritten
c   2 - istak(lnowo-1) overwritten
c
      common /cstak / dstak
      external istkgt
c
      double precision dstak(500)
      integer istak(1000)
      logical init
c
      equivalence (dstak(1), istak(1))
      equivalence (istak(2), lnow)
c
      data init / .true. /
c
      if (init) call i0tk00 (init, 500, 4)
c
      lnowo = lnow
      call istkrl (1)
c
      itype = istak(lnowo-1)
c
      if (itype.le.0 .or. itype.ge.7) call
     1  seterr (35histkmd - istak(lnowo-1) overwritten, 35, 1, 2)
c
      istkmd = istkgt (nitems, itype)
c
      return
c
      end
