        subroutine TABA
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
      include 'INPAR.INC'
      include 'LOCAL1.INC'
      include 'LOCAL2.INC'
        real OUT1(NCON), OUT2(NCON), OUT3(NCON), OUT4(6)
        integer LOC1(NCON), LOC2(NCON), NFIRST, NLAST
        logical MEAN
        character KOUT*2, NMON*4, TAG*2
        common/TABLES/ OUT1, OUT2, OUT3, OUT4
     &, LOC1, LOC2, NFIRST, NLAST, MEAN
        common /TABLE2/ KOUT, NMON, TAG
        integer I, J, K, NBLOCL, III, IV, VRAIL
        character OUTLIN*64
5000  format ('1','Exposure Analysis Modeling System -- EXAMS Version ',
     &   F4.2,', Mode',I2/' Ecosystem: ',50A1)
5010  format (1X,63('-'))
5020  format (1X,63('-')/2X,'* Segment types: Littoral, Epilimnetic, Hyp
     &olimnetic, Benthic.')
5030  format (1X,A2,' Average of 12 monthly mean values.')
      III = VRAIL(ECONAM)
      do 170 NBLOCL = NFIRST, NLAST
         write (RPTLUN(MACHNO),5000) VERSN,MODEG,(ECONAM(IV),IV=1,III)
         write (RPTLUN(MACHNO),5010)
         if (MODEG.ne.3.or.PRSWG.ne.1) go to 100
         NMON = NAMONG(NBLOCL)
         if (NBLOCL.ne.13) go to 100
         MEAN = .true.
         TAG = '**'
100      continue
         write (KOUT,5040) NBLOCL
5040     format (I2)
         if (KOUT(1:1).eq.' ') KOUT(1:1) = '0'
         write (RPTLUN(MACHNO),5050) KOUT,NMON,TAG
5050  format (' Table 4.',A2,'.  ',A4,' environmental input data: ','bio
     &logicals.',A2)
         write (RPTLUN(MACHNO),5010)
         write (RPTLUN(MACHNO),5060)
5060  format (1X,'Seg  T*',4X,'BACPL',4X,'BNBAC',4X,'PLMAS',4X,'BNMAS'/ 
     &2X,'#',3X,'y',4X,'cfu/ml',3X,'cfu/100g',2X,'mg/L',4X,'dry g/m2')
         write (RPTLUN(MACHNO),5010)
         do 160 J = 1, KOUNT
            do 110 I = 1, 6
               OUT4(I) = 0.0
110         continue
            if (.not.MEAN) go to 140
            do 120 I = 1, 12
               if (TYPEG(J).eq.'B') then
                  OUT4(2) = OUT4(2)+BNBACG(J,I)
                  OUT4(4) = OUT4(4)+BNMASG(J,I)
               else
                  OUT4(1) = OUT4(1)+BACPLG(J,I)
                  OUT4(3) = OUT4(3)+PLMASG(J,I)
               endif
120         continue
            do 130 I = 1, 4
               OUT4(I) = OUT4(I)/12.
130         continue
            BACPLG(J,13) = OUT4(1)
            BNBACG(J,13) = OUT4(2)
            PLMASG(J,13) = OUT4(3)
            BNMASG(J,13) = OUT4(4)
140         continue
            if (TYPEG(J).eq.'B') then
               OUT4(2) = BNBACG(J,NBLOCL)
               OUT4(4) = BNMASG(J,NBLOCL)
            else
               OUT4(1) = BACPLG(J,NBLOCL)
               OUT4(3) = PLMASG(J,NBLOCL)
            endif
            OUT4(5) = 0.0
            OUT4(6) = 0.0
            write (OUTLIN,5070) J,TYPEG(J),(OUT4(I),I=1,6)
5070        format (1X,I3,2X,A1,3X,1PE9.2,5E9.2)
            K = 1
            do 150 I = 11, 56, 9
               if (OUT4(K).eq.0.0) OUTLIN(I:I+8) = '         '
               if (OUTLIN(I+5:I+8).eq.'E+00') OUTLIN(I+5:I+8) = '    '
               K = K+1
150         continue
            write (RPTLUN(MACHNO),5080) OUTLIN
5080        format (A64)
160      continue
         write (RPTLUN(MACHNO),5020)
         if (TAG(1:1).eq.'*') write (RPTLUN(MACHNO),5030) TAG
170   continue
      if (.not.(PRSWG.eq.1.and.MODEG.eq.3)) go to 180
      MEAN = .false.
      TAG = '  '
180   continue
      do 280 NBLOCL = NFIRST, NLAST
         write (RPTLUN(MACHNO),5000) VERSN,MODEG,(ECONAM(IV),IV=1,III)
         write (RPTLUN(MACHNO),5010)
         if (MODEG.ne.3.or.PRSWG.ne.1) go to 190
         NMON = NAMONG(NBLOCL)
         if (NBLOCL.ne.13) go to 190
         MEAN = .true.
         TAG = '*'
190      continue
         write (KOUT,5040) NBLOCL
         if (KOUT(1:1).eq.' ') KOUT(1:1) = '0'
         write (RPTLUN(MACHNO),5090) KOUT,NMON,TAG
5090  format (' Table 5.',A2,'.  ',A4,' environmental data: ','hydrologi
     &c parameters.',A2)
         write (RPTLUN(MACHNO),5010)
         write (RPTLUN(MACHNO),5100)
5100  format (1X,'Seg  T*',4X,'STFLO',4X,'STSED',4X,'NPSFL',4X,'NPSED', 
     &4X,'SEEPS',5X,'EVAP'/2X,'#',3X,'y ',4X,'m3/hr',4X,'kg/hr',4X,'m3/h
     &r',4X,'kg/hr',4X,'m3/hr',5X,'mm/mon')
         write (RPTLUN(MACHNO),5010)
         do 270 J = 1, KOUNT
            if (.not.MEAN) go to 240
            do 200 I = 1, 6
               OUT4(I) = 0.0
200         continue
            do 220 I = 1, 12
               OUT4(1) = OUT4(1)+STFLOG(J,I)
               OUT4(2) = OUT4(2)+STSEDG(J,I)
               OUT4(3) = OUT4(3)+NPSFLG(J,I)
               OUT4(4) = OUT4(4)+NPSEDG(J,I)
               OUT4(5) = OUT4(5)+SEEPSG(J,I)
               if (J.eq.1) go to 210
               if (TYPEG(J).ne.'B'.and.TYPEG(J-1).eq.'B') go to 210
               go to 220
210            continue
               OUT4(6) = OUT4(6)+EVAPG(J,I)
220         continue
            do 230 I = 1, 6
               OUT4(I) = OUT4(I)/12.
230         continue
            STFLOG(J,13) = OUT4(1)
            STSEDG(J,13) = OUT4(2)
            NPSFLG(J,13) = OUT4(3)
            NPSEDG(J,13) = OUT4(4)
            SEEPSG(J,13) = OUT4(5)
            EVAPG(J,13) = OUT4(6)
240         continue
            OUT4(1) = STFLOG(J,NBLOCL)
            OUT4(2) = STSEDG(J,NBLOCL)
            OUT4(3) = NPSFLG(J,NBLOCL)
            OUT4(4) = NPSEDG(J,NBLOCL)
            OUT4(5) = SEEPSG(J,NBLOCL)
            if (J.eq.1) go to 250
            if (TYPEG(J).ne.'B'.and.TYPEG(J-1).eq.'B') go to 250
            EVAPG(J,NBLOCL) = 0.0
250         continue
            OUT4(6) = EVAPG(J,NBLOCL)
            write (OUTLIN,5070) J,TYPEG(J),(OUT4(I),I=1,6)
            K = 1
            do 260 I = 11, 56, 9
               if (OUT4(K).eq.0.0) OUTLIN(I:I+8) = '         '
               if (OUTLIN(I+5:I+8).eq.'E+00') OUTLIN(I+5:I+8) = '    '
               K = K+1
260         continue
            write (RPTLUN(MACHNO),5080) OUTLIN
270      continue
         write (RPTLUN(MACHNO),5020)
280   continue
      if (TAG(1:1).eq.'*') write (RPTLUN(MACHNO),5030) TAG
      return
      end
