      SUBROUTINE EDIT (MAXSP,MAXEQ,MAXEL,KFLAG)
      DOUBLE PRECISION C(9),ERR1,ERR2,WARN1,WARN2
      DOUBLE PRECISION ITEXT(11),OT1(8),OT2(8)
      DOUBLE PRECISION TP(51),EPS,V,X,RVAL,ZERO
      INTEGER ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT,INFDAT
      INTEGER MAXL(9),NUM(2),QFLAG
      INTEGER*2 STAR,CHAR1
      INTEGER*2 AA,CC,DD,EE,FF,GG,HH,II,LL,MM,NN,OO,PP,QQ,RR,SS,TT
      INTEGER*2 LA,LC,LD,LE,LF,LG,LH,LI,LLL,LM,LN,LO,LP,LQ,LR,LS,LT
      INTEGER*2 IN(80),INH(80),TAB(2,10),DLIM(11)
      LOGICAL LLINE,LCHA,LRVAL
      COMMON / LUNIT / ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT
      COMMON / INFORM / IHELP,INFDAT
      DATA AA /1HA/ , CC /1HC/ , DD /1HD/ , EE /1HE/, OO /1HO/
     @   , FF /1HF/ , GG /1HG/ , HH /1HH/ , II /1HI/
     @   , LL /1HL/ , MM /1HM/ , NN /1HN/ , PP /1HP/ , QQ /1HQ/
     @   , RR /1HR/ , SS /1HS/ , TT /1HT/ 
      DATA LA /1Ha/ , LC /1Hc/ , LD /1Hd/ , LE /1He/, LO /1Ho/
     @   , LF /1Hf/ , LG /1Hg/ , LH /1Hh/ , LI /1Hi/
     @   , LLL /1Hl/ , LM /1Hm/ , LN /1Hn/ , LP /1Hp/ , LQ /1Hq/
     @   , LR /1Hr/ , LS /1Hs/ , LT /1Ht/ , STAR /1H*/
      DATA ITEXT(1)/8H*HEAD   / , ITEXT(2)/8H*ELEME../ ,
     @     ITEXT(3)/8H*SPECI../ ,
     @     ITEXT(4)/8H*REACT../ , ITEXT(5)/8H*INITI../ ,
     @     ITEXT(6)/8H*TEMP.../ , ITEXT(7)/8H*GAS C../ ,
     @     ITEXT(8)/8H*NUMER../ ,
     @     ITEXT(9)/8H*ACCUR../ , ITEXT(10)/8H*OUTPUT./ ,
     @     ITEXT(11)/8H*PRINT../
      DATA OT1(1)/8HHEAD    / , OT2(1)/8H        / ,
     @     OT1(2)/8HELEMENT / , OT2(2)/8HLIST    / ,
     @     OT1(3)/8HSPECIES / , OT2(3)/8HLIST    / ,
     @     OT1(4)/8HREACTION/ , OT2(4)/8H SYSTEM / ,
     @     OT1(5)/8HINITIAL / , OT2(5)/8HVALUES  /,
     @     OT1(6)/8HTEMPERAT/ , OT2(6)/8HURE     /,
     @     OT1(7)/8HGAS CONS/ , OT2(7)/8HTANT    /,
     @     OT1(8)/8HNUMERICA/ , OT2(8)/8HL INPUT /
      DATA DLIM(1)/1HH/ , DLIM(2)/1HE/ , DLIM(3)/1HS/ , DLIM(4)/1HR/ ,
     @     DLIM(5)/1HI/ , DLIM(6)/1HT/ , DLIM(7)/1HG/ , DLIM(8)/1HN/ ,
     @     DLIM(9)/1HA/ , DLIM(10)/1HO/ , DLIM(11)/1HP/
      DATA ERR1/8H *** ERR/ , ERR2/8HOR ***  / , WARN1/8H *** WAR/ ,
     @     WARN2/8HNING ***/
      DATA ZERO/0.D0/
      DATA MAXL(1)/5/ , MAXL(6)/1/ , MAXL(7)/1/ , MAXL(8)/60/ ,
     @     MAXL(9)/50/
      MAXL(2)=MAXEL
      MAXL(3)=MAXSP
      MAXL(4)=MAXEQ
      MAXL(5)=MAXSP
      REWIND CIN
      REWIND HDS
      REWIND SIN
10    WRITE(ITOUT,8000)
8000  FORMAT(//,23H WORK WITH INPUT DATA: ,/,
     @ 38H / NEW / MODIFY / LIST / PRINT / Q / ?)
      TAB(1,1)=NN
      TAB(1,2)=MM
      TAB(1,3)=LL
      TAB(1,4)=PP
      TAB(1,5)=QQ
      TAB(2,1)=LN
      TAB(2,2)=LM
      TAB(2,3)=LLL
      TAB(2,4)=LP
      TAB(2,5)=LQ
      CALL ANSNUM (TAB,5,NUM,0,X,KFLAG,10)
      IF(KFLAG.LT.0) GOTO 6000
      GOTO (1000,2000,4000,3000,5000),KFLAG
1000  WRITE(ITOUT,8001)
8001  FORMAT(/,11H NEW MEANS:,/,33H THE ACTUAL INPUT FILE IS DELETED,
     @         41H AND A TOTALLY NEW MODEL MUST BE ENTERED.,/,
     @         48H FOR THE NUMERICAL INPUT STANDARD VALUES ARE SET,/,
     @         35H WHICH MAY BE OVERWRITTEN LATER ON.)
      WRITE(ITOUT,8002)
8002  FORMAT(/,17H / NEW / QUIT / ?)
      TAB(1,1)=NN
      TAB(1,2)=QQ
      TAB(2,1)=LN
      TAB(2,2)=LQ
      CALL ANSNUM (TAB,2,NUM,0,X,KFLAG,0)
      IF(KFLAG.NE.1) GOTO 10
      WRITE(CIN,8013)
8013  FORMAT(5H*HEAD)
      WRITE(CIN,8014)
8014  FORMAT(13H*ELEMENT LIST)
      WRITE(CIN,8015)
8015  FORMAT(13H*SPECIES LIST)
      WRITE(CIN,8016)
8016  FORMAT(16H*REACTION SYSTEM)
      WRITE(CIN,8017)
8017  FORMAT(23H*INITIAL CONCENTRATIONS)
      WRITE(CIN,8018)
8018  FORMAT(12H*TEMPERATURE)
      WRITE(CIN,8019)
8019  FORMAT(13H*GAS CONSTANT)
      WRITE(CIN,8020)
8020  FORMAT(16H*NUMERICAL INPUT)
      EPS=1.D-3
      ITPMAX=2
      TP(1)=ZERO
      TP(2)=1.D0
      IPRINT=0
      WRITE(CIN,8021)
8021  FORMAT(9H*ACCURACY)
      WRITE(CIN,8022) EPS
8022  FORMAT(D21.12)
      WRITE(CIN,8023)
8023  FORMAT(14H*OUTPUT POINTS)
      WRITE(CIN,8024) ITPMAX
8024  FORMAT(I3)
      WRITE(CIN,8022) TP(1)
      WRITE(CIN,8022) TP(2)
      WRITE(CIN,8025)
8025  FORMAT(16H*PRINT PARAMETER)
      WRITE(CIN,8024) IPRINT
      ENDFILE CIN
      REWIND CIN
      GOTO 10
2000  WRITE(ITOUT,8200)
8200  FORMAT(/,8H MODIFY:,/,
     @ 60H / HEAD / ELEMENT LIST / SPECIES LIST / CHEMICAL EQUATIONS /
     @ ,/,56H / INITIAL CONCENTRATIONS / TEMPERATURE / GAS CONSTANT /
     @ ,/,38H / NUMERICAL INPUT / QUIT / RETURN / ?)
      TAB(1,1)=HH
      TAB(1,2)=EE
      TAB(1,3)=SS
      TAB(1,4)=CC
      TAB(1,5)=II
      TAB(1,6)=TT
      TAB(1,7)=GG
      TAB(1,8)=NN
      TAB(1,9)=QQ
      TAB(1,10)=RR
      TAB(2,1)=LH
      TAB(2,2)=LE
      TAB(2,3)=LS
      TAB(2,4)=LC
      TAB(2,5)=LI
      TAB(2,6)=LT
      TAB(2,7)=LG
      TAB(2,8)=LN
      TAB(2,9)=LQ
      TAB(2,10)=LR
      CALL ANSNUM (TAB,10,NUM,0,X,KFLAG,11)
      GOTO (2100,2100,2100,2100,2100,2100,2100,2100,10,5000),KFLAG
      GOTO 2000
2100  IBLOCK=KFLAG
      IBEGIN=0
      ISTOP=0
      IDIFF=0
      ICOM=0
2105  READ(CIN,9000) IN(1),IN(2)
      IBEGIN=IBEGIN+1
      IF(IN(1).EQ.STAR.AND.IN(2).EQ.DLIM(IBLOCK)) GOTO 2110
      GOTO 2105
2106  WRITE(ITOUT,8210) ERR1,ERR2,ITEXT(IBLOCK),IN(1),IN(2)
8210  FORMAT(//,2A8,/,24H INPUT DATASET INVALID; ,A8,8H MISSING,/,
     @ 39H (OR NON-COMMENT CARD STARTS WITH *...),/,
     @ 36H EDIT STOPPED IN LINE STARTING WITH:,1X,1H',2A1,4H...',/)
      RETURN
2110  IF((IDIFF-ICOM).GT.MAXL(IBLOCK)) GOTO 2112
      READ(CIN,9000) IN(1),IN(2)
      IDIFF=IDIFF+1
      IF(IN(1).NE.STAR) GOTO 2110
      IF(IN(2).NE.CC) GOTO 2111
      ICOM=ICOM+1
      GOTO 2110
2111  IF(IN(2).EQ.DLIM(IBLOCK+1)) GOTO 2120
      IBLOCK=IBLOCK+1
      GOTO 2106
2112  WRITE(ITOUT,8213) ERR1,ERR2,MAXL(IBLOCK),OT1(IBLOCK),OT2(IBLOCK)
8213  FORMAT(//,2A8,/,11H MORE THAN ,I4,17H INPUT LINES FOR ,2A8)
      RETURN
2120  IDIFF=IDIFF-1
      IF(IBLOCK.EQ.8) GOTO 2700
      ISTOP=IBEGIN+IDIFF
      IF(IBLOCK.EQ.6) GOTO 2500
      IF(IBLOCK.EQ.7) GOTO 2500
2125  IF(IDIFF.LE.0) WRITE(ITOUT,8215) WARN1,WARN2,OT1(IBLOCK),
     @ OT2(IBLOCK)
8215  FORMAT(//,2A8,/,4H NO ,2A8,23H IN INPUT DATASET FOUND,/,
     @ 51H IN MODIFY ONLY THE COMMANDS: / ADD / Q /  POSSIBLE,/)
      REWIND CIN
2130  WRITE(ITOUT,8217) OT1(IBLOCK),OT2(IBLOCK)
8217  FORMAT(/,8H MODIFY ,2A8,1H:,/,
     @ 43H / LIST / ADD / CHANGE / DELETE / Q / R / ?)
      TAB(1,1)=LL
      TAB(1,2)=AA
      TAB(1,3)=CC
      TAB(1,4)=DD
      TAB(1,5)=QQ
      TAB(1,6)=RR
      TAB(2,1)=LLL
      TAB(2,2)=LA
      TAB(2,3)=LC
      TAB(2,4)=LD
      TAB(2,5)=LQ
      TAB(2,6)=LR
      I1=1
      I2=IDIFF
      CALL ANSNUM (TAB,6,NUM,2,X,KFLAG,12)
      IF(KFLAG.EQ.1.OR.KFLAG.GE.5) GOTO 2137
      DO 2135 I=1,10000
      READ(CIN,9100,END=2137) (C(L),L=1,9)
2135  WRITE(HDS,9100) (C(L),L=1,9)
2137  REWIND CIN
      ENDFILE HDS
      REWIND HDS
      GOTO (2140,2150,2170,2170,2000,5000),KFLAG
      GOTO 2130
2140  IF(IDIFF.LE.0) GOTO 2125
      IF(NUM(1).LE.0) GOTO 2141
      I1=NUM(1)
      IF(I1.GT.IDIFF) I1=IDIFF
      I2=NUM(2)
      IF(I2.GT.IDIFF) I2=IDIFF
      IF(I2.GE.I1) GOTO 2141
      I2=I1
      I1=1
2141  IH1=IBEGIN+I1-1
      DO 2142 I=1,IH1
2142  READ(CIN,9000) CHAR1
      IH1=IH1+1
      IH2=IBEGIN+I2
      DO 2143 I=IH1,IH2
      J=I-IBEGIN
      READ(CIN,9000) (IN(L),L=1,72)
2143  WRITE(ITOUT,9010) J,(IN(L),L=1,72)
      REWIND CIN
      GOTO 2130
2150  I1=IDIFF
      IF(NUM(1).LT.0.OR.NUM(1).GT.IDIFF) GOTO 2151
      I1=NUM(1)
2151  IH1=IBEGIN+I1
      DO 2152 I=1,IH1
      READ(HDS,9100) (C(L),L=1,9)
2152  WRITE(CIN,9100) (C(L),L=1,9)
      I=0
      IMAX=IDIFF-ICOM
      WRITE(ITOUT,8220) OT1(IBLOCK),OT2(IBLOCK)
8220  FORMAT(/,19H ADD NEW LINES FOR ,2A8,1H:)
2155  I=I+1
      WRITE(ITOUT,8222) I
8222  FORMAT(/,3H / ,I3,13H.LINE / Q / ?)
      READ(ITIN,9000) (IN(L),L=1,73)
      CALL ANSQ (IN,QFLAG,13)
      IF(QFLAG.EQ.1) GOTO 2160
      IF(QFLAG.LT.0) GOTO 6000
      IF(IN(1).NE.STAR) IMAX=IMAX+1
      IF(IMAX.GT.MAXL(IBLOCK)) GOTO 2157
      WRITE(CIN,9000) (IN(L),L=1,72)
      GOTO 2155
2157  WRITE(ITOUT,8225) WARN1,WARN2,MAXL(IBLOCK),OT1(IBLOCK),OT2(IBLOCK)
8225  FORMAT(//,1X,2A8,/,10H MORE THAN,I4,11H DATA LINES,
     @ 33H (COMMENT CARDS NOT COUNTED) FOR ,2A8,/,18H LAST LINE IGNORED)
2160  DO 2161 IH=1,10000
      READ(HDS,9100,END=2162) (C(L),L=1,9)
2161  WRITE(CIN,9100) (C(L),L=1,9)
2162  REWIND HDS
      ENDFILE CIN
      REWIND CIN
      I=I-1
      IDIFF=IDIFF+I
      ICOM=ICOM+I-IMAX
      ISTOP=IBEGIN+IDIFF
      GOTO 2130
2170  LCHA=.TRUE.
      IF(KFLAG.EQ.4) LCHA=.FALSE.
      IF(IDIFF.LE.0) GOTO 2125
      I1=NUM(1)
2171  IF(I1.GT.0.AND.I1.LE.IDIFF) GOTO 2190
      IF(IBLOCK.EQ.2.OR.IBLOCK.EQ.3.OR.IBLOCK.EQ.5) GOTO 2175
2172  WRITE(ITOUT,8230)
8230  FORMAT(/,12H WHICH LINE:,/,19H / LINE NO. / Q / ?)
      READ(ITIN,9000) (IN(L),L=1,73)
      CALL ANSQ (IN,QFLAG,14)
      IF(QFLAG.EQ.1) GOTO 2130
      IF(QFLAG.LT.0) GOTO 6000
      CALL INUM (IN,1,72,I1,KFLAG)
      IF(KFLAG.NE.0) GOTO 2172
      GOTO 2171
2175  WRITE(ITOUT,8232)
8232  FORMAT(/,15H IDENTIFY LINE:,/,15H / NAME / Q / ?)
      READ(ITIN,9000) (IN(L),L=1,73)
      KFLAG=0
      CALL ANSQ (IN,QFLAG,15)
      IF(QFLAG.EQ.1) GOTO 2130
      IF(QFLAG.LT.0) GOTO 6000
      CALL SEARCH (IN,IBEGIN,ISTOP,I1,KFLAG,100)
      IF(KFLAG.NE.0) GOTO 2000
      GOTO 2171
2190  IH1=IBEGIN+I1-1
      DO 2192 I=1,IH1
      READ(HDS,9100) (C(L),L=1,9)
2192  WRITE(CIN,9100) (C(L),L=1,9)
      READ(HDS,9000) (INH(L),L=1,72)
      WRITE(ITOUT,8241) (INH(L),L=1,72)
8241  FORMAT(/,10H OLD LINE:,/,1H ,72A1)
      IF(INH(1).NE.STAR) GOTO 2194
      ICOM=ICOM-1
      IF(INH(2).EQ.CC) GOTO 2194
      WRITE(ITOUT,8242) WARN1,WARN2
8242  FORMAT(/,2A8,/,13H INVALID LINE)
      ICOM=ICOM+1
2194  IDIFF=IDIFF-1
      IF(.NOT.LCHA) GOTO 2200
2196  WRITE(ITOUT,8244)
8244  FORMAT(/,24H / MODIFIED LINE / Q / ?)
      READ(ITIN,9000) (IN(L),L=1,73)
      IDIFF=IDIFF+1
      CALL ANSQ (IN,QFLAG,16)
      IF(QFLAG.EQ.1) GOTO 2199
      IF(QFLAG.LT.0) GOTO 6000
      IF(IN(1).NE.STAR) GOTO 2198
      ICOM=ICOM+1
      IF(IN(2).EQ.CC) GOTO 2198
      WRITE(ITOUT,8246) WARN1,WARN2,(IN(L),L=1,4)
8246  FORMAT(/,2A8,/,28H INVALID LINE; STARTS WITH: ,A1,9H REENTER:)
      ICOM=ICOM-1
      IDIFF=IDIFF-1
      GOTO 2196
2198  WRITE(CIN,9000) (IN(L),L=1,72)
      GOTO 2200
2199  WRITE(CIN,9000) (INH(L),L=1,72)
2200  DO 2202 I=1,10000
      READ(HDS,9100,END=2204) (C(L),L=1,9)
2202  WRITE(CIN,9100) (C(L),L=1,9)
      ISTOP=IBEGIN+IDIFF
2204  REWIND HDS
      ENDFILE CIN
      REWIND CIN
      GOTO 2130
2500  LRVAL=.FALSE.
      LLINE=.FALSE.
      TAB(1,1)=DD
      TAB(2,1)=QQ
      TAB(1,2)=LD
      TAB(2,2)=LQ
      REWIND CIN
      DO 2510 I=1,IBEGIN
      READ(CIN,9100) (C(L),L=1,9)
2510  WRITE(HDS,9100) (C(L),L=1,9)
      IF(IDIFF.EQ.0) GOTO 2514
      LRVAL=.TRUE.
      READ(CIN,9000) (IN(L),L=1,72)
      CALL RNUM (IN,1,72,RVAL,KFLAG)
      IF(KFLAG.EQ.0) GOTO 2515
      WRITE(ITOUT,8500) WARN1,WARN2
8500  FORMAT(/,2A8,/,31H VALUE IN INPUT DATASET INVALID,/)
      GOTO 2520
2514  WRITE(ITOUT,8502) OT1(IBLOCK),OT2(IBLOCK)
8502  FORMAT(/,22H NO CURRENT VALUE FOR ,2A8)
      GOTO 2520
2515  WRITE(ITOUT,8505) OT1(IBLOCK),OT2(IBLOCK),RVAL
8505  FORMAT(19H CURRENT VALUE FOR ,2A8,D21.12)
2520  IH=18
      NTAB=2
      IF(.NOT.LRVAL) GOTO 2521
      WRITE(ITOUT,8510)
8510  FORMAT(29H / NEW VALUE / DELETE / Q / ?)
      GOTO 2522
2521  IH=17
      TAB(1,1)=QQ
      TAB(2,1)=LQ
      NTAB=1
      WRITE(ITOUT,8511)
8511  FORMAT(20H / NEW VALUE / Q / ?)
2522  CALL ANSNUM (TAB,NTAB,NUM,-1,RVAL,KFLAG,IH)
      IF(KFLAG.EQ.-1) GOTO 2520
      IF(KFLAG.EQ.0) GOTO 2524
      IF(.NOT.LRVAL) KFLAG=KFLAG+1
      GOTO (2525,2551) , KFLAG
2524  LLINE=.TRUE.
      GOTO 2531
2525  IF(LRVAL) GOTO 2527
      GOTO 2520
2527  LLINE=.FALSE.
2531  IF(LLINE) WRITE(HDS,8022) RVAL
      DO 2533 I=1,10000
      READ(CIN,9100,END=2535) (C(L),L=1,9)
2533  WRITE(HDS,9100) (C(L),L=1,9)
2535  REWIND CIN
      ENDFILE HDS
      REWIND HDS
      DO 2540 I=1,10000
      READ(HDS,9100,END=2550) (C(L),L=1,9)
2540  WRITE(CIN,9100) (C(L),L=1,9)
2550  CONTINUE
      ENDFILE CIN
2551  REWIND CIN
      REWIND HDS
      GOTO 2000
2700  NBLOCK=KFLAG+1
      KFLAG=0
      LCHA=.FALSE.
      READ(CIN,9000) (IN(L),L=1,72)
      CALL RNUM (IN,1,72,EPS,KFLAG)
      IF(KFLAG.NE.0) GOTO 2750
      READ(CIN,9000) IN(1),IN(2)
      NBLOCK=NBLOCK+1
      IF(IN(1).NE.STAR.OR.IN(2).NE.DLIM(NBLOCK)) GOTO 2750
      READ(CIN,9000) (IN(L),L=1,72)
      CALL INUM (IN,1,72,ITP,KFLAG)
      IF(KFLAG.NE.0) GOTO 2750
      DO 2710 I=1,ITP
      READ(CIN,9000) (IN(L),L=1,72)
      CALL RNUM (IN,1,72,TP(I),KFLAG)
      IF(KFLAG.NE.0) GOTO 2750
2710  CONTINUE
      NBLOCK=NBLOCK+1
      READ(CIN,9000) IN(1),IN(2)
      IF(IN(1).NE.STAR.OR.IN(2).NE.DLIM(NBLOCK)) GOTO 2750
      READ(CIN,9000) (IN(L),L=1,72)
      CALL INUM (IN,1,72,IPRINT,KFLAG)
      IF(KFLAG.NE.0) GOTO 2750
      REWIND CIN
      GOTO 2800
2750  IF(KFLAG.EQ.0) GOTO 2760
      WRITE(ITOUT,8750) ERR1,ERR2,ITEXT(NBLOCK)
8750  FORMAT(/,2A8,/,24H INPUT DATASET INVALID; ,A8,8H MISSING,/,
     @ 61H (OR COMMENT CARD IN DATA FOR TEMP., GAS CONST. OR NUMERICAL ,
     @  5HINPUT)
      RETURN
2760  WRITE(ITOUT,8760) ERR1,ERR2
8760  FORMAT(/,2A8,/,
     @ 54H A NUMERICAL VALUE IN INPUT DATASET MISSING OR INVALID,/)
      RETURN
2800  WRITE(ITOUT,8800)
8800  FORMAT(/,24H MODIFY NUMERICAL INPUT:,/,13H / LIST / EPS,
     @55H / START-(T) / FINAL-(T) / OUT-(T) / IPRINT / Q / R / ?)
      TAB(1,1)=LL
      TAB(1,2)=EE
      TAB(1,3)=SS
      TAB(1,4)=FF
      TAB(1,5)=OO
      TAB(1,6)=II
      TAB(1,7)=QQ
      TAB(1,8)=RR
      TAB(2,1)=LLL
      TAB(2,2)=LE
      TAB(2,3)=LS
      TAB(2,4)=LF
      TAB(2,5)=LO
      TAB(2,6)=LI
      TAB(2,7)=LQ
      TAB(2,8)=LR
      CALL ANSNUM (TAB,8,NUM,0,X,KFLAG,19)
      IF(KFLAG.LT.0) GOTO 6000
      IFLAG=KFLAG
      GOTO (2810,2820,2830,2840,2850,2890,2990,2990) , IFLAG
      GOTO 2800
2810  WRITE(ITOUT,8810)
8810  FORMAT(//,35H CURRENT NUMERICAL DATA FOR LARKIN:,/)
      WRITE(ITOUT,8811) EPS
      WRITE(ITOUT,8812) TP(1)
      WRITE(ITOUT,8813) TP(ITP)
      WRITE(ITOUT,8814)
      WRITE(ITOUT,8815) IPRINT
8811  FORMAT(44H EPS (RELATIVE ACCURACY FOR SIMULATION):    ,D15.6)
8812  FORMAT(44H START-(T) (STARTING POINT FOR SIMULATION): ,D21.12)
8813  FORMAT(44H FINAL-(T) (FINAL POINT FOR SIMULATION):    ,D21.12)
8814  FORMAT(44H IPRINT (PRINT PARAMETER FOR ADDITIONAL     )
8815  FORMAT(44H         CHEMICAL OUTPUT):                  ,3X,I4)
      IF(ITP.LE.2) GOTO 2800
      WRITE(ITOUT,8817)
8817  FORMAT(/,26H ADDITIONAL OUTPUT POINTS:)
      IH=ITP-1
      DO 2812 I=2,IH
      J=I-1
2812  WRITE(ITOUT,8819) J,TP(I)
8819  FORMAT(8H OUT-(T),I2,3H:  ,D21.12)
      GOTO 2800
2820  WRITE(ITOUT,8820) EPS
      WRITE(ITOUT,8821)
8820  FORMAT(/,24H CURRENT VALUE FOR EPS: ,D13.6)
8821  FORMAT(20H / NEW VALUE / Q / ?)
      READ(ITIN,9000) (IN(L),L=1,73)
      CALL ANSQ (IN,QFLAG,20)
      IF(QFLAG.EQ.1) GOTO 2800
      IF(QFLAG.LT.0) GOTO 6000
      CALL RNUM (IN,1,72,EPS,KFLAG)
      IF(KFLAG.NE.0) GOTO 2820
      LCHA=.TRUE.
      GOTO 2800
2830  WRITE(ITOUT,8830) TP(1)
      WRITE(ITOUT,8821)
8830  FORMAT(/,30H CURRENT VALUE FOR START-(T): ,D21.12)
      READ(ITIN,9000) (IN(L),L=1,73)
      CALL ANSQ (IN,QFLAG,20)
      IF(QFLAG.EQ.1) GOTO 2800
      IF(QFLAG.LT.0) GOTO 6000
      CALL RNUM (IN,1,72,TP(1),KFLAG)
      IF(KFLAG.NE.0) GOTO 2830
      LCHA=.TRUE.
      GOTO 2880
2840  WRITE(ITOUT,8840) TP(ITP)
      WRITE(ITOUT,8821)
8840  FORMAT(/,30H CURRENT VALUE FOR FINAL-(T): ,D21.12)
      READ(ITIN,9000) (IN(L),L=1,73)
      CALL ANSQ (IN,QFLAG,20)
      IF(QFLAG.EQ.1) GOTO 2800
      IF(QFLAG.LT.0) GOTO 6000
      CALL RNUM (IN,1,72,TP(ITP),KFLAG)
      IF(KFLAG.NE.0) GOTO 2840
      LCHA=.TRUE.
      GOTO 2880
2850  IF(ITP.LE.2) GOTO 2861
      J=1
      TAB(1,1)=DD
      TAB(1,2)=QQ
      TAB(2,1)=LD
      TAB(2,2)=LQ
      ITP=ITP-1
2851  J=J+1
      JH=J-1
2852  WRITE(ITOUT,8850) JH,TP(J)
      WRITE(ITOUT,8851)
8850  FORMAT(9H OUT-(T) ,I2,4H :  ,D21.12)
8851  FORMAT(29H / NEW VALUE / DELETE / Q / ?)
      CALL ANSNUM (TAB,2,NUM,-1,TP(J),KFLAG,21)
      GOTO (2858,2855) , KFLAG
      IF(KFLAG.EQ.-1) GOTO 2852
2855  IF(J.LT.ITP) GOTO 2851
      GOTO 2860
2858  DO 2859 L=J,ITP
2859  TP(L)=TP(L+1)
      ITP=ITP-1
      J=J-1
      IF(J.LT.ITP) GOTO 2851
2860  ITP=ITP+1
2861  WRITE(ITOUT,8860)
8860  FORMAT(48H ADD (OPTIONAL) OUTPUT POINTS; Q  STOPS EDITING:)
      IMAX=MAXL(9)+1
      IH=ITP+1
      DO 2870 J=IH,IMAX
      ITP=J-1
      JH=J-2
2865  WRITE(ITOUT,8180) JH
8180  FORMAT(/,3H / ,I3,15H. VALUE / Q / ?)
      READ(ITIN,9000) (IN(L),L=1,73)
      CALL ANSQ (IN,QFLAG,22)
      IF(QFLAG.EQ.1) GOTO 2880
      IF(QFLAG.LT.0) GOTO 6000
      CALL RNUM (IN,1,72,TP(J),KFLAG)
      IF(KFLAG.NE.0) GOTO 2865
2870  CONTINUE
      WRITE(ITOUT,8190)
8190  FORMAT(/,2A8,/,36H TOO MANY POINTS; LAST VALUE IGNORED)
2880  ITEST=ITP
2881  JM=ITEST-1
      ITEST=0
      DO 2885 J=1,JM
      IF(TP(J).LE.TP(J+1)) GOTO 2885
      V=TP(J)
      TP(J)=TP(J+1)
      TP(J+1)=V
      ITEST=J
2885  CONTINUE
      IF(ITEST.NE.0) GOTO 2881
      LCHA=.TRUE.
      GOTO 2800
2890  WRITE(ITOUT,8890) IPRINT
8890  FORMAT(/,27H CURRENT VALUE FOR IPRINT: ,I5,/,
     @ 20H / NEW VALUE / Q / ?)
      READ(ITIN,9000) (IN(L),L=1,73)
      CALL ANSQ (IN,QFLAG,20)
      IF(QFLAG.EQ.1) GOTO 2800
      IF(QFLAG.LT.0) GOTO 6000
      CALL INUM (IN,1,72,IPRINT,KFLAG)
      IF(KFLAG.NE.0) GOTO 2820
      LCHA=.TRUE.
      GOTO 2800
2990  IF(LCHA) GOTO 2991
      IF(IFLAG.EQ.8) GOTO 5000
      GOTO 2000
2991  IH=IBEGIN+1
      DO 2992 I=1,IH
2992  READ(CIN,9000) CHAR1
      WRITE(CIN,8022) EPS
      WRITE(CIN,8023)
      WRITE(CIN,8024) ITP
      DO 2994 J=1,ITP
2994  WRITE(CIN,8022) TP(J)
      WRITE(CIN,8025)
      WRITE(CIN,8024) IPRINT
      ENDFILE CIN
      REWIND CIN
      IF(IFLAG.EQ.8) GOTO 5000
      GOTO 2000
3000  ITOUT=POUT
4000  LLINE=.TRUE.
      DO 4100 I=1,10000
      READ(CIN,9001,END=4200) (IN(L),L=1,72)
      IF(IN(1).NE.STAR) GOTO 4099
      IF(IN(2).EQ.CC) GOTO 4098
      J=1
      IF(IN(2).EQ.DLIM(1)) WRITE(ITOUT,8900)
8900  FORMAT(///,45H *****  LIST OF CURRENT INPUT DATA FOR LARKIN,
     @ 7H  *****,/,45H        -------------------------------------,///,
     @ 16H ***  HEAD:  ***,/)
      IF(IN(2).EQ.DLIM(2)) WRITE(ITOUT,8901)
8901  FORMAT(///,24H ***  ELEMENT LIST:  ***,/)
      IF(IN(2).EQ.DLIM(3)) WRITE(ITOUT,8909)
8909  FORMAT(///,24H ***  SPECIES LIST:  ***,/)
      IF(IN(2).EQ.DLIM(4)) WRITE(ITOUT,8902)
8902  FORMAT(///,27H ***  REACTION SYSTEM:  ***,/)
      IF(IN(2).EQ.DLIM(5)) WRITE(ITOUT,8904)
8904  FORMAT(///,34H ***  INITIAL CONCENTRATIONS:  ***,/)
      IF(IN(2).EQ.DLIM(6)) WRITE(ITOUT,8903)
      IF(IN(2).EQ.DLIM(6)) LLINE=.FALSE.
8903  FORMAT(///,23H ***  TEMPERATURE:  ***,/)
      IF(IN(2).EQ.DLIM(7)) WRITE(ITOUT,8910)
      IF(IN(2).EQ.DLIM(7)) LLINE=.FALSE.
8910  FORMAT(///,34H ***  UNIVERSAL GAS CONSTANT:  ***,/)
      IF(IN(2).EQ.DLIM(8)) WRITE(ITOUT,8905)
8905  FORMAT(///,27H ***  NUMERICAL INPUT:  ***)
      IF(IN(2).EQ.DLIM(9)) WRITE(ITOUT,8906)
8906  FORMAT(/,35H ***  EPS (RELATIVE ACCURACY):  ***,/)
      IF(IN(2).EQ.DLIM(10)) WRITE(ITOUT,8907)
8907  FORMAT(///,25H ***  OUTPUT POINTS:  ***,/)
      IF(IN(2).EQ.DLIM(11)) WRITE(ITOUT,8908)
8908  FORMAT(///,27H ***  PRINT PARAMETER:  ***,/)
      GOTO 4100
4098  WRITE(ITOUT,9002) (IN(L),L=1,72)
      GOTO 4100
4099  IF(.NOT.LLINE) GOTO 4098
      WRITE(ITOUT,9003) J,(IN(L),L=1,72)
      J=J+1
4100  CONTINUE
C4200  ITOUT=ITIN
4200  REWIND CIN
      GOTO 10
5000  KFLAG=0
      REWIND CIN
      REWIND HDS
      RETURN
6000  KFLAG=-1
      REWIND CIN
      REWIND HDS
      RETURN
9000  FORMAT(73A1)
9001  FORMAT(72A1)
9002  FORMAT(3X,72A1)
9003  FORMAT(I4,1X,72A1)
9010  FORMAT(3H L.,I3,2H: ,72A1)
9100  FORMAT(9A8)
      END
      SUBROUTINE ANSQ (KEY,KFLAG,IHELP)
      INTEGER*2 KEY(80),MKEY,BLANK,Q,U,I,T
      INTEGER IHELP
      INTEGER ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT,INFDAT
      COMMON / LUNIT / ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT
      COMMON / INFORM / IIHELP,INFDAT
      DATA BLANK /1H / , Q /1HQ/ , U /1HU/ , I /1HI/ , T /1HT/
      DATA LQ /1Hq/ , LU /1Hu/ , LI /1Hi/ , LT /1Ht/
      KFLAG=1
      K=0
1     K=K+1
      DO 2 I=1,72
      M=I
      IF(KEY(M).NE.BLANK) GOTO 10
2     CONTINUE
      GOTO 20
10    MKEY=KEY(M)
      IF(KEY(73).NE.BLANK) GOTO 50
      KEY(73)=BLANK
      IF(MKEY.NE.Q.AND.MKEY.NE.LQ) GOTO 40
      MKEY=KEY(M+1)
      IF(MKEY.EQ.BLANK) GOTO 30
      IF(MKEY.NE.U.AND.MKEY.NE.LU) GOTO 40
      M=M+1
      MKEY=KEY(M)
      IF(MKEY.EQ.BLANK) GOTO 30
      IF(MKEY.NE.I.AND.MKEY.NE.LI) GOTO 40
      M=M+1
      MKEY=KEY(M)
      IF(MKEY.EQ.BLANK) GOTO 30
      IF(MKEY.NE.T.AND.MKEY.NE.LT) GOTO 40
      M=M+1
      IF(KEY(M).NE.BLANK) GOTO 40
30    KFLAG=1
      RETURN
40    KFLAG=0
      RETURN
20    CALL HELP (IHELP)
      WRITE(ITOUT,8000)
      READ(ITIN,9000) (KEY(L),L=1,73)
      IF(K.LT.5) GOTO 1
      WRITE(ITOUT,8100)
      KFLAG=-1
      RETURN
50    WRITE(ITERM,8200) (KEY(L),L=63,72)
      KFLAG=0
      RETURN
9000  FORMAT(73A1)
8000  FORMAT(//,24H ENTER NOW YOUR ANSWER: ,20H  / INPUT LINE / Q /,/)
8100  FORMAT(//,18H TOO MANY ATTEMPTS)
8200  FORMAT(/,27H LINE TRUNCATED AFTER : ...,10A1,/,
     @         24H ENTER CONTINUATION CARD)
      END
      SUBROUTINE SEARCH (KEY,IBEGIN,ISTOP,I1,KFLAG,IHELP)
      INTEGER*2 KEY(80),IN(80),BLANK,CHAR1
      INTEGER ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT,INFDAT
      COMMON / LUNIT / ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT
      COMMON / INFORM / IIHELP,INFDAT
      DATA BLANK /1H /
      K=0
      I1=0
      DO 5 I=1,IBEGIN
5     READ(CIN,9000) CHAR1
1     DO 10 I=1,72
      M1=I
      IF(KEY(I).NE.BLANK) GOTO 11
10    CONTINUE
      CALL HELP(IHELP)
      WRITE(ITOUT,8000)
      READ(ITIN,9000) (KEY(L),L=1,73)
      K=K+1
      IF(K.LT.10) GOTO 1
      WRITE(ITOUT,8100)
      GOTO 100
11    DO 12 I=M1,72
      M11=I
      IF(KEY(I).EQ.BLANK) GOTO 13
12    CONTINUE
13    ME=M11-1
14    READ(CIN,9000) (IN(L),L=1,72)
      I1=I1+1
      DO 20 I=1,72
      M2=I
      IF(IN(I).NE.BLANK) GOTO 21
20    CONTINUE
      WRITE(ITOUT,8400)
      WRITE(ITOUT,8200)
      GOTO 100
21    DO 30 I=M1,ME
      IF(KEY(I).NE.IN(M2)) GOTO 31
30    M2=M2+1
      IF(IN(M2).EQ.BLANK) GOTO 32
31    IH1=IBEGIN+I1
      IF(IH1.LT.ISTOP) GOTO 14
      WRITE(ITOUT,8300)
      GOTO 100
32    REWIND CIN
      KFLAG=0
      RETURN
100   KFLAG=-1
      REWIND CIN
      RETURN
9000  FORMAT(73A1)
8000  FORMAT(//,24H ENTER NOW YOUR ANSWER: ,14H  / NAME / Q /)
8100  FORMAT(//18H TOO MANY ATTEMPTS)
8200  FORMAT(//,22H INPUT DATASET INVALID)
8300  FORMAT(/,15H NAME NOT FOUND)
8400  FORMAT(/,14H *** ERROR ***,/,28H BLANK LINE IN INPUT DATASET)
      END
 
