c
c %W%
c
      subroutine trcflx(rky)

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

      dimension rky(maxtrace+1)

      if (rky(1) .ge. 0.0) then
         s     = rky(1)
        else
         s     = 0.0
       endif
      if (rky(2) .ge. 0.0) then
         phyto = rky(2)
        else
         phyto = 0.0
       endif
      if (rky(3) .ge. 0.0) then
         zoo   = rky(3)
        else
         zoo   = 0.0
       endif
      if (rky(4) .ge. 0.0) then
         s2    = rky(4)
        else
         s2    = 0.0
       endif

      q1 = (s * exp(-kn * s2)) / (ks + s) 
      q2 = s2 / (ks2 + s2)
      q  = q1 + q2

      pofi = pmax * (1.0 - exp(-p1*enow/pmax) ) * 
     .                       exp(-p2*enow/pmax) * phyto

      no3upt = pofi * q1
      nh4upt = pofi * q2
      phyupt = pofi * q
      pdeath = ploss * phyto
      graze  = rm * (1.0 - exp(-civlev * phyto)) * zoo
      ingest = (1.0 - fslop) * graze
      hdeath = zloss * zoo
      carniv = zloss2 * zoo**2
      slopfd = fslop * graze
      regen1 = (1.0 - zeff1) * hdeath
      regen2 = (1.0 - zeff2) * carniv
      exprt1 = zeff1 * hdeath
      exprt2 = zeff2 * carniv

      return
      end
