      subroutine OUTP(TIME,Y,DY,JFLAG)
      include 'SIZE.INC'
      include 'GLOBAL.INC'
      include 'LOCAL.INC'
      include 'UNITS.INC'
      include 'LOCAL1.INC'
      dimension Y(KOUNT,KCHEM), DY(KOUNT,KCHEM)
      double precision TIME, Y, DY
      integer JFLAG
      real TTEMP, YTEMP, TEST96, TEST21, TESTXX, RTIMER
      integer I, ITIMER, J, K, LBEGIN, LEND, IZ, ISTK
      YCOUNT = YCOUNT+1.0
      YMONCT = YMONCT+1.0
      TTEMP = TIME
      ITIMER = int(TIME/TFACTR)
      RTIMER = TIME/TFACTR
      do 160 K = 1, KCHEM
         do 100 I = 1, 6
            Z(I,K) = 0.0
100      continue
         do 110 I = 1, 12
            Z2(I) = 0.0
110      continue
         do 130 J = 1, KOUNT
            YTEMP = dabs(Y(J,K))
            YSUM(J,K) = YSUM(J,K)+YTEMP
            if (TYPEG(J).eq.'B') go to 120
            Z(1,K) = Z(1,K)+YTEMP*(ALPHA(29,J,K)+ALPHA(31,J,K))
            Z(2,K) = Z(2,K)+ALPHA(30,J,K)*YTEMP/SEDCOL(J)
            Z(5,K) = Z(5,K)+YTEMP*WATVOL(J)*1.0E-06
            go to 130
120         continue
            Z(3,K) = Z(3,K)+YTEMP*(ALPHA(29,J,K)+ALPHA(31,J,K))
            Z(4,K) = Z(4,K)+ALPHA(30,J,K)*YTEMP/SEDCOL(J)
            Z(6,K) = Z(6,K)+YTEMP*WATVOL(J)*1.0E-06
130      continue
         Z(1,K) = Z(1,K)/KOUNTW
         Z(2,K) = Z(2,K)/KOUNTW
         Z(3,K) = Z(3,K)/KOUNTS
         Z(4,K) = Z(4,K)/KOUNTS
         if (MODEG.le.2)write(RPTLUN(MACHNO),5000) ITIMER,(Z(J,K),J=1,6)
5000     format (1X,I4,1PG9.2,3(1X,G9.2),2X,G9.2,G9.2)
         write (KINLUN(MACHNO)) K,TTEMP,(Z(J,K),J=1,6)
         do 150 J = 1, KOUNT
            YTEMP = dabs(Y(J,K))
            Z2(1) = YTEMP
            if (TYPEG(J).eq.'B') Z2(1) = YTEMP/SEDCOL(J)
            Z2(2) = (ALPHA(29,J,K)+ALPHA(31,J,K))*YTEMP
            Z2(3) = ALPHA(30,J,K)*YTEMP/SEDCOL(J)
            Z2(4) = ALPHA(32,J,K)*YTEMP/BIOTOL(J)
            Z2(5) = 1.0E-03*YTEMP*WATVOL(J)/AREAG(J)
            Z2(6) = ALPHA(29,J,K)*YTEMP
            Z2(7) = ALPHA(31,J,K)*YTEMP
            write (KINLUN(MACHNO)) K,TTEMP,J,(Z2(I),I=1,7)
            if (MODEG.ne.3) go to 150
            if (TYPEG(J).ne.'B') then
               LBEGIN = 1
               LEND = 5
            else
               LBEGIN = 6
               LEND = 10
            endif
            IZ = 1
            do 140 I = LBEGIN, LEND
               if (JFLAG.eq.1) then
                  STKBEG(0,I,J,K) = Z2(IZ)
                  go to 139
               endif
               TEST96 = STKBEG(22,I,J,K) + 0.5*(STKBEG(0,I,J,K) + Z2(IZ)
     &                - STKBEG(04,I,J,K) - STKEND(4,I,J,K))
               TEST21 = STKBEG(23,I,J,K) + 0.5*(STKBEG(0,I,J,K) + Z2(IZ)
     &                - STKBEG(21,I,J,K) - STKEND(21,I,J,K))
               do 134 ISTK = 21, 2, -1
                  STKEND(ISTK,I,J,K) = STKEND(ISTK-1,I,J,K)
                  STKBEG(ISTK,I,J,K) = STKBEG(ISTK-1,I,J,K)
134            continue
               STKBEG(1,I,J,K) = STKBEG(0,I,J,K)
               STKEND(1,I,J,K) = Z2(IZ)
               STKBEG(0,I,J,K) = Z2(IZ)
               TESTXX = amax1(PEAKLT(I,K), STKBEG(1,I,J,K),
     &                        STKEND(1,I,J,K))
               if (TESTXX.gt.PEAKLT(I,K)) then
                  PEAKLT(I,K) = TESTXX
                  MAXSEG(I,K) = J
               endif
               TESTXX = amin1(YMINLT(I,K), STKBEG(1,I,J,K),
     &                        STKEND(1,I,J,K))
               if (TESTXX.lt.YMINLT(I,K)) then
                  YMINLT(I,K) = TESTXX
                  MINSEG(I,K) = J
               endif
               if (TEST96.gt.YBAR96(I,K)) then
                  TEST96 = 0.0
                  do 135 ISTK = 1, 4
                     TEST96=TEST96+STKBEG(ISTK,I,J,K)+STKEND(ISTK,I,J,K)
135               continue
                  TEST96 = TEST96/8.0
               endif
               if (TEST96.gt.YBAR96(I,K)) then
                  YBAR96(I,K) = TEST96
                  PEAK96(I,K) = 0.0
                  YMIN96(I,K) = 1.E+20
                  do 136 ISTK = 1, 4
                     PEAK96(I,K) = amax1( PEAK96(I,K),
     &                           STKBEG(ISTK,I,J,K), STKEND(ISTK,I,J,K))
                     YMIN96(I,K) = amin1( YMIN96(I,K),
     &                           STKBEG(ISTK,I,J,K), STKEND(ISTK,I,J,K))
136               continue
               end if
               if (TEST21.gt.YBAR21(I,K)) then
                  TEST21 = 0.0
                  do 137 ISTK = 1, 21
                     TEST21=TEST21+STKBEG(ISTK,I,J,K)+STKEND(ISTK,I,J,K)
137               continue
                  TEST21 = TEST21/42.0
               end if
               if (TEST21.gt.YBAR21(I,K)) then
                  YBAR21(I,K) = TEST21
                  PEAK21(I,K) = 0.0
                  YMIN21(I,K) = 1.E+20
                  do 138 ISTK = 1, 21
                     PEAK21(I,K) = amax1( PEAK21(I,K),
     &                           STKBEG(ISTK,I,J,K), STKEND(ISTK,I,J,K))
                     YMIN21(I,K) = amin1( YMIN21(I,K),
     &                           STKBEG(ISTK,I,J,K), STKEND(ISTK,I,J,K))
138               continue
               endif
               STKBEG(22,I,J,K) = TEST96
               STKBEG(23,I,J,K) = TEST21
139            continue
               IZ = IZ+1
140         continue
150      continue
160   continue
      if (KOUNT.le.2 .and. MODEG.gt.1) call EX2FGT(Y,JFLAG,RTIMER)
      return
      end
