      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
C
      DOUBLE PRECISION DSTAK(500)
      INTEGER ISTAK(1000)
C
      EQUIVALENCE (DSTAK(1),ISTAK(1))
      EQUIVALENCE (ISTAK(2),LNOW)
C
      LNOWO = LNOW
      CALL ISTKRL(1)
C
      ITYPE = ISTAK(LNOWO-1)
C
C/6S
C     IF (ITYPE.LE.0.OR.ITYPE.GE.6) CALL SETERR
C    1   (35HISTKMD - ISTAK(LNOWO-1) OVERWRITTEN,35,1,2)
C/7S
      IF (ITYPE.LE.0.OR.ITYPE.GE.6) CALL SETERR
     1   ('ISTKMD - ISTAK(LNOWO-1) OVERWRITTEN',35,1,2)
C/
C
      ISTKMD = ISTKGT(NITEMS,ITYPE)
C
      RETURN
C
      END
