anchor.diff:        USE MOD_VARIABLES
         IMPLICIT NONE
         CHARACTER STR*(*)
  -      INTEGER I,J,NS,NQ,S(3,MTOK),Q(3,MTOK),IVAL(4)
  +      INTEGER I,J,NS,NQ,IVAL(4)
  +      TYPE(TYP_TOKEN) :: S(MTOK),Q(MTOK)
         DOUBLE PRECISION FVAL(2)
         CHARACTER*128 SVAL
  -      EQUIVALENCE (FVAL,IVAL)
  +      EQUIVALENCE(FVAL,IVAL)
   !
         FVAL = 0D0
         NS   = 0
  
positive.code: !
  !     Begin building POSTFIX queue from INFIX.
        DO 1001 I=1,NTOK
        SELECT CASE(100*(TOKLST(1,I)/100))
  !
        CASE (IDEN,NUMB)
          NQ = NQ + 1
          Q(1,NQ) = TOKLST(1,I)
          Q(2,NQ) = TOKLST(2,I)
          Q(3,NQ) = TOKLST(3,I)
  !
        CASE (OPER)
          IF (NS.EQ.0) THEN
            NS = NS + 1
            S(1,NS) = TOKLST(1,I)      ! PUSH OPERATOR ONTO STACK
            S(2,NS) = TOKLST(2,I)
            S(3,NS) = TOKLST(3,I)
          ELSE
  !         Note that if the stack holds an open parenthesis, this check
  !         will always result in pushing the operator on the stack
  !         because the parenthesis states are 500 while operator states
  !         are 400.
            IF (S(1,NS).LE.TOKLST(1,I)) THEN
              NQ = NQ + 1
              Q(1,NQ) = S(1,NS)  ! POP OPERATOR FROM STACK INTO QUEUE
              Q(2,NQ) = S(2,NS)
              Q(3,NQ) = S(3,NS)
              S(1,NS) = TOKLST(1,I)      ! PUSH OPERATOR ONTO STACK
              S(2,NS) = TOKLST(2,I)
              S(3,NS) = TOKLST(3,I)
            ELSE
              NS = NS + 1
              S(1,NS) = TOKLST(1,I)      ! PUSH OPERATOR ONTO STACK
              S(2,NS) = TOKLST(2,I)
              S(3,NS) = TOKLST(3,I)
            ENDIF
          END IF
  !
        CASE (GRP)
          SELECT CASE (TOKLST(1,I))
          CASE (OPAR)
  !         If an identifier preceded this open parenthesis, then it
  !         is a function identifier.
            IF (I.GT.1) THEN
              IF (TOKLST(1,I-1).EQ.IDEN) THEN
                Q(1,NQ) = FUNC
              ENDIF
            END IF
            NS = NS + 1
            S(1,NS) = TOKLST(1,I)      ! PUSH OPEN PARENTHESIS ONTO STACK
            S(2,NS) = TOKLST(2,I)
            S(3,NS) = TOKLST(3,I)
          CASE (CPAR)
            DO 1021 WHILE (NS.GT.0)
            IF (S(1,NS).EQ.OPAR) THEN
              NS = NS - 1
              EXIT
            ELSE 
              NQ = NQ + 1
              Q(1,NQ) = S(1,NS)  ! POP OPERATOR FROM STACK INTO QUEUE
              Q(2,NQ) = S(2,NS)
              Q(3,NQ) = S(3,NS)
              NS = NS - 1
            END IF
   1021     CONTINUE
          END SELECT
  !
        CASE DEFAULT
          WRITE(0,9001) STR(TOKLST(2,I):TOKLST(3,I))
          GOTO 8999
        END SELECT
   1001 CONTINUE
        DO 2001 WHILE(NS.GT.0)
        NQ = NQ + 1
        Q(1,NQ) = S(1,NS)  ! POP OPERATOR FROM STACK INTO QUEUE
        Q(2,NQ) = S(2,NS)
        Q(3,NQ) = S(3,NS)
        NS = NS - 1
   2001 CONTINUE
  !
  !     Evaluate POSTFIX Queue
        DO 3001 I=1,NQ
        WRITE(6,9021) (Q(J,I),J=1,3),STR(Q(2,I):Q(3,I))
  !     WRITE(6,9031) NS
        SELECT CASE(100*(Q(1,I)/100))
  !
        CASE (IDEN)
          CALL GETVAL(STR(Q(2,I):Q(3,I)),SVAL)
          IF (LEN_TRIM(SVAL).EQ.0) THEN
            WRITE(0,9041)STR(Q(2,I):Q(3,I))
            GOTO 8999
          END IF
          READ(SVAL,*)FVAL(1)
          NS = NS + 1
          S(1,NS) = Q(1,I)
          S(2,NS) = IVAL(1)
          S(3,NS) = IVAL(2)
  !
        CASE(NUMB)
          READ(STR(Q(2,I):Q(3,I)),*)FVAL(1)
          NS = NS + 1
          S(1,NS) = Q(1,I)
          S(2,NS) = IVAL(1)
          S(3,NS) = IVAL(2)
  !
        CASE(OPER)
          IVAL(3) = S(2,NS)
          IVAL(4) = S(3,NS)
          NS = NS -1
          IVAL(1) = S(2,NS)
          IVAL(2) = S(3,NS)
          SELECT CASE (Q(1,I))
          CASE (POW)
            FVAL(1) = FVAL(1) ** FVAL(2)
          CASE (MUL)
  
negative.code: !     PERFORM ACTION
        SELECT CASE (ACTN)
        CASE(ERR)
          CALL SCNERR(INP,I,CUR%STATE)
          GOTO 8999
        CASE(NEW)
          CUR%STRT = I
          CUR%ENDT = CUR%STRT
        CASE(PUSH)
          CUR%ENDT = CUR%ENDT + 1
        CASE(FLSH)
          IF (CUR%STATE.NE.WHIT) THEN
            NTOK = NTOK + 1
            TOKLST(NTOK) = CUR
            WRITE(6,9021)CUR%STATE,CUR%STRT,CUR%ENDT, &
                         REPEAT(' ',CUR%STRT-1)//INP(CUR%STRT:CUR%ENDT)
          END IF
          CUR%STRT = I
          CUR%ENDT = CUR%STRT
        END SELECT
   1001 CUR%STATE = NXTST
  !
        IF (CUR%ENDT.GE.CUR%STRT.AND.CUR%STATE.NE.WHIT) THEN
          NTOK = NTOK + 1
          TOKLST(NTOK) = CUR
          WRITE(6,9021)CUR%STATE,CUR%STRT,CUR%ENDT, &
                         REPEAT(' ',CUR%STRT-1)//INP(CUR%STRT:CUR%ENDT)
        END IF
  !
   8999 RETURN
  