      SUBROUTINE MAIN
      INTEGER NLINES, SUM, I, ASSIGN, N, GETLIN, EOR, OPEN, OUTFIL, IEOF
     *, J
      INTEGER STATUS, MAKRUN, SUNIT, NRUNS
      LOGICAL*1 BUF(400)
      COMMON / SELECT / TAPE, A(3), D(3), LEVEL, UNIT(3), T(3), FILE(40,
     * 3)
      INTEGER TAPE
      INTEGER A
      INTEGER D
      INTEGER LEVEL
      INTEGER UNIT
      INTEGER T
      LOGICAL*1 FILE
      COMMON / CSORT / LINPTR(750), BLANKS, DICT, FOLD, NOPRT, MERG, REV
     *ERS, SUBF, COFSET, IFOUT, OFILE(40), LINBUF(18000)
      INTEGER LINPTR
      INTEGER BLANKS
      INTEGER DICT
      INTEGER FOLD
      INTEGER NOPRT
      INTEGER MERG
      INTEGER REVERS
      INTEGER SUBF
      INTEGER COFSET
      INTEGER IFOUT
      LOGICAL*1 OFILE
      LOGICAL*1 LINBUF
      CALL SRTINT
      STATUS = 0
      NRUNS = 0
23000 CONTINUE
      IF(.NOT.(STATUS .EQ. 0))GOTO 23003
      STATUS = MAKRUN(NLINES)
      NRUNS = NRUNS + 1
      IF(.NOT.(MERG .EQ. 0))GOTO 23005
      CALL QUICK(LINPTR, NLINES, LINBUF)
23005 CONTINUE
      IF(.NOT.(NRUNS .EQ. 1))GOTO 23007
      IF(.NOT.(STATUS .EQ. -3))GOTO 23009
      CALL REDOUT
      CALL PUTRUN(LINPTR, NLINES, LINBUF, 2)
      RETURN
23009 CONTINUE
      CALL FSETUP
23010 CONTINUE
23007 CONTINUE
      GOTO 23004
23003 CONTINUE
      NLINES = 0
23004 CONTINUE
      IF(.NOT.(SUM(D, 3-1) .GT. 0 .OR. NLINES .GT. 0))GOTO 23011
      CALL STAPE
      IF(.NOT.(A(TAPE) .GT. 1))GOTO 23013
      CALL PUTEOR(UNIT(TAPE))
23013 CONTINUE
      CALL PUTRUN(LINPTR, NLINES, LINBUF, UNIT(TAPE))
23011 CONTINUE
23001 IF(.NOT.(SUM(D, 3-1) .EQ. 0 .AND. STATUS .EQ. -3))GOTO 23000
23002 CONTINUE
      I=1
23015 IF(.NOT.(I .LT. 3))GOTO 23017
      T(I) = I
      IF(.NOT.(ASSIGN(FILE(1,I), UNIT(I), 1) .EQ. -3))GOTO 23018
      CALL CANT(FILE(1,I))
23018 CONTINUE
23016 I=I+1
      GOTO 23015
23017 CONTINUE
      UNIT(3) = OPEN(FILE(1,3), 2)
      IF(.NOT.(UNIT(3) .EQ. -3))GOTO 23020
      CALL CANT(FILE(1,3))
23020 CONTINUE
      T(3) = 3
23022 CONTINUE
      OUTFIL = T(3)
      IF(.NOT.(LEVEL .EQ. 1))GOTO 23025
      SUNIT = UNIT(OUTFIL)
      CALL REDOUT
      UNIT(OUTFIL) = 2
23025 CONTINUE
23027 CONTINUE
      CALL MRGRUN(IEOF)
      IF(.NOT.(IEOF .EQ. 0))GOTO 23030
      CALL PUTEOR(UNIT(OUTFIL))
23030 CONTINUE
23028 IF(.NOT.(IEOF .GT. 0))GOTO 23027
23029 CONTINUE
      IF(.NOT.(LEVEL .EQ. 1))GOTO 23032
      UNIT(OUTFIL) = SUNIT
      GOTO 23024
23032 CONTINUE
      I = T(IEOF)
      J = T(3)
      IF(.NOT.(ASSIGN(FILE(1,I), UNIT(I), 2) .EQ. -3))GOTO 23034
      CALL CANT(FILE(1,I))
23034 CONTINUE
      IF(.NOT.(ASSIGN(FILE(1,J), UNIT(J), 1) .EQ. -3))GOTO 23036
      CALL CANT(FILE(1,J))
23036 CONTINUE
      T(3) = I
      T(IEOF) = J
      LEVEL = LEVEL - 1
23023 IF(.NOT.(LEVEL .EQ. 0))GOTO 23022
23024 CONTINUE
      CALL CLEANS
      RETURN
      END
      SUBROUTINE SRTINT
      LOGICAL*1 TEMP(40), CLOWER
      INTEGER I, N, GETARG, INDEX, CTOI
      COMMON / SELECT / TAPE, A(3), D(3), LEVEL, UNIT(3), T(3), FILE(40,
     * 3)
      INTEGER TAPE
      INTEGER A
      INTEGER D
      INTEGER LEVEL
      INTEGER UNIT
      INTEGER T
      LOGICAL*1 FILE
      COMMON / CSORT / LINPTR(750), BLANKS, DICT, FOLD, NOPRT, MERG, REV
     *ERS, SUBF, COFSET, IFOUT, OFILE(40), LINBUF(18000)
      INTEGER LINPTR
      INTEGER BLANKS
      INTEGER DICT
      INTEGER FOLD
      INTEGER NOPRT
      INTEGER MERG
      INTEGER REVERS
      INTEGER SUBF
      INTEGER COFSET
      INTEGER IFOUT
      LOGICAL*1 OFILE
      LOGICAL*1 LINBUF
      COMMON /FLIST/ FLEVEL, FFILES(40, 25)
      INTEGER FLEVEL
      LOGICAL*1 FFILES
      FLEVEL = 0
      BLANKS = 0
      DICT = 0
      FOLD = 0
      NOPRT = 0
      MERG = 0
      REVERS = 0
      SUBF = 0
      COFSET = 0
      IFOUT = 0
      I=1
23038 IF(.NOT.(GETARG(I, TEMP, 40) .NE. -1))GOTO 23040
      IF(.NOT.(TEMP(1) .EQ. 63 .AND. TEMP(2) .EQ. 0))GOTO 23041
      CALL ERROR(49Husage:  sort [-bdfimr] [+ofile] [+sn] [file ...].)
      GOTO 23042
23041 CONTINUE
      IF(.NOT.(TEMP(1) .EQ. 45 .AND. TEMP(2) .NE. 0))GOTO 23043
      IF(.NOT.(INDEX(TEMP, 98) .NE. 0 .OR. INDEX(TEMP, 66) .NE. 0))GOTO 
     *23045
      BLANKS = 1
23045 CONTINUE
      IF(.NOT.(INDEX(TEMP, 100) .NE. 0 .OR. INDEX(TEMP, 68) .NE. 0))GOTO
     * 23047
      DICT = 1
23047 CONTINUE
      IF(.NOT.(INDEX(TEMP, 102) .NE. 0 .OR. INDEX(TEMP, 70) .NE. 0))GOTO
     * 23049
      FOLD = 1
23049 CONTINUE
      IF(.NOT.(INDEX(TEMP, 105) .NE. 0 .OR. INDEX(TEMP, 73) .NE. 0))GOTO
     * 23051
      NOPRT = 1
23051 CONTINUE
      IF(.NOT.(INDEX(TEMP, 109) .NE. 0 .OR. INDEX(TEMP, 77) .NE. 0))GOTO
     * 23053
      MERG = 1
23053 CONTINUE
      IF(.NOT.(INDEX(TEMP, 114) .NE. 0 .OR. INDEX(TEMP, 82) .NE. 0))GOTO
     * 23055
      REVERS = 1
23055 CONTINUE
      GOTO 23044
23043 CONTINUE
      IF(.NOT.(TEMP(1) .EQ. 43 .AND. CLOWER(TEMP(2)) .EQ. 115))GOTO 2305
     *7
      SUBF = 1
      N = 3
      COFSET = CTOI(TEMP, N) - 1
      IF(.NOT.(COFSET .LT. 0))GOTO 23059
      COFSET = 0
23059 CONTINUE
      GOTO 23058
23057 CONTINUE
      IF(.NOT.(TEMP(1) .EQ. 43 .AND. CLOWER(TEMP(2)) .EQ. 111))GOTO 2306
     *1
      IFOUT = 1
      CALL SCOPY(TEMP, 3, OFILE, 1)
      GOTO 23062
23061 CONTINUE
      CALL FSTACK(TEMP)
23062 CONTINUE
23058 CONTINUE
23044 CONTINUE
23042 CONTINUE
23039 I=I+1
      GOTO 23038
23040 CONTINUE
      RETURN
      END
      SUBROUTINE FSTACK (IARG)
      INTEGER I
      LOGICAL*1 IARG(40)
      COMMON /FLIST/ FLEVEL, FFILES(40, 25)
      INTEGER FLEVEL
      LOGICAL*1 FFILES
      IF(.NOT.(FLEVEL .LT. 25))GOTO 23063
      FLEVEL = FLEVEL + 1
      I=1
23065 IF(.NOT.(I.LE.40))GOTO 23067
      FFILES(I,FLEVEL) = IARG(I)
23066 I=I+1
      GOTO 23065
23067 CONTINUE
23063 CONTINUE
      RETURN
      END
      INTEGER FUNCTION MAKRUN(NLINES)
      INTEGER NLINES, LBP, LEN, GSRTLN
      COMMON / CSORT / LINPTR(750), BLANKS, DICT, FOLD, NOPRT, MERG, REV
     *ERS, SUBF, COFSET, IFOUT, OFILE(40), LINBUF(18000)
      INTEGER LINPTR
      INTEGER BLANKS
      INTEGER DICT
      INTEGER FOLD
      INTEGER NOPRT
      INTEGER MERG
      INTEGER REVERS
      INTEGER SUBF
      INTEGER COFSET
      INTEGER IFOUT
      LOGICAL*1 OFILE
      LOGICAL*1 LINBUF
      NLINES = 0
      LBP = 1
23068 CONTINUE
      LEN = GSRTLN(LINBUF(LBP))
      IF(.NOT.(LEN .EQ. -3))GOTO 23071
      GOTO 23070
23071 CONTINUE
      IF(.NOT.(LEN .EQ. -1 .AND. MERG .EQ. 1))GOTO 23073
      GOTO 23070
23073 CONTINUE
      IF(.NOT.(LEN .NE. -1))GOTO 23075
      NLINES = NLINES + 1
      LINPTR(NLINES) = LBP
      LBP = LBP + LEN + 1
      IF(.NOT.(LBP .GE. 18000 - 400 .OR. NLINES .GE. 750))GOTO 23077
      GOTO 23070
23077 CONTINUE
23075 CONTINUE
23069 GOTO 23068
23070 CONTINUE
      IF(.NOT.(LEN .EQ. -3))GOTO 23079
      MAKRUN = -3
      GOTO 23080
23079 CONTINUE
      MAKRUN = 0
23080 CONTINUE
      RETURN
      END
      SUBROUTINE PUTRUN(LINPTR, NLINES, LINBUF, OUTFIL)
      LOGICAL*1 LINBUF(18000)
      INTEGER I, J, LINPTR(750), NLINES, OUTFIL
      I=1
23081 IF(.NOT.(I .LE. NLINES))GOTO 23083
      J = LINPTR(I)
      CALL PUTLIN(LINBUF(J), OUTFIL)
23082 I=I+1
      GOTO 23081
23083 CONTINUE
      RETURN
      END
      SUBROUTINE STAPE
      INTEGER I, Z
      COMMON / SELECT / TAPE, A(3), D(3), LEVEL, UNIT(3), T(3), FILE(40,
     * 3)
      INTEGER TAPE
      INTEGER A
      INTEGER D
      INTEGER LEVEL
      INTEGER UNIT
      INTEGER T
      LOGICAL*1 FILE
      IF(.NOT.(D(TAPE) .LT. D(TAPE+1)))GOTO 23084
      TAPE = TAPE + 1
      GOTO 23085
23084 CONTINUE
      IF(.NOT.(D(TAPE) .EQ. 0))GOTO 23086
      LEVEL = LEVEL + 1
      Z = A(1)
      I=1
23088 IF(.NOT.(I .LT. 3))GOTO 23090
      D(I) = Z + A(I+1) - A(I)
      A(I) = Z + A(I+1)
23089 I=I+1
      GOTO 23088
23090 CONTINUE
23086 CONTINUE
      TAPE = 1
23085 CONTINUE
      D(TAPE) = D(TAPE) - 1
      RETURN
      END
      INTEGER FUNCTION EOR(BUFFER)
      LOGICAL*1 BUFFER(100)
      IF(.NOT.(BUFFER(1) .EQ. 4 .AND. BUFFER(2) .EQ. 10))GOTO 23091
      EOR = 1
      GOTO 23092
23091 CONTINUE
      EOR = 0
23092 CONTINUE
      RETURN
      END
      SUBROUTINE PUTEOR(INT)
      INTEGER INT
      CALL PUTCH(4, INT)
      CALL PUTCH(10, INT)
      RETURN
      END
      INTEGER FUNCTION SUM(ARRAY, N)
      INTEGER ARRAY(100), N, I
      SUM = 0
      I=1
23093 IF(.NOT.(I.LE.N))GOTO 23095
      SUM = SUM + ARRAY(I)
23094 I=I+1
      GOTO 23093
23095 CONTINUE
      RETURN
      END
      SUBROUTINE QUICK(LINPTR, NLINES, LINBUF)
      LOGICAL*1 LINBUF(100)
      INTEGER COMPAR
      INTEGER I, J, LINPTR(100), LV(20), NLINES, P, PIVLIN, UV(20)
      LV(1) = 1
      UV(1) = NLINES
      P = 1
23096 IF(.NOT.(P .GT. 0))GOTO 23097
      IF(.NOT.(LV(P) .GE. UV(P)))GOTO 23098
      P = P - 1
      GOTO 23099
23098 CONTINUE
      I = LV(P) - 1
      J = UV(P)
      PIVLIN = LINPTR(J)
23100 IF(.NOT.(I .LT. J))GOTO 23101
      I=I+1
23102 IF(.NOT.(COMPAR(LINPTR(I), PIVLIN, LINBUF) .LT. 0))GOTO 23104
23103 I=I+1
      GOTO 23102
23104 CONTINUE
      J = J - 1
23105 IF(.NOT.(J .GT. I))GOTO 23107
      IF(.NOT.(COMPAR(LINPTR(J), PIVLIN, LINBUF) .LE. 0))GOTO 23108
      GOTO 23107
23108 CONTINUE
23106 J = J - 1
      GOTO 23105
23107 CONTINUE
      IF(.NOT.(I .LT. J))GOTO 23110
      CALL EXCHAN(LINPTR(I), LINPTR(J), LINBUF)
23110 CONTINUE
      GOTO 23100
23101 CONTINUE
      J = UV(P)
      CALL EXCHAN(LINPTR(I), LINPTR(J), LINBUF)
      IF(.NOT.(I-LV(P) .LT. UV(P)-I))GOTO 23112
      LV(P+1) = LV(P)
      UV(P+1) = I - 1
      LV(P) = I + 1
      GOTO 23113
23112 CONTINUE
      LV(P+1) = I + 1
      UV(P+1) = UV(P)
      UV(P) = I - 1
23113 CONTINUE
      P = P + 1
23099 CONTINUE
      GOTO 23096
23097 CONTINUE
      RETURN
      END
      INTEGER FUNCTION COMPAR(LP1, LP2, LIN)
      LOGICAL*1 LIN(100)
      INTEGER I, J, LP1, LP2
      INTEGER TYPE, CT
      LOGICAL*1 C1,C2
      LOGICAL*1 CLOWER
      COMMON / CSORT / LINPTR(750), BLANKS, DICT, FOLD, NOPRT, MERG, REV
     *ERS, SUBF, COFSET, IFOUT, OFILE(40), LINBUF(18000)
      INTEGER LINPTR
      INTEGER BLANKS
      INTEGER DICT
      INTEGER FOLD
      INTEGER NOPRT
      INTEGER MERG
      INTEGER REVERS
      INTEGER SUBF
      INTEGER COFSET
      INTEGER IFOUT
      LOGICAL*1 OFILE
      LOGICAL*1 LINBUF
      I = LP1
      J = LP2
      IF(.NOT.(BLANKS .EQ. 1))GOTO 23114
23116 IF(.NOT.(LIN(I) .EQ. 32))GOTO 23117
      I = I + 1
      GOTO 23116
23117 CONTINUE
23118 IF(.NOT.(LIN(J) .EQ. 32))GOTO 23119
      J = J + 1
      GOTO 23118
23119 CONTINUE
      GOTO 23115
23114 CONTINUE
      IF(.NOT.(SUBF .EQ. 1))GOTO 23120
23122 IF(.NOT.(LIN(I) .NE. 0))GOTO 23123
      I = I + 1
      GOTO 23122
23123 CONTINUE
23124 IF(.NOT.(LIN(J) .NE. 0))GOTO 23125
      J = J + 1
      GOTO 23124
23125 CONTINUE
      IF(.NOT.(I .GT. LP1 + COFSET))GOTO 23126
      I = LP1 + COFSET
23126 CONTINUE
      IF(.NOT.(J .GT. LP2 + COFSET))GOTO 23128
      J = LP2 + COFSET
23128 CONTINUE
23120 CONTINUE
23115 CONTINUE
23130 CONTINUE
      IF(.NOT.(LIN(I) .EQ. 0))GOTO 23133
      COMPAR = 0
      RETURN
23133 CONTINUE
      IF(.NOT.(NOPRT .EQ. 1))GOTO 23135
23137 IF(.NOT.((LIN(I) .GT. 0 .AND. LIN(I) .LT. 32) .OR. LIN(I) .EQ. 127
     *))GOTO 23138
      I = I + 1
      GOTO 23137
23138 CONTINUE
23139 IF(.NOT.((LIN(J) .GT. 0 .AND. LIN(J) .LT. 32) .OR. LIN(J) .EQ. 127
     *))GOTO 23140
      J = J + 1
      GOTO 23139
23140 CONTINUE
23135 CONTINUE
      IF(.NOT.(DICT .EQ. 1))GOTO 23141
23143 CONTINUE
      CT = TYPE (LIN(I))
      IF(.NOT.(CT .EQ. 1 .OR. CT .EQ. 2 .OR. CT.EQ. 32 .OR. CT .EQ. 0))G
     *OTO 23146
      GOTO 23145
23146 CONTINUE
      I = I + 1
23144 GOTO 23143
23145 CONTINUE
23148 CONTINUE
      CT = TYPE (LIN(J))
      IF(.NOT.(CT .EQ. 1 .OR. CT .EQ. 2 .OR. CT .EQ. 32 .OR. CT .EQ. 0))
     *GOTO 23151
      GOTO 23150
23151 CONTINUE
      J = J + 1
23149 GOTO 23148
23150 CONTINUE
23141 CONTINUE
      IF(.NOT.(FOLD .EQ. 1))GOTO 23153
      C1 = CLOWER (LIN(I))
      C2 = CLOWER(LIN(J))
      GOTO 23154
23153 CONTINUE
      C1 = LIN(I)
      C2 = LIN(J)
23154 CONTINUE
      IF(.NOT.(C1 .NE. C2))GOTO 23155
      GOTO 23132
23155 CONTINUE
      I = I + 1
      J = J + 1
23131 GOTO 23130
23132 CONTINUE
      IF(.NOT.(C1 .LT. C2 ))GOTO 23157
      COMPAR = -1
      GOTO 23158
23157 CONTINUE
      COMPAR = +1
23158 CONTINUE
      IF(.NOT.(REVERS .EQ. 1))GOTO 23159
      COMPAR = -COMPAR
23159 CONTINUE
      RETURN
      END
      SUBROUTINE EXCHAN(LP1, LP2, LINBUF)
      LOGICAL*1 LINBUF(100)
      INTEGER K, LP1, LP2
      K = LP1
      LP1 = LP2
      LP2 = K
      RETURN
      END
      SUBROUTINE MRGRUN(IEOF)
      INTEGER OUTFIL, LBP, NF, I, K, N, GETLIN, EOR, IEOF
      COMMON / SELECT / TAPE, A(3), D(3), LEVEL, UNIT(3), T(3), FILE(40,
     * 3)
      INTEGER TAPE
      INTEGER A
      INTEGER D
      INTEGER LEVEL
      INTEGER UNIT
      INTEGER T
      LOGICAL*1 FILE
      COMMON / CSORT / LINPTR(750), BLANKS, DICT, FOLD, NOPRT, MERG, REV
     *ERS, SUBF, COFSET, IFOUT, OFILE(40), LINBUF(18000)
      INTEGER LINPTR
      INTEGER BLANKS
      INTEGER DICT
      INTEGER FOLD
      INTEGER NOPRT
      INTEGER MERG
      INTEGER REVERS
      INTEGER SUBF
      INTEGER COFSET
      INTEGER IFOUT
      LOGICAL*1 OFILE
      LOGICAL*1 LINBUF
      OUTFIL = T(3)
      LBP = 1
      NF = 0
      IEOF = 0
      I=1
23161 IF(.NOT.(I .LT. 3))GOTO 23163
      K = T(I)
      N = GETLIN(LINBUF(LBP), UNIT(K))
      IF(.NOT.(N .NE. -1 .AND. EOR(LINBUF(LBP)) .NE. 1))GOTO 23164
      NF = NF + 1
      LINPTR(NF) = LBP
      GOTO 23165
23164 CONTINUE
      IF(.NOT.(N .EQ. -1))GOTO 23166
      IEOF = I
23166 CONTINUE
23165 CONTINUE
      LBP = LBP + 400
23162 I=I+1
      GOTO 23161
23163 CONTINUE
      CALL QUICK(LINPTR, NF, LINBUF)
23168 IF(.NOT.(NF .GT. 0))GOTO 23169
      LBP = LINPTR(1)
      CALL PUTLIN(LINBUF(LBP), UNIT(OUTFIL))
      I = LBP / 400 + 1
      K = T(I)
      N = GETLIN(LINBUF(LBP), UNIT(K))
      IF(.NOT.(N .EQ. -1 .OR. EOR(LINBUF(LBP)) .EQ. 1))GOTO 23170
      LINPTR(1) = LINPTR(NF)
      NF = NF - 1
      IF(.NOT.(N .EQ. -1))GOTO 23172
      IEOF = I
23172 CONTINUE
23170 CONTINUE
      CALL REHEAP(LINPTR, NF, LINBUF)
      GOTO 23168
23169 CONTINUE
      RETURN
      END
      SUBROUTINE REHEAP(LINPTR, NF, LINBUF)
      LOGICAL*1 LINBUF(18000)
      INTEGER COMPAR
      INTEGER I, J, NF, LINPTR(100)
      I = 1
23174 IF(.NOT.(2 * I .LE. NF))GOTO 23176
      J = 2 * I
      IF(.NOT.(J .LT. NF))GOTO 23177
      IF(.NOT.(COMPAR(LINPTR(J), LINPTR(J+1), LINBUF) .GT. 0))GOTO 23179
      J = J + 1
23179 CONTINUE
23177 CONTINUE
      IF(.NOT.(COMPAR(LINPTR(I), LINPTR(J), LINBUF) .LE. 0))GOTO 23181
      GOTO 23176
23181 CONTINUE
      CALL EXCHAN(LINPTR(I), LINPTR(J), LINBUF)
23175 I = J
      GOTO 23174
23176 CONTINUE
      RETURN
      END
      SUBROUTINE CLEANS
      INTEGER I
      COMMON / SELECT / TAPE, A(3), D(3), LEVEL, UNIT(3), T(3), FILE(40,
     * 3)
      INTEGER TAPE
      INTEGER A
      INTEGER D
      INTEGER LEVEL
      INTEGER UNIT
      INTEGER T
      LOGICAL*1 FILE
      I=1
23183 IF(.NOT.(I .LE. 3))GOTO 23185
      IF(.NOT.(UNIT(I) .GT. 0))GOTO 23186
      CALL CLOSE(UNIT(I))
      CALL REMOVE(FILE(1,I))
23186 CONTINUE
23184 I=I+1
      GOTO 23183
23185 CONTINUE
      RETURN
      END
      INTEGER FUNCTION GSRTLN(BUF)
      LOGICAL*1 BUF(400)
      INTEGER GETLIN, INIT, LEVEL, FOPEN, OPEN, INFILE
      COMMON /FLIST/ FLEVEL, FFILES(40, 25)
      INTEGER FLEVEL
      LOGICAL*1 FFILES
      DATA INIT/0/
      IF(.NOT.(INIT .EQ. 0))GOTO 23188
      LEVEL = 0
      IF(.NOT.(FLEVEL .EQ. 0))GOTO 23190
      FLEVEL = 1
      CALL SCOPY(1H-, 1, FFILES(1,1), 1)
23190 CONTINUE
      INIT = 1
      FOPEN = 0
23188 CONTINUE
      IF(.NOT.(FOPEN .EQ. 0 .AND. LEVEL .EQ. FLEVEL))GOTO 23192
      GSRTLN = -3
      GOTO 23193
23192 CONTINUE
      IF(.NOT.(FOPEN .EQ. 0))GOTO 23194
      FOPEN = 1
      LEVEL = LEVEL + 1
      IF(.NOT.(FFILES(1, LEVEL) .EQ. 45))GOTO 23196
      INFILE = 1
      GOTO 23197
23196 CONTINUE
      INFILE = OPEN(FFILES(1, LEVEL), 1)
      IF(.NOT.(INFILE .EQ. -3))GOTO 23198
      CALL CANT(FFILES(1, LEVEL))
23198 CONTINUE
23197 CONTINUE
23194 CONTINUE
      GSRTLN = GETLIN(BUF, INFILE)
      IF(.NOT.(GSRTLN .EQ. -1))GOTO 23200
      FOPEN = 0
      IF(.NOT.(INFILE .NE. 1))GOTO 23202
      CALL CLOSE(INFILE)
23202 CONTINUE
23200 CONTINUE
23193 CONTINUE
      RETURN
      END
      SUBROUTINE FSETUP
      LOGICAL*1 TEMP(4)
      INTEGER I, N, ITOC, OPEN
      COMMON / SELECT / TAPE, A(3), D(3), LEVEL, UNIT(3), T(3), FILE(40,
     * 3)
      INTEGER TAPE
      INTEGER A
      INTEGER D
      INTEGER LEVEL
      INTEGER UNIT
      INTEGER T
      LOGICAL*1 FILE
      TAPE = 1
      LEVEL = 1
      I=1
23204 IF(.NOT.(I .LE. 3))GOTO 23206
      A(I) = 1
      D(I) = 1
      TEMP(1) = 115
      N = ITOC(I, TEMP(2), 3)
      CALL SCRATF(TEMP, FILE(1,I))
      IF(.NOT.(I .LT. 3))GOTO 23207
      UNIT(I) = OPEN(FILE(1,I), 2)
      IF(.NOT.(UNIT(I) .EQ. -3))GOTO 23209
      CALL CANT(FILE(1,I))
23209 CONTINUE
      GOTO 23208
23207 CONTINUE
      UNIT(I) = 0
23208 CONTINUE
23205 I=I+1
      GOTO 23204
23206 CONTINUE
      D(3) = 0
      A(3) = 0
      RETURN
      END
      SUBROUTINE REDOUT
      INTEGER ASSIGN
      COMMON / CSORT / LINPTR(750), BLANKS, DICT, FOLD, NOPRT, MERG, REV
     *ERS, SUBF, COFSET, IFOUT, OFILE(40), LINBUF(18000)
      INTEGER LINPTR
      INTEGER BLANKS
      INTEGER DICT
      INTEGER FOLD
      INTEGER NOPRT
      INTEGER MERG
      INTEGER REVERS
      INTEGER SUBF
      INTEGER COFSET
      INTEGER IFOUT
      LOGICAL*1 OFILE
      LOGICAL*1 LINBUF
      IF(.NOT.(IFOUT .EQ. 1))GOTO 23211
      IF(.NOT.(ASSIGN(OFILE, 2, 2) .EQ. -3))GOTO 23213
      CALL REMARK(43HCannot redirect standard output to +o file.)
23213 CONTINUE
23211 CONTINUE
      RETURN
      END
