      SUBROUTINE MAIN
      INTEGER GETARG, OPEN
      INTEGER I, FD
      LOGICAL*1 BUF(36)
      LOGICAL*1 ST001Z(25)
      DATA ST001Z(1)/117/,ST001Z(2)/115/,ST001Z(3)/97/,ST001Z(4)/103/,ST
     *001Z(5)/101/,ST001Z(6)/58/,ST001Z(7)/32/,ST001Z(8)/114/,ST001Z(9)/
     *97/,ST001Z(10)/116/,ST001Z(11)/112/,ST001Z(12)/50/,ST001Z(13)/32/,
     *ST001Z(14)/91/,ST001Z(15)/102/,ST001Z(16)/105/,ST001Z(17)/108/,ST0
     *01Z(18)/101/,ST001Z(19)/115/,ST001Z(20)/93/,ST001Z(21)/32/,ST001Z(
     *22)/46/,ST001Z(23)/46/,ST001Z(24)/46/,ST001Z(25)/0/
      CALL QUERY (ST001Z)
      I=1
23000 IF (.NOT.(GETARG(I, BUF, 36) .NE. -1))GOTO 23002
      IF (.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0))GOTO 23003
      FD = 1
      GOTO 23004
23003 CONTINUE
      FD = OPEN(BUF, 1)
23004 CONTINUE
      IF (.NOT.(FD .EQ. -3))GOTO 23005
      CALL CANT (BUF)
23005 CONTINUE
      CALL FSORT (FD, 2)
      IF (.NOT.(FD .NE. 1))GOTO 23007
      CALL CLOSE (FD)
23007 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(I .EQ. 1))GOTO 23009
      CALL FSORT (1, 2)
23009 CONTINUE
      RETURN
      END
      SUBROUTINE FSORT(IFD,OFD)
      INTEGER IFD,OFD
      INTEGER LEN, I
      INTEGER KIND
      LOGICAL*1 LINE(402)
      INTEGER GETLIN, LOOKUP, MKTABL
      INTEGER GCODE
      INTEGER MEM(500)
      LOGICAL*1 CMEM(1000)
      LOGICAL*1 BUF
      INTEGER PTR
      INTEGER TYPE
      INTEGER NEXTP
      INTEGER STB
      COMMON /CDSMEM/ MEM
      COMMON /RATP2C/ BUF(20000),PTR(1000),TYPE(1000), NEXTP, STB
      EQUIVALENCE (CMEM(1),MEM(1))
      CALL DSINIT(500)
      NEXTP = 1
      PTR(NEXTP) = 1
      KIND = 12
      STB = MKTABL (1)
      CALL INITFS (STB)
      LEN=GETLIN(LINE,IFD)
23011 IF (.NOT.(LEN.NE.-1))GOTO 23013
      I = 1
      CALL SKIPBL(LINE, I)
      IF (.NOT.(LINE(I) .EQ. 10))GOTO 23014
      GOTO 23012
23014 CONTINUE
      IF (.NOT.(LEN.GT.6 .AND. LINE(6).NE. 32 .AND. LINE(6).NE. 48 .AND.
     * LINE(6).NE. 9))GOTO 23016
      GOTO 23017
23016 CONTINUE
      KIND = GCODE(LINE)
23017 CONTINUE
      CALL KEEPLN(LINE,KIND)
      IF (.NOT.(KIND.EQ.2))GOTO 23018
      CALL SFLUSH (OFD)
      NEXTP = 1
      PTR(NEXTP) = 1
      KIND = 12
23018 CONTINUE
23012 LEN=GETLIN(LINE,IFD)
      GOTO 23011
23013 CONTINUE
      IF (.NOT.(NEXTP .GT. 1))GOTO 23020
      CALL SFLUSH (OFD)
23020 CONTINUE
      RETURN
      END
      INTEGER FUNCTION FTNTOK(LINE, I, TOKEN)
      LOGICAL*1 LINE(100), TOKEN(100), C
      INTEGER I, J
      LOGICAL*1 TYPE
      CALL SKIPBL(LINE, I)
      J = 1
      IF (.NOT.(TYPE(LINE(I)) .EQ. 1))GOTO 23022
23024 CONTINUE
      TOKEN(J) = LINE(I)
      J = J + 1
      I = I + 1
      C = TYPE(LINE(I))
23025 IF (.NOT.(C .NE. 1 .AND. C .NE. 2 .AND. C .NE. 95))GOTO 23024
23026 CONTINUE
23022 CONTINUE
      TOKEN(J) = 0
      IF (.NOT.(LINE(I) .EQ. 42))GOTO 23027
23029 CONTINUE
      I = I + 1
23030 IF (.NOT.(TYPE(LINE(I)) .NE. 2))GOTO 23029
23031 CONTINUE
23027 CONTINUE
      CALL FOLD(TOKEN)
      FTNTOK=(J - 1)
      RETURN
      END
      INTEGER FUNCTION GCODE(LINE)
      LOGICAL*1 LINE(100), WORD(402)
      INTEGER I, LEN, CODE
      INTEGER LOOKUP, FTNTOK
      INTEGER TMP
      LOGICAL*1 BUF
      INTEGER PTR
      INTEGER TYPE
      INTEGER NEXTP
      INTEGER STB
      COMMON /RATP2C/ BUF(20000),PTR(1000),TYPE(1000), NEXTP, STB
      I = 1
      IF (.NOT.(FTNTOK(LINE, I, WORD) .EQ. 0))GOTO 23032
      GCODE=(3)
      RETURN
23032 CONTINUE
      IF (.NOT.(LOOKUP(WORD, CODE, STB) .EQ. 0))GOTO 23034
      GCODE=(3)
      RETURN
23034 CONTINUE
      IF (.NOT.(CODE.EQ.10 .OR. CODE.EQ.9))GOTO 23036
      TMP = CODE
      LEN = FTNTOK(LINE,I,WORD)
      IF (.NOT.(LOOKUP(WORD,CODE, STB) .EQ. 0))GOTO 23038
      GCODE=(3)
      RETURN
23038 CONTINUE
      IF (.NOT.(TMP.EQ.10 .AND. CODE.EQ.8))GOTO 23040
      GCODE=(4)
      RETURN
23040 CONTINUE
      IF (.NOT.(TMP.EQ.9 .AND. CODE.EQ.11))GOTO 23042
      GCODE=(5)
      RETURN
23042 CONTINUE
      GCODE=(3)
      RETURN
23043 CONTINUE
23041 CONTINUE
      GOTO 23037
23036 CONTINUE
      GCODE=(CODE)
      RETURN
23037 CONTINUE
      GCODE=(3)
      RETURN
      END
      SUBROUTINE INITFS (TB)
      INTEGER TB
      INTEGER JUNK
      INTEGER ENTER
      LOGICAL*1 SEND(4)
      LOGICAL*1 SPROG(8)
      LOGICAL*1 SSUB(11)
      LOGICAL*1 SFUNC(9)
      LOGICAL*1 SBLCK(6)
      LOGICAL*1 SDATA(5)
      LOGICAL*1 SINT(8)
      LOGICAL*1 SREAL(5)
      LOGICAL*1 SDOUBL(7)
      LOGICAL*1 SPREC(10)
      LOGICAL*1 SLOG(8)
      LOGICAL*1 SCOMPL(8)
      LOGICAL*1 SCHAR(10)
      LOGICAL*1 SBYTE(5)
      LOGICAL*1 SEXT(9)
      LOGICAL*1 SDIM(10)
      LOGICAL*1 SIMPL(9)
      LOGICAL*1 SCOM(7)
      LOGICAL*1 SEQU(12)
      DATA SEND(1)/101/,SEND(2)/110/,SEND(3)/100/,SEND(4)/0/
      DATA SPROG(1)/112/,SPROG(2)/114/,SPROG(3)/111/,SPROG(4)/103/,SPROG
     *(5)/114/,SPROG(6)/97/,SPROG(7)/109/,SPROG(8)/0/
      DATA SSUB(1)/115/,SSUB(2)/117/,SSUB(3)/98/,SSUB(4)/114/,SSUB(5)/11
     *1/,SSUB(6)/117/,SSUB(7)/116/,SSUB(8)/105/,SSUB(9)/110/,SSUB(10)/10
     *1/,SSUB(11)/0/
      DATA SFUNC(1)/102/,SFUNC(2)/117/,SFUNC(3)/110/,SFUNC(4)/99/,SFUNC(
     *5)/116/,SFUNC(6)/105/,SFUNC(7)/111/,SFUNC(8)/110/,SFUNC(9)/0/
      DATA SBLCK(1)/98/,SBLCK(2)/108/,SBLCK(3)/111/,SBLCK(4)/99/,SBLCK(5
     *)/107/,SBLCK(6)/0/
      DATA SDATA(1)/100/,SDATA(2)/97/,SDATA(3)/116/,SDATA(4)/97/,SDATA(5
     *)/0/
      DATA SINT(1)/105/,SINT(2)/110/,SINT(3)/116/,SINT(4)/101/,SINT(5)/1
     *03/,SINT(6)/101/,SINT(7)/114/,SINT(8)/0/
      DATA SREAL(1)/114/,SREAL(2)/101/,SREAL(3)/97/,SREAL(4)/108/,SREAL(
     *5)/0/
      DATA SDOUBL(1)/100/,SDOUBL(2)/111/,SDOUBL(3)/117/,SDOUBL(4)/98/,SD
     *OUBL(5)/108/,SDOUBL(6)/101/,SDOUBL(7)/0/
      DATA SPREC(1)/112/,SPREC(2)/114/,SPREC(3)/101/,SPREC(4)/99/,SPREC(
     *5)/105/,SPREC(6)/115/,SPREC(7)/105/,SPREC(8)/111/,SPREC(9)/110/,SP
     *REC(10)/0/
      DATA SLOG(1)/108/,SLOG(2)/111/,SLOG(3)/103/,SLOG(4)/105/,SLOG(5)/9
     *9/,SLOG(6)/97/,SLOG(7)/108/,SLOG(8)/0/
      DATA SCOMPL(1)/99/,SCOMPL(2)/111/,SCOMPL(3)/109/,SCOMPL(4)/112/,SC
     *OMPL(5)/108/,SCOMPL(6)/101/,SCOMPL(7)/120/,SCOMPL(8)/0/
      DATA SCHAR(1)/99/,SCHAR(2)/104/,SCHAR(3)/97/,SCHAR(4)/114/,SCHAR(5
     *)/97/,SCHAR(6)/99/,SCHAR(7)/116/,SCHAR(8)/101/,SCHAR(9)/114/,SCHAR
     *(10)/0/
      DATA SBYTE(1)/98/,SBYTE(2)/121/,SBYTE(3)/116/,SBYTE(4)/101/,SBYTE(
     *5)/0/
      DATA SEXT(1)/101/,SEXT(2)/120/,SEXT(3)/116/,SEXT(4)/101/,SEXT(5)/1
     *14/,SEXT(6)/110/,SEXT(7)/97/,SEXT(8)/108/,SEXT(9)/0/
      DATA SDIM(1)/100/,SDIM(2)/105/,SDIM(3)/109/,SDIM(4)/101/,SDIM(5)/1
     *10/,SDIM(6)/115/,SDIM(7)/105/,SDIM(8)/111/,SDIM(9)/110/,SDIM(10)/0
     */
      DATA SIMPL(1)/105/,SIMPL(2)/109/,SIMPL(3)/112/,SIMPL(4)/108/,SIMPL
     *(5)/105/,SIMPL(6)/99/,SIMPL(7)/105/,SIMPL(8)/116/,SIMPL(9)/0/
      DATA SCOM(1)/99/,SCOM(2)/111/,SCOM(3)/109/,SCOM(4)/109/,SCOM(5)/11
     *1/,SCOM(6)/110/,SCOM(7)/0/
      DATA SEQU(1)/101/,SEQU(2)/113/,SEQU(3)/117/,SEQU(4)/105/,SEQU(5)/1
     *18/,SEQU(6)/97/,SEQU(7)/108/,SEQU(8)/101/,SEQU(9)/110/,SEQU(10)/99
     */,SEQU(11)/101/,SEQU(12)/0/
      JUNK = ENTER(SPROG, 4, TB)
      JUNK = ENTER(SSUB, 4, TB)
      JUNK = ENTER(SBLCK, 10, TB)
      JUNK = ENTER(SCOM, 6, TB)
      JUNK = ENTER(SFUNC, 5, TB)
      JUNK = ENTER(SINT, 5, TB)
      JUNK = ENTER(SREAL, 5, TB)
      JUNK = ENTER(SLOG, 5, TB)
      JUNK = ENTER(SCOMPL, 5, TB)
      JUNK = ENTER(SCHAR, 5, TB)
      JUNK = ENTER(SBYTE, 5, TB)
      JUNK = ENTER(SDIM, 5, TB)
      JUNK = ENTER(SEXT, 5, TB)
      JUNK = ENTER(SIMPL, 5, TB)
      JUNK = ENTER(SEQU, 7, TB)
      JUNK = ENTER(SDATA, 8, TB)
      JUNK = ENTER(SDOUBL, 9, TB)
      JUNK = ENTER(SPREC, 11, TB)
      JUNK = ENTER(SEND, 2, TB)
      RETURN
      END
      SUBROUTINE KEEPLN(LINE,KIND)
      LOGICAL*1 LINE(100)
      INTEGER LENGTH
      INTEGER I,J
      INTEGER KIND
      LOGICAL*1 BUF
      INTEGER PTR
      INTEGER TYPE
      INTEGER NEXTP
      INTEGER STB
      LOGICAL*1 ST002Z(21)
      LOGICAL*1 ST003Z(20)
      LOGICAL*1 ST004Z(20)
      COMMON /RATP2C/ BUF(20000),PTR(1000),TYPE(1000), NEXTP, STB
      DATA ST002Z(1)/114/,ST002Z(2)/97/,ST002Z(3)/116/,ST002Z(4)/112/,ST
     *002Z(5)/50/,ST002Z(6)/32/,ST002Z(7)/115/,ST002Z(8)/101/,ST002Z(9)/
     *113/,ST002Z(10)/117/,ST002Z(11)/101/,ST002Z(12)/110/,ST002Z(13)/99
     */,ST002Z(14)/101/,ST002Z(15)/32/,ST002Z(16)/101/,ST002Z(17)/114/,S
     *T002Z(18)/114/,ST002Z(19)/111/,ST002Z(20)/114/,ST002Z(21)/0/
      DATA ST003Z(1)/116/,ST003Z(2)/111/,ST003Z(3)/111/,ST003Z(4)/32/,ST
     *003Z(5)/109/,ST003Z(6)/97/,ST003Z(7)/110/,ST003Z(8)/121/,ST003Z(9)
     */32/,ST003Z(10)/100/,ST003Z(11)/101/,ST003Z(12)/99/,ST003Z(13)/108
     */,ST003Z(14)/32/,ST003Z(15)/108/,ST003Z(16)/105/,ST003Z(17)/110/,S
     *T003Z(18)/101/,ST003Z(19)/115/,ST003Z(20)/0/
      DATA ST004Z(1)/116/,ST004Z(2)/111/,ST004Z(3)/111/,ST004Z(4)/32/,ST
     *004Z(5)/109/,ST004Z(6)/97/,ST004Z(7)/110/,ST004Z(8)/121/,ST004Z(9)
     */32/,ST004Z(10)/100/,ST004Z(11)/101/,ST004Z(12)/99/,ST004Z(13)/108
     */,ST004Z(14)/32/,ST004Z(15)/99/,ST004Z(16)/104/,ST004Z(17)/97/,ST0
     *04Z(18)/114/,ST004Z(19)/115/,ST004Z(20)/0/
      IF (.NOT.(KIND .EQ. 12))GOTO 23044
      CALL ERROR(ST002Z)
23044 CONTINUE
      IF (.NOT.(NEXTP .EQ. 1000))GOTO 23046
      CALL ERROR(ST003Z)
23046 CONTINUE
      TYPE(NEXTP) = KIND
      I = PTR(NEXTP)
      J = LENGTH(LINE)
      IF (.NOT.(I+J .GE. 20000))GOTO 23048
      CALL ERROR(ST004Z)
23048 CONTINUE
      CALL SCOPY(LINE,1,BUF,I)
      NEXTP = NEXTP + 1
      PTR(NEXTP) = I+J+1
      RETURN
      END
      SUBROUTINE SFLUSH(FD)
      INTEGER FD,J,P
      INTEGER I,KIND, ORD(10)
      LOGICAL*1 BUF
      INTEGER PTR
      INTEGER TYPE
      INTEGER NEXTP
      INTEGER STB
      COMMON /RATP2C/ BUF(20000),PTR(1000),TYPE(1000), NEXTP, STB
      DATA ORD(1)/4/, ORD(2)/5/, ORD(3)/6/, ORD(4)/7/, ORD(5)/8/, ORD(6)
     */3/, ORD(7)/2/, ORD(8)/12/
      I=1
23050 IF (.NOT.(ORD(I) .NE. 12))GOTO 23052
      KIND = ORD(I)
      P=1
23053 IF (.NOT.(P.LT.NEXTP))GOTO 23055
      IF (.NOT.(TYPE(P) .EQ. KIND))GOTO 23056
      J = PTR(P)
      CALL PUTLIN(BUF(J),FD)
23056 CONTINUE
23054 P=P+1
      GOTO 23053
23055 CONTINUE
23051 I=I+1
      GOTO 23050
23052 CONTINUE
      RETURN
      END
