      subroutine PRCHEM
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
      include 'INPAR.INC'
      include 'LOCAL1.INC'
      include 'LOCAL2.INC'
      integer I,INUNIT,J,K,EOF,LFIRST,LLAST,III,IV,VRAIL,I1,I2,ITAB
     &,         IMBED
      logical IONS
      character CCHAR(2)*1, IOUT(6)*2, MSSAGE(4)*64, OUTLIN(4)*64
      character KOUT*2, NAME1(4,4)*7
      character REQFMT*41
      data REQFMT/'(1X,''Please enter Yes, No, or Quit-> ''  )'/
      data CCHAR/'1','0'/, IOUT/'+1','+2','+3','-1','-2','-3'/
      data NAME1 /' KAH:  ',' KBH:  ',' KBACW:',' K1O2: ',
     &            ' EAH:  ',' EBH:  ',' QTBAW:',' EK1O2:',
     &            ' KNH:  ',' KRED: ',' KBACS:',' KOX:  ',
     &            ' ENH:  ',' ERED: ',' QTBAS:',' EOX:  '/
      data MSSAGE/
     &' *** Reactivity of dissolved species: SET via "entry(I, J,KK)"  '
     &,
     &' *** Reactivity of solids-sorbed species:     "entry(I, J,KK)"  '
     &,
     &' *** Reactivity of "DOC"-complexed species:   "entry(I, J,KK)"  '
     &,
     &' *** Reactivity of biosorbed species:         "entry(I, J,KK)"  '
     &/
      REQFMT(39:40) = CRSTOP(MACHNO)
      INUNIT = TTYIN(MACHNO)
      if (BATCH.eq.0) then
         LFIRST = 1
         LLAST = KCHEM
      else
         LFIRST = MCHEMG
         LLAST = MCHEMG
      endif
      do 340 K = LFIRST, LLAST
         III = VRAIL(CHEMNA(1,K))
         write (KOUT,5000) K
5000     format (I2)
         if (KOUT(1:1).eq.' ') KOUT(1:1) = '0'
         if (SPFLGG(1,K).eq.0) SPFLGG(1,K) = 1
         IONS = .false.
         do 100 I = 2, 7
            if (SPFLGG(I,K).eq.1) IONS = .true.
100      continue
         if (MWTG(K).gt.0.0) go to 110
         IFLAG = 8
         write (TTYOUT(MACHNO),5010) K,MWTG(K),(CHEMNA(IV,K),IV=1,III)
5010  format (' Molecular weight of Chemical in ADB #',I2,' = ',1PG8.1/ 
     &1X,50A1/' Molecular weight must be specified to RUN an analysis.')
110      continue
         do 330 J = 1, 7
            if (SPFLGG(J,K).ne.1) go to 330
            if (BATCH.eq.0.or..not.IONS) go to 130
            write (TTYOUT(MACHNO),5020)
            if (J.eq.1) then
               write (TTYOUT(MACHNO),5030)
            else
               write (TTYOUT(MACHNO),5040) IOUT(J-1),J
            endif
5020        format (/' Do you want to inspect the input data for')
5030        format (' the neutral species (SPFLG(1,MCHEM))?')
5040        format (' the ',A2,' ion (SPFLG(',I1,'))?')
120         continue
            write (TTYOUT(MACHNO),REQFMT)
            call INREC (EOF,INUNIT,INPUT)
            if (EOF.eq.1) go to 350
            START = IMBED(INPUT,0)
            if (START.eq.-999) goto 130
            if (INPUT(START:START).eq.'Q'.or.INPUT(START:START).eq.'q')
     &         go to 350
            if (INPUT(START:START).eq.'Y'.or.INPUT(START:START).eq.'y')
     &         go to 130
            if (INPUT(START:START).eq.'N'.or.INPUT(START:START).eq.'n')
     &         go to 330
            write (TTYOUT(MACHNO),REQFMT)
            go to 120
5050        format (/' Response not understood; please try again.')
130         continue
            write (RPTLUN(MACHNO),5060) CCHAR(BATCH+1),VERSN,MODEG,K,
     &         (CHEMNA(IV,K),IV=1,III)
            write (RPTLUN(MACHNO),5070)
5060  format (A1,'Exposure Analysis Modeling System -- EXAMS Version ', 
     &F4.2,', Mode',I2/' Chemical:',I2,') ',50A1)
5070        format (1X,63('-'))
            if (J.eq.1) then
               write (RPTLUN(MACHNO),5080) KOUT
5080  format (' Table 1.',A2,'.1  Chemical input data for',' neutral mol
     &ecule (Sp.#1).')
               write (RPTLUN(MACHNO),5090) K
5090           format (' *** Chemical-specific data: SET via "entry(',I2
     &            ,')"')
               write (OUTLIN(1),5100) MWTG(K),VAPRG(K),HENRYG(K),KOWG(K)
5100  format (' MWT:  ',1PE9.2,' VAPR: ',E9.2,' HENRY:',E9.2,' KOW:  ', 
     &E9.2)
               write (OUTLIN(2),5110) KVOG(K),EVPRG(K),EHENG(K),KOCG(K)
5110  format (' KVO:  ',1PE9.2,' EVPR: ',E9.2,' EHEN: ',E9.2,' KOC:  ', 
     &E9.2)
               write (OUTLIN(3),5120) SOLG(1,K),KPBG(1,K),KPSG(1,K)
5120           format (' SOL:  ',1PE9.2,' KPB:  ',E9.2,' KPS:  ',E9.2,:,
     &            ' pK?:  ',E9.2)
               write (OUTLIN(4),5130) ESOLG(1,K),KPDOCG(1,K)
5130           format (' ESOL: ',1PE9.2,' KPDOC:',E9.2,:,' KIEC: ',E9.2,
     &            ' EpK:  ',E9.2)
               do 150 I1 = 1, 4
                  do 140 I = 9, 57, 16
      if (OUTLIN(I1)(I:I).eq.'0') OUTLIN(I1)(I-1:I+7) = '         '
                     if (OUTLIN(I1)(I+4:I+7).eq.'E+00') OUTLIN(I1)(I+4:I
     &                  +7) = '    '
140               continue
150            continue
               write (OUTLIN(3)(49:64),5140)
               write (OUTLIN(4)(33:64),5140)
5140           format (' ')
               write (RPTLUN(MACHNO),5180) (OUTLIN(I),I=1,2)
               write (RPTLUN(MACHNO),5150) J,K
5150           format (' *** Ion-specific data: "entry(',I1,',',I2,')"',
     &            :,' or, for KIEC & pK, (',I1,',',I2,')')
               write (RPTLUN(MACHNO),5180) (OUTLIN(I),I=3,4)
            else
               write (RPTLUN(MACHNO),5160) KOUT,J,IOUT(J-1),J
5160  format (' Table 1.',A2,'.',I1,'.  Chemical input data for ',A2,' i
     &on (Species #',I1,').')
               write (RPTLUN(MACHNO),5150) J,K,J-1,K
               write (OUTLIN(1),5120) SOLG(J,K),KPBG(J,K),KPSG(J,K),PKG(
     &            J-1,K)
               write (OUTLIN(2),5130) ESOLG(J,K),KPDOCG(J,K),KIECG(J-1,K
     &            ),EPKG(J-1,K)
               do 170 I1 = 1, 2
                  do 160 I = 9, 57, 16
      if (OUTLIN(I1)(I:I).eq.'0') OUTLIN(I1)(I-1:I+7) = '         '
                     if (OUTLIN(I1)(I+4:I+7).eq.'E+00') OUTLIN(I1)(I+4:I
     &                  +7) = '    '
160               continue
170            continue
               OUTLIN(1)(52:52) = 'b'
               if (J.gt.4) OUTLIN(1)(52:52) = 'a'
               write (RPTLUN(MACHNO),5180) OUTLIN(1),OUTLIN(2)
            endif
            do 210 I = 1, 4
               write (MSSAGE(I)(54:60),5170) I,J,K
5170           format (I1,', ',I1,',',I2)
               write (RPTLUN(MACHNO),5180) MSSAGE(I)
5180           format (A64)
               if (I.eq.4) go to 180
               write (OUTLIN(1),5190) NAME1(1,1),KAHG(I,J,K),NAME1(1,2),
     &            EAHG(I,J,K),NAME1(1,3),KNHG(I,J,K),NAME1(1,4),ENHG(I,J
     &            ,K)
5190           format (4(A7,1PE9.2))
               write (OUTLIN(2),5190) NAME1(2,1),KBHG(I,J,K),NAME1(2,2),
     &            EBHG(I,J,K),NAME1(2,3),KREDG(I,J,K),NAME1(2,4),EREDG(I
     &            ,J,K)
180            continue
               write (OUTLIN(3),5190) NAME1(3,1),KBACWG(I,J,K),NAME1(3,2
     &            ),QTBAWG(I,J,K),NAME1(3,3),KBACSG(I,J,K),NAME1(3,4),
     &            QTBASG(I,J,K)
               do 200 I1 = 1, 3
                  do 190 I2 = 9, 57, 16
                     if (OUTLIN(I1)(I2:I2).eq.'0') OUTLIN(I1)(I2-1:I2+7)
     &                   = '         '
                     if (OUTLIN(I1)(I2+4:I2+7).eq.'E+00') OUTLIN(I1)(I2+
     &                  4:I2+7) = '    '
190               continue
200            continue
               if (I.lt.4) then
                  write (RPTLUN(MACHNO),5180) (OUTLIN(I2),I2=1,3)
               else
                  write (RPTLUN(MACHNO),5180) OUTLIN(3)
               endif
210         continue
            if (BATCH.eq.0) go to 240
            write (TTYOUT(MACHNO),5200)
5200  format (/' Do you want to inspect the photolytic process data?')
220         continue
            write (TTYOUT(MACHNO),REQFMT)
            call INREC (EOF,INUNIT,INPUT)
            if (EOF.eq.1) go to 350
            START = IMBED(INPUT,0)
            if (START.eq.-999) goto 230
            if (INPUT(START:START).eq.'Q'.or.INPUT(START:START).eq.'q')
     &         go to 350
            if (INPUT(START:START).eq.'Y'.or.INPUT(START:START).eq.'y')
     &         go to 230
            if (INPUT(START:START).eq.'N'.or.INPUT(START:START).eq.'n')
     &         go to 330
            write (TTYOUT(MACHNO),5050)
            go to 220
230         continue
            write (RPTLUN(MACHNO),5060) CCHAR(BATCH+1),VERSN,MODEG,K,
     &         (CHEMNA(IV,K),IV=1,III)
            write (RPTLUN(MACHNO),5070)
            if (J.eq.1) then
               write (RPTLUN(MACHNO),5080) KOUT
            else
               write (RPTLUN(MACHNO),5160) KOUT,J,IOUT(J-1),J
            endif
240         continue
            write (RPTLUN(MACHNO),5210) J,K
5210        format (/' Photochemical process data;  Ion-specific data: '
     &         ,'"entry(',I1,',',I2,')"')
            write (OUTLIN(1),5220) J,K,KDPG(J,K),J,K,RFLATG(J,K),J,K,
     &         LAMAXG(J,K)
5220  format (' KDP(',I1,',',I2,'):',1PE9.2,' RFLAT(',I1,',',I2,'):',   
     &0PF6.1,'   ',' LAMAX(',I1,',',I2,'):',F6.1,'   ')
            if (OUTLIN(1)(13:13).eq.'0' .and. BATCH.eq.0) then
               do 250 I = 13, 57, 22
                  OUTLIN(1)(I-1:I+7) = '         '
250            continue
            endif
            if (OUTLIN(1)(13:13).eq.'0') OUTLIN(1)(12:20) = '         '
            write (RPTLUN(MACHNO),5180) OUTLIN(1)
            do 270 I = 1, 3
               write (MSSAGE(I)(54:60),5170) I,J,K
               write (RPTLUN(MACHNO),5180) MSSAGE(I)
               write (OUTLIN(1),5190) NAME1(4,1),K1O2G(I,J,K),NAME1(4,2)
     &            ,EK1O2G(I,J,K),NAME1(4,3),KOXG(I,J,K),NAME1(4,4),EOXG(
     &            I,J,K)
               do 260 I1 = 9, 57, 16
      if (OUTLIN(1)(I1:I1).eq.'0') OUTLIN(1)(I1-1:I1+7) = '         '
                  if (OUTLIN(1)(I1+4:I1+7).eq.'E+00') OUTLIN(1)(I1+4:I1+
     &               7) = '    '
260            continue
               write (RPTLUN(MACHNO),5180) OUTLIN(1)
270         continue
            write (OUTLIN(1),5230) (I,J,K,QUANTG(I,J,K),I=1,3)
5230        format (' ',3(' QUA(',I1,',',I1,',',I2,')',1PE9.2))
            do 280 I = 15, 57, 21
      if (OUTLIN(1)(I:I).eq.'0') OUTLIN(1)(I-1:I+7) = '         '
      if (OUTLIN(1)(I+4:I+7).eq.'E+00') OUTLIN(1)(I+4:I+7) = '    '
280         continue
            write (RPTLUN(MACHNO),5180) OUTLIN(1)
            write (OUTLIN(1),5240) J,K,(ABSORG(I,J,K),I=1,2)
5240        format (' Light ABSORption (n,',I1,',',I2,'):       (1)',   
     &         1PE10.3,'   (2)',E10.3)
            do 290 I = 39, 55, 16
      if (OUTLIN(1)(I:I).eq.'0') OUTLIN(1)(I-1:I+8) = '          '
290         continue
            write (RPTLUN(MACHNO),5180) OUTLIN(1)
            do 320 ITAB = 3, 43, 4
               write (OUTLIN(1),5250) (I,ABSORG(I,J,K),I=ITAB,ITAB+3)
               do 300 I = 7, 55, 16
      if (OUTLIN(1)(I:I).eq.'0') OUTLIN(1)(I-1:I+8) = '          '
300            continue
               do 310 I = 3, 51, 16
                  if (OUTLIN(1)(I-1:I).eq.'( ') OUTLIN(1)(I-1:I) = ' ('
310            continue
               write (RPTLUN(MACHNO),5180) OUTLIN(1)
320         continue
5250        format (' (',I2,')',1PE10.3,3('  (',I2,')',E10.3))
330      continue
340   continue
350   continue
      return
      end
