      SUBROUTINE NUMOUT (MAXSP,MAXEQ,MAXEL,NRW,RW,KFLAG)
      REAL RW(NRW)
      N2=MAXSP+1
      N3=N2+MAXSP
      N4=N3+MAXSP
      N5=N4+MAXSP
      N6=N5+MAXEL
      N7=N6+MAXEL
      CALL LIST (MAXSP,MAXEQ,MAXEL,RW(1),RW(N2),RW(N3),RW(N4),RW(N5),
     @           RW(N6),RW(N7),KFLAG)
      RETURN
      END
      SUBROUTINE LIST (MAXSP,MAXEQ,MAXEL,SPN1,SPN2,SPN3,SPATW,ELN1,ELN2,
     @                 ELATW,KFLAG)
      DOUBLE PRECISION XX
      REAL SPN1(MAXSP),SPN2(MAXSP),SPN3(MAXSP),SPATW(MAXSP),ELN1(MAXEL),
     @     ELN2(MAXEL),ELATW(MAXEL)
      REAL C(1000),RK(1000)
      REAL TP(50),T,SUM,CHAR
      INTEGER LOUT
      INTEGER ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT,INFDAT
      INTEGER NUM(2),STD(10),STDMAX
      INTEGER*2 TAB(2,10),AC,CC,EC,FC,IC,KC,OC,QC,RC,SC
      INTEGER*2 AL,CL,EL,FL,IL,KL,OL,QL,RL,SL
      LOGICAL LMW
      COMMON / LUNIT / ITIN,ITOUT,CIN,HDS,POUT,SIN,DOUT
      COMMON / INFORM / IHELP,INFDAT
      DATA AC/1HA/ , CC/1HC/ , EC/1HE/ , FC/1HF/ , IC/1HI/ , KC/1HK/ ,
     @     OC/1HO/ , QC/1HQ/ , RC/1HR/ , SC/1HS/
      DATA AL/1Ha/ , CL/1Hc/ , EL/1He/ , FL/1Hf/ , IL/1Hi/ , KL/1Hk/ ,
     @     OL/1Ho/ , QL/1Hq/ , RL/1Hr/ , SL/1Hs/
      REWIND DOUT
      LOUT=ITOUT
      IF(KFLAG.LT.10) GOTO 10
      LOUT=POUT
      KFLAG=KFLAG-10
10    CONTINUE
      KF=KFLAG
      DO 100 I=1,MAXSP
100   SPATW(I)=0.
      DO 110 I=1,MAXEL
110   ELATW(I)=0.
      STDMAX=4
      STD(1)=2
      STD(2)=7
      STD(3)=3
      STD(4)=6
      IOP=1
      IND=IOP
      WRITE(LOUT,8100)
8100  FORMAT(//,19X,15HSIMULATION DATA,/,19X,15(1H-))
      READ(DOUT,8101) IHEAD
      IH=IHEAD*6
8101  FORMAT(15X,I3)
      IF(IH.GT.0) READ(DOUT,8102) (SPN1(L),SPN2(L),SPN3(L),L=1,IH)
8102  FORMAT(1X,18A4)
      WRITE(LOUT,8105)
8105  FORMAT(//,19X,13HACTUAL MODEL:,/,19X,13(1H-),/)
      IF(IH.GT.0) WRITE(LOUT,8102) (SPN1(L),SPN2(L),SPN3(L),L=1,IH)
      READ(DOUT,8110) CHAR
      READ(DOUT,8110) CHAR
      READ(DOUT,8106) NSP,NCEQ,IEL
      READ(DOUT,8110) CHAR
8106  FORMAT(5X,I6,7X,I6,6X,I6)
      IF(NSP.GT.MAXSP) GOTO 6000
      IF(NCEQ.GT.MAXEQ) GOTO 6000
      IF(IEL.GT.MAXEL) GOTO 6000
      READ(DOUT,8110) CHAR
      READ(DOUT,8107) ITPMAX
      READ(DOUT,8108) (TP(L),L=1,ITPMAX)
      READ(DOUT,8110) CHAR
8107  FORMAT(8X,I3)
8108  FORMAT(3(1X,D21.12,1X))
      IF(IEL.LE.0) GOTO 1400
      READ(DOUT,8110) CHAR
      READ(DOUT,8111) (ELN1(L),ELN2(L),L=1,IEL)
8111  FORMAT(7(1X,2A4,1X))
      READ(DOUT,8110) CHAR
      READ(DOUT,8110) CHAR
      READ(DOUT,8110) CHAR
      READ(DOUT,8109) (RK(L),L=1,IEL)
      READ(DOUT,8110) CHAR
8109  FORMAT(5(1X,D13.7,1X))
      DO 1420 I=1,IEL
1420  ELATW(I)=RK(I)
1400  CONTINUE
      READ(DOUT,8110) CHAR
8110  FORMAT(A4)
      READ(DOUT,8112) (SPN1(L),SPN2(L),SPN3(L),L=1,NSP)
8112  FORMAT(5(1X,3A4,1X))
      READ(DOUT,8110) CHAR
      IF(IEL.LE.0) GOTO 1460
      READ(DOUT,8110) CHAR
      READ(DOUT,8110) CHAR
      READ(DOUT,8109) (RK(L),L=1,NSP)
      READ(DOUT,8110) CHAR
      DO 1450 I=1,NSP
1450  SPATW(I)=RK(I)
1460  CONTINUE
      LMW=.TRUE.
      DO 1470 I=1,NSP
1470  IF(SPATW(I).EQ.0.) LMW=.FALSE.
      ILMAX=STDMAX
      IF(KF.EQ.0) GOTO 1600
1500  WRITE(ITOUT,9000)
9000  FORMAT(//,20H SELECT OUTPUT DATA:,/,1X,19(1H-),/,
     @61H FIXED STANDARD OUTPUT(INFO, KIN.PAR., MOLAR CONC., I. RATES)
     @,/,25H ELEMENT AND SPECIES INFO,/,29H CONCENTRATIONS (MOLAR CONC.)
     @,/,28H SUM OF MOLAR CONCENTRATIONS,/,
     @6H RATES,/,17H INTEGRATED RATES,/,19H KINETIC PARAMETERS,/,
     @55H OPTIONS (CONVERSION MOLAR CONC. TO MASS/MOLE FRACTION))
      WRITE(ITOUT,9001)
9001  FORMAT(5H   OR,/,
     @49H ALTER OUTPUT ALLOCATION ( TERMINAL <-> PRINTER ),/,5H   OR,/,
     @5H QUIT)
      TAB(1,1)=FC
      TAB(1,2)=EC
      TAB(1,3)=CC
      TAB(1,4)=SC
      TAB(1,5)=RC
      TAB(1,6)=IC
      TAB(1,7)=KC
      TAB(1,8)=OC
      TAB(1,9)=AC
      TAB(1,10)=QC
      TAB(2,1)=FL
      TAB(2,2)=EL
      TAB(2,3)=CL
      TAB(2,4)=SL
      TAB(2,5)=RL
      TAB(2,6)=IL
      TAB(2,7)=KL
      TAB(2,8)=OL
      TAB(2,9)=AL
      TAB(2,10)=QL
      IND=IOP
      CALL ANSNUM (TAB,10,NUM,1,XX,IFLAG,100)
      IF(NUM(1).GE.0.AND.NUM(1).LE.2) IND=NUM(1)
      ILMAX=1
      IF(IFLAG.EQ.1) ILMAX=STDMAX
1600  DO 5000 ILOOP=1,ILMAX
      IF(ILMAX.NE.1) IFLAG=STD(ILOOP)
      REWIND DOUT
      GOTO (6050,2000,2100,2200,2300,2400,2500,3000,4000,7000) , IFLAG
      GOTO 6050
2000  IF(IEL.GT.0) GOTO 2011
      WRITE(LOUT,8201)
8201  FORMAT(//,38H NO ELEMENTS IN CHEMICAL INPUT DEFINED,/)
      GOTO 2012
2011  WRITE(LOUT,8202)
      WRITE(LOUT,8203) (L,ELN1(L),ELN2(L),ELATW(L),L=1,IEL)
8202  FORMAT(//,26H ELEMENT AND SPECIES INFO:,/,
     @       34H  NO    ELEMENT      ATOMIC WEIGHT)
8203  FORMAT(I4,4X,2A4,5X,E12.6)
2012  WRITE(LOUT,8204)
8204  FORMAT(//,41H  NO    SPECIES          MOLECULAR WEIGHT)
      WRITE(LOUT,8205) (L,SPN1(L),SPN2(L),SPN3(L),SPATW(L),L=1,NSP)
8205  FORMAT(I4,4X,3A4,5X,E12.6)
      GOTO 5000
2100  CONTINUE
      CALL NLCONC (DOUT,T,C,NSP,KFOUND)
      IF(KFOUND.LT.0) GOTO 2180
      WRITE(LOUT,8211) T
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
8211  FORMAT(//,21H CONCENTRATIONS AT T=,E14.6,/)
8212  FORMAT(1X,3A4,E14.6,15X,3A4,E14.6)
      TEND=TP(ITPMAX)
      I=2
2150  CONTINUE
      CALL NLCONC (DOUT,T,C,NSP,KFOUND)
      IF(KFOUND.LT.0) GOTO 2180
      IF(T.EQ.TEND) GOTO 2160
      IF(IND.EQ.0) GOTO 2150
      IF(IND.EQ.2) GOTO 2155
      IF(T.NE.TP(I)) GOTO 2150
      I=I+1
2155  WRITE(LOUT,8211) T
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
      GOTO 2150
2160  WRITE(LOUT,8211) T
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
      GOTO 5000
2180  WRITE(LOUT,8218)
8218  FORMAT(/,36H NO DATA FOR CONCENTRATION AVAILABLE)
      GOTO 5000
2200  CONTINUE
      CALL NLSUMC (DOUT,T,SUM,KFOUND)
      IF(KFOUND.LT.0) GOTO 2280
      WRITE(LOUT,8220)
8220  FORMAT(//,29H SUM OF MOLAR CONCENTRATIONS:,/,20X,1HT,21X,3HSUM,/)
      WRITE(LOUT,8221) T,SUM
8221  FORMAT(14X,E14.7,8X,E14.7)
      TEND=TP(ITPMAX)
      I=2
2250  CONTINUE
      CALL NLSUMC (DOUT,T,SUM,KFOUND)
      IF(KFOUND.LT.0) GOTO 2280
      IF(T.EQ.TEND) GOTO 2260
      IF(IND.EQ.0) GOTO 2250
      IF(IND.EQ.2) GOTO 2255
      IF(T.NE.TP(I)) GOTO 2250
      I=I+1
2255  WRITE(LOUT,8221) T,SUM
      GOTO 2250
2260  WRITE(LOUT,8221) T,SUM
      GOTO 5000
2280  WRITE(LOUT,8228)
8228  FORMAT(/,43H NO DATA FOR SUM OF CONCENTRATION AVAILABLE)
      GOTO 5000
2300  CONTINUE
      CALL NLRATE (DOUT,T,RK,NCEQ,KFOUND)
      IF(KFOUND.LT.0) GOTO 2380
      WRITE(LOUT,8231) T
      WRITE(LOUT,8232) (L,RK(L),L=1,NCEQ)
8231  FORMAT(//,12H RATES AT T=,E14.6,/,22H EQUATION        VALUE,
     @       13X,22H EQUATION        VALUE)
8232  FORMAT(4X,I5,5X,E12.6,13X,I5,5X,E12.6)
      TEND=TP(ITPMAX)
      I=2
2350  CONTINUE
      CALL NLRATE (DOUT,T,RK,NCEQ,KFOUND)
      IF(KFOUND.LT.0) GOTO 2380
      IF(T.EQ.TEND) GOTO 2360
      IF(IND.EQ.0) GOTO 2350
      IF(IND.EQ.2) GOTO 2355
      IF(T.NE.TP(I)) GOTO 2350
      I=I+1
2355  WRITE(LOUT,8231) T
      WRITE(LOUT,8232) (L,RK(L),L=1,NCEQ)
      GOTO 2350
2360  WRITE(LOUT,8231) T
      WRITE(LOUT,8232) (L,RK(L),L=1,NCEQ)
      GOTO 5000
2380  WRITE(LOUT,8238)
8238  FORMAT(/,28H NO DATA FOR RATES AVAILABLE)
      GOTO 5000
2400  CONTINUE
      CALL NLIRAT (DOUT,T,RK,NCEQ,KFOUND)
      IF(KFOUND.LT.0) GOTO 2480
      WRITE(LOUT,8241) T
      WRITE(LOUT,8232) (L,RK(L),L=1,NCEQ)
8241  FORMAT(//,23H INTEGRATED RATES AT T=,E14.6,/,
     @       22H EQUATION        VALUE,13X,22H EQUATION        VALUE)
      TEND=TP(ITPMAX)
      I=2
2450  CONTINUE
      CALL NLIRAT (DOUT,T,RK,NCEQ,KFOUND)
      IF(KFOUND.LT.0) GOTO 2480
      IF(T.EQ.TEND) GOTO 2460
      IF(IND.EQ.0) GOTO 2450
      IF(IND.EQ.2) GOTO 2455
      IF(T.NE.TP(I)) GOTO 2450
      I=I+1
2455  WRITE(LOUT,8241) T
      WRITE(LOUT,8232) (L,RK(L),L=1,NCEQ)
      GOTO 2450
2460  WRITE(LOUT,8241) T
      WRITE(LOUT,8232) (L,RK(L),L=1,NCEQ)
      GOTO 5000
2480  WRITE(LOUT,8248)
8248  FORMAT(/,39H NO DATA FOR INTEGRATED RATES AVAILABLE)
      GOTO 5000
2500  CONTINUE
      CALL NLKIPA (DOUT,RK,NCEQ,KFOUND)
      IF(KFOUND.LT.0) GOTO 2580
      WRITE(LOUT,8250)
8250  FORMAT(//,20H KINETIC PARAMETERS:,/,22H EQUATION        VALUE,
     @       13X,22H EQUATION        VALUE)
      WRITE(LOUT,8232) (I,RK(I),I=1,NCEQ)
      GOTO 5000
2580  WRITE(LOUT,8252)
8252  FORMAT(/,41H NO DATA FOR KINETIC PARAMETERS AVAILABLE)
      GOTO 5000
3000  CONTINUE
3200  WRITE(ITOUT,9003)
9003  FORMAT(/,15H CHOOSE OPTION:,/,
     @58H CONVERT MOLAR CONCENTRATIONS IN MOLE FRACTIONS   ENTER: O,/,
     @57H CONVERT MOLAR CONCENTRATIONS IN MASS FRACTIONS  ENTER: A,/,
     @47H RETURN  ( LEAVE SUBSYSTEM 'NUMERICAL OUTPUT' ),/,
     @5H QUIT)
      TAB(1,1)=OC
      TAB(1,2)=AC
      TAB(1,3)=RC
      TAB(1,4)=QC
      TAB(2,1)=OL
      TAB(2,2)=AL
      TAB(2,3)=RL
      TAB(2,4)=QL
      IND=IOP
      CALL ANSNUM (TAB,4,NUM,1,XX,JFLAG,100)
      IF(NUM(1).GE.0.AND.NUM(1).LE.2) IND=NUM(1)
      REWIND DOUT
      GOTO (3300,3400,7000,5000) , JFLAG
      GOTO 6050
3300  CONTINUE
      CALL NLCONC (DOUT,T,C,NSP,KFOUND)
      IF(KFOUND.LT.0) GOTO 3380
      CALL NLSUMC (DOUT,T,SUM,KFOUND)
      IF(KFOUND.LT.0) GOTO 3380
      DO 3310 K=1,NSP
3310  C(K)=C(K)/SUM
      WRITE(LOUT,8331) T
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
8331  FORMAT(//,21H MOLE FRACTIONS AT T=,E14.6,/)
      TEND=TP(ITPMAX)
      I=2
3350  CONTINUE
      CALL NLCONC (DOUT,T,C,NSP,KFOUND)
      IF(KFOUND.LT.0) GOTO 3380
      CALL NLSUMC (DOUT,T,SUM,KFOUND)
      IF(KFOUND.LT.0) GOTO 3380
      IF(T.EQ.TEND) GOTO 3360
      IF(IND.EQ.0) GOTO 3350
      IF(IND.EQ.2) GOTO 3355
      IF(T.NE.TP(I)) GOTO 3350
      I=I+1
3355  WRITE(LOUT,8331) T
      DO 3356 K=1,NSP
3356  C(K)=C(K)/SUM
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
      GOTO 3350
3360  WRITE(LOUT,8331) T
      DO 3370 K=1,NSP
3370  C(K)=C(K)/SUM
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
      GOTO 3200
3380  WRITE(LOUT,8218)
      GOTO 3200
3400  IF(.NOT.LMW) GOTO 3900
      CALL NLCONC (DOUT,T,C,NSP,KFOUND)
      IF(KFOUND.LT.0) GOTO 3380
      SUM=0.
      DO 3410 K=1,NSP
      C(K)=C(K)*SPATW(K)
3410  SUM=SUM+C(K)
      DO 3411 K=1,NSP
3411  C(K)=C(K)/SUM
      WRITE(LOUT,8431) T
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
8431  FORMAT(//,21H MASS FRACTIONS AT T=,E14.6,/)
      TEND=TP(ITPMAX)
      I=2
3450  CONTINUE
      CALL NLCONC (DOUT,T,C,NSP,KFOUND)
      IF(KFOUND.LT.0) GOTO 3380
      SUM=0.
      IF(T.EQ.TEND) GOTO 3460
      IF(IND.EQ.0) GOTO 3450
      IF(IND.EQ.2) GOTO 3455
      IF(T.NE.TP(I)) GOTO 3450
      I=I+1
3455  WRITE(LOUT,8431) T
      DO 3456 K=1,NSP
      C(K)=C(K)*SPATW(K)
3456  SUM=SUM+C(K)
      DO 3457 K=1,NSP
3457  C(K)=C(K)/SUM
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
      GOTO 3450
3460  WRITE(LOUT,8431) T
      DO 3470 K=1,NSP
      C(K)=C(K)*SPATW(K)
3470  SUM=SUM+C(K)
      DO 3471 K=1,NSP
3471  C(K)=C(K)/SUM
      WRITE(LOUT,8212) (SPN1(L),SPN2(L),SPN3(L),C(L),L=1,NSP)
      GOTO 3200
3900  WRITE(LOUT,8319)
8319  FORMAT(//,53H ZERO MOLECULAR WEIGHT FOUND, CONVERSION NOT POSSIBLE
     @       ,/,46H ENTER COMPLETE ELEMENT ATOMIC WEIGHT LIST AND,/,
     @       51H SPECIES ELEMENT COMPOSITION LIST AS CHEMICAL INPUT)
      GOTO 3200
4000  IF(LOUT.NE.POUT) GOTO 4100
      LOUT=ITOUT
      GOTO 5000
4100  LOUT=POUT
5000  CONTINUE
      IF(KF.NE.0) GOTO 1500
      GOTO 7000
6000  WRITE(ITOUT,9990)
9990  FORMAT(//,36H ERROR: MAXIMUM DIMENSIONS EXHAUSTED)
      GOTO 6099
6050  WRITE(ITOUT,9991)
9991  FORMAT(//,51H ERROR: POSSIBLY WRONG DEFAULTS FOR STANDARD OUTPUT)
6099  KFLAG=-1
      REWIND DOUT
      RETURN
7000  REWIND DOUT
      KFLAG=0
      RETURN
      END
      SUBROUTINE NLSUMC (NF,T,SUM,KFOUND)
      REAL T,SUM
      REAL STRING,CHAR
      DATA STRING/4H&SUM/
10    CONTINUE
      READ(NF,9000,END=20) CHAR
      IF(CHAR.NE.STRING) GOTO 10
      READ(NF,9100) T,SUM
      KFOUND=1
      RETURN
20    CONTINUE
      KFOUND=-1
      RETURN
9000  FORMAT(1X,A4)
9100  FORMAT(3X,D21.12,6X,D13.7)
      END
      SUBROUTINE NLKIPA (NF,RK,NCEQ,KFOUND)
      REAL RK(NCEQ)
      REAL STRING,CHAR
      DATA STRING/4H&KIP/
10    CONTINUE
      READ(NF,9000,END=20) CHAR
      IF(CHAR.NE.STRING) GOTO 10
      READ(NF,9000) CHAR
      READ(NF,9100) (RK(L),L=1,NCEQ)
      KFOUND=1
      RETURN
20    CONTINUE
      KFOUND=-1
      RETURN
9000  FORMAT(1X,A4)
9100  FORMAT(5(1X,D13.7,1X))
      END
 
