c
c %W%
c
      subroutine savflx(rky,ip,k)

      include'mladv.inc'
      include'trc.inc'

      common/parm/kz,m,mm1,mm2,mp1,msq,tim,tmax,tstart,hy,rea,dt,
     +   xbasin,yy(mx0),icalc,kzp1,kzm1,iftop,ifbot,iftvv,ifrel,theta,
     +   ifsbl,ifeva

      data itrcnt /0/
      data icall  /-1/

      dimension rky(maxtrace+1)

      if (icall .lt. 0) then
         msqtl = msq * l
         tstd = tstart * t0 / 86400.
         icall = 0
        endif

      icall = icall + 1

      if ( amod(mltime - tstd , dtrflx) .lt. qgts / 2. / 86400) then

         if (itrcnt .gt. 0) then
            fact = 86400. / qgts / float(itrcnt)
           else
            fact = 0.
          endif

         do 1 i=1,ntflx
            tfluxd(ip,k,i) = fact * tflux(ip,k,i)
            tflux(ip,k,i) = 0.
  1       continue

         if (icall .eq. msqtl) itrcnt = 0

        endif

      call trcflx(rky)

      tflux(ip,k,1)  = tflux(ip,k,1)  + no3upt
      tflux(ip,k,2)  = tflux(ip,k,2)  + nh4upt
      tflux(ip,k,3)  = tflux(ip,k,3)  + phyupt
      tflux(ip,k,4)  = tflux(ip,k,4)  + pdeath
      tflux(ip,k,5)  = tflux(ip,k,5)  + graze
      tflux(ip,k,6)  = tflux(ip,k,6)  + ingest
      tflux(ip,k,7)  = tflux(ip,k,7)  + hdeath
      tflux(ip,k,8)  = tflux(ip,k,8)  + carniv
      tflux(ip,k,9)  = tflux(ip,k,9)  + slopfd
      tflux(ip,k,10) = tflux(ip,k,10) + regen1
      tflux(ip,k,11) = tflux(ip,k,11) + regen2
      tflux(ip,k,12) = tflux(ip,k,12) + exprt1
      tflux(ip,k,13) = tflux(ip,k,13) + exprt2


      if (icall .eq. msqtl) then
         itrcnt = itrcnt + 1
         icall = 0
        endif

      return
      end
