      Subroutine TOXSUB(CW,TOXB,TOXF)
C
      Include 'comdeck'
C      Include 'dino.inc'
C
C-----------------------------------------------------------------------
C Program to calculate relative shellfish toxicity based on a simple
C "Hyundai" toxicity model formulated formulated during the ECOHAB
C Modelling project kick-off (2/25/03-2/26/03)
C
C DSTX/DT = alpha*[Alex] - k1*[STX]
C
C STX = saxitoxin (relative units for now)
C alpha = an uptake coefficient (TOXK_IN below)
C [Alex] = alexandrium concentration (cells/m3 within model)
C k1 = a detoxification coefficient (TOXK_OUT below) 
C
C Coding 2/3/05, contact: Charlie Stock
C-----------------------------------------------------------------------
C
      REAL CW(IM,JM,KB), TOXB(IM,JM,KB), TOXF(IM,JM,KB)
      REAL TOXK_IN, TOXK_OUT 

C set parameter values 
      TOXK_IN = 1.0
      TOXK_OUT = 0.1
      

      Do 30 I = 2,IMM1 
        Do 20 J = 2,JMM1 
          Do 10 K = 1,KBM1
            If (D(I,J).GT.0.0) then
              DSTX_DT = TOXK_IN*CW(I,J,K) - TOXK_OUT*TOXB(I,J,K)
              TOXF(I,J,K) = TOXB(I,J,K) + DSTX_DT*(DTI*2.0/86400.0)
              TOXF(I,J,K) = max(TOXF(I,J,K),0.0) 
           end if
   10     Continue
   20   Continue
   30 Continue

      RETURN
      End
