#include "definetab.h"
      subroutine setbio(rmumax,rik,cchlratio,cnratio,bn,bf,fescavrate, 
     * wsh,drate,rlamz,greff,dratez1,dratez2,regen, 
     * solFe,remin,rkn,rks,rkf, 
#if PCOTAB
     * Pdeep,pco2tab)
#else
     * Pdeep)
#endif
!  Computes constants over entire run of model, reads in required
!  data files, and otherwise obtains one-time-only information 
!  necessary for the run.
!  Biological constituents
!  P(1) = nitrate (uM)
!  P(2) = ammonium (uM)
!  P(3) = silica (uM)
!  P(4) = iron (nM)
!  P(5) = diatoms (mg chl m-3)
!  P(6) = chlorophytes (mg chl m-3)
!  P(7) = cyanobacteria (mg chl m-3)
!  P(8) = coccolithophores (mg chl m-3)
!  P(9) = herbivores (mg chl m-3)
!  Detrital components
!  P(10) = N/C detritus (ugC l-1)
!  P(11) = silica detritus (uM)
!  P(12) = iron detritus (nM)
!  Carbon components
!  P(13) = DOC (uM)
!  P(14) = DIC (uM)
!  pCO2 (uatm)
 
#include "definebio.h"
#if PCOTAB
      integer, parameter :: it0inc=1,nt0=80/it0inc
      integer, parameter :: isalinc=1,nsal=20
      integer, parameter :: idicinc=2,ndic=(650+idicinc)/idicinc
      integer, parameter :: itainc=2,nta=(500+itainc)/itainc
      real*4 pco2tab(nt0,nsal,ndic,nta)
#endif
      real rmumax(nchl)     !max phyto growth rate at 20oC, /d
      real rik(3,nchl)      !light saturation parameter umol quanta/m2/s
      real cchl(3)          !C:chl ratio g:g for 3 light states
      real fescavrate(2)    !Fe scavenging rate /hr
      real remin(ndet)      !detrital remineralization rate /hr
      real rkn(nchl),rks(nchl) !half-sat constants for N and S (uM)
      real rkf(nchl)        !half-sat constant for Fe (nM)
      real wsd(ntyp)        !particle sinking rate m/d
      real wsh(ntyp)        !particle sinking rate m/h
      real Pdeep(ntyp)
 
      pHsfc = 8.0
      pHmin = 7.5
      pHmax = 8.6
 
!  Physical parameters needed for biolog
      solFe = 0.02          !solubility of iron
 
!  Zooplankton/grazing parameters
      rlamz   = 1.0	      !Ivlev constant
      greff   = 0.25          !grazing efficiency
      greff   = 0.10          !grazing efficiency
      dratez1 = 0.1/24.0      !zooplankton death rate/hr
      dratez2 = 0.5/24.0      !zooplankton death rate/hr
      regen   = 0.25          !regeneration fraction
      regen   = 0.10          !regeneration fraction
 
!  Phytoplankton group parameters
      drate  = 0.05/24.0      !phytoplankton death rate/hr
      rkn    = 0.0
      rks    = 0.0
      rkf    = 0.0
      wsd    = 0.0
      wsh    = 0.0
      rmumax = 0.0
      rik    = 0.0
      Pdeep    =  0.0   !bottom BC 
      Pdeep(1) = 32.0   !bottom BC for nitrate
      Pdeep(2) =  0.1   !bottom BC for ammonium
      Pdeep(3) = 60.0   !bottom BC for silica
      Pdeep(4) =  0.6   !bottom BC for iron from Archer and Johnson 2000
      Pdeep(nds:nde)  =  0.0   !bottom BC for detritus
      Pdeep(ncs)   = 0.0  !bottom BC for DOC
      Pdeep(ntyp)  = 2330.0!bottom BC for DIC uM from Goyet et al (2000)
 
!  Carbon:chl ratios for different adaptation states
      cchl(1) = 25.0
      cchl(2) = 50.0
      cchl(3) = 80.0
!      cchl(1) = 20.0
!      cchl(2) = 60.0
!      cchl(3) = 100.0
      cnratio = 106.0/16.0*12.0    !C:N ratio (ugl:uM)
      csratio = 106.0/16.0*12.0    !C:Si ratio (ugl:uM)
      cfratio = 150000.0*12.0*1.0E-3    !C:Fe ratio (ugl:nM)
      bn = cchl(2)/cnratio         !N:chl ratio (uM/ugl)
      bf = cchl(2)/cfratio         !Fe:chl ratio (nM/ugl)
      cchlratio = cchl(2)          !C:chl ratio (ugl/ugl)
 
#if NCHL_DEFINED > 0
!  Diatoms
      n = 1
      rmumax(n)   = 2.00     !u max in /day at 20C
      rmumax(n)   = 1.75     !u max in /day at 20C
      wsd(n+nnut) = 0.75     !sinking rate in m/day
      rik(1,n)    = 90.0     !low light-adapted Ik (<50 uE/m2/s)
      rik(2,n)    = 93.0     !medium light-adapted Ik (50-200 uE/m2/s)
      rik(3,n)    = 184.0    !high light adapted Ik (>200 uE/m2/s)
      rkn(n)      = 1.0      !M-M half-sat constant for nitrogen
      rks(n)      = 0.2      !M-M half-sat constant for silica
      rkf(n)      = 0.12     !M-M half-sat constant for iron
#endif
#if NCHL_DEFINED > 1
!  Chlorophytes
      n = 2
      rmumax(n)   = rmumax(n-1)*0.840
      wsd(n+nnut) = 0.25
      rik(1,n)    = rik(1,n-1)*1.077
      rik(2,n)    = rik(2,n-1)*0.935
      rik(3,n)    = rik(3,n-1)*0.781
      rkn(n)      = rkn(n-1)*0.75
      rkn(n)      = rkn(n-1)*0.667  !1/3 distance bet. cocco and dia
      rkf(n)      = rkf(n-1)*0.835  !midway between cocco's and diatoms
      rkf(n)      = rkf(n-1)*0.779  !1/3 distance bet. cocco and dia
#endif
#if NCHL_DEFINED > 2
!  Cyanobacteria
      n = 3
      rmumax(n)   = rmumax(n-2)*0.670
      wsd(n+nnut) = 0.0085
      rik(1,n)    = rik(1,n-2)*0.723
      rik(2,n)    = rik(2,n-2)*0.710
      rik(3,n)    = rik(3,n-2)*0.256
      rkn(n)      = rkn(n-2)*0.45
      rkf(n)      = rkf(n-2)*0.67  !equals cocco 
#endif
#if NCHL_DEFINED > 3
!  Coccolithophores
      n = 4
!      rmumax(n)   = rmumax(n-3)*0.663  !all coccos
      rmumax(n)   = rmumax(n-3)*0.755  !E. huxleyi only
!      rmumax(n)  = rmumax(n-3)*0.781  !E. huxleyi only (no Sunda/Hunts)
      wsd(n+nnut) = 0.82
      wsd(n+nnut) = 0.648
      rik(1,n)    = rik(1,n-3)*0.623
      rik(2,n)    = rik(2,n-3)*0.766
      rik(3,n)    = rik(3,n-3)*0.899
      rkn(n)      = rkn(n-3)*0.5
      rkf(n)      = rkf(n-3)*0.67
#endif
#if NCHL_DEFINED > 4
!  Dinoflagellates
      n = 5
      rmumax(n)   = rmumax(n-4)*0.335
      wsd(n+nnut) = 0.0
      rik(1,n)    = rik(1,n-4)*1.321
      rik(2,n)    = rik(2,n-4)*1.381
      rik(3,n)    = rik(3,n-4)*1.463
      rkn(n)      = rkn(n-4)*1.0
      rkf(n)      = rkf(n-4)*0.67
#endif
!  Detrital sinking rates m/d
      wsd(nds)   = 35.0     !nitrogen  
      wsd(nds+1) = 30.0     !silica 
      wsd(nde)   =  5.0     !iron 

      wsh = wsd/24.0  !convert to m/hr
 
!  Detrital remineralization rates /hr
      remin(1) = 0.01/24.0             !nitrogen 
      remin(2) = 0.05/24.0             !silica 
      remin(3) = 0.50/24.0             !iron 
      fescavrate(1) = 2.74E-5/24.0       !low fe scavenging rate/hr
      fescavrate(2) = 50.0*fescavrate(1) !high fe scavenging rate/hr
 
#if PCOTAB
!  Read in pco2 data file
      open(4,file='bcs/pco2.tbl',status='old',form='unformatted')
      read(4)pco2tab
      close(4)
#endif
 
      return
      end
