      SUBROUTINE BIODAT(NSTEPS) 

C
C  This subroutine reads in data pertinent to the dinoflagellate model
C  including the biological model parameters, the cyst map, nutrient data,
C  day-averaged irradiance.  I also includes the specification of the
C  endogenous clock.  This routine can be expanded to include other info. 
C  pertinent to the biological model as nescessary.
C   
C  BIOMOD = array of parameter values for the biological model.  Each row is
C           a different set of parameters.  Columns are organized as follows:
C	    gmax  dg  Kn  m  G_eff  G_r  Kw  Ks  Elgt  Edrk  Wa
C
C  variables input here and included in dino.inc
C  CYSTINIT1 = initial number of cysts
C  CYSTBED1 = the present number of cysts
C  DINMAP = cruise based DIN concentrations
C  DASWRA = day averaged short-wave radiation
C  OPT_DAT = observational data
C  GPN = the normalized germination potential
C  DAYMM = the mid-month point of each day
C  NOBS_ALEX = # of Alexandrium observations for comparison
C   
C  Local variables:
C  GP = germination potential
C  NUMB = total # of grid cells in 2D slab
C  NUMDAYS = total # of days in the simulation
C 
C  From hydrodynamic model
C  NSTEPS = # of steps in the simulation
C  DTI = time step (seconds)
C  IM = x-dimension of grid
C  JM = y-dimension of grid
C  
C  If it is desired to run biological simulations with multiple bio tracers
C  for the same hydrodynamic run, add CYSTINIT2, CYSTBED2 etc. and uncomment
C  the loop 11 to take in the appropriate number of bio model settings. 

      INCLUDE 'comdeck'
      INCLUDE 'dino.inc'

      INTEGER NUMDAYS
      REAL GP(12)

C The number of observations used in the comparison
      NOBS_ALEX = 386

C zero DINMAP
      DO 9 I = 1,IM
        DO 9 J = 1,JM
          DO 9 K = 1,7
            DINMAP(I,J,K) = 0.0
 9    CONTINUE

C open file holding the parameter values for all biological model settings
C uncomment loop and and set accordingly if running multiple biological
C model parameter choices per hydrodynamic simulation 
C      DO 11 N = 1,10
       N = 1
       READ(IUBIO,FMT='(11F6.3)') (BIOMOD(N,I), I = 1,11)
C  11  CONTINUE

C read in the cyst data (cysts/cm3), convert to cysts/m2 in top dg cm
      NUMB = IM*JM
      DO 13 N = 1,NUMB
	READ(IUCYS,21) I,J,CYSTBED1(I,J)
        CYSTINIT1(I,J) = CYSTBED1(I,J)*10000.0*BIOMOD(1,2)
        CYSTBED1(I,J) = CYSTINIT1(I,J)
  13  CONTINUE

C read in nitrogen data - data consists of 7 maps for Stock et al. runs,
C adjust accordingly
      DO 15 II = 1,NUMB
        READ(IUNIT0,23) I, J, DINMAP(I,J,1)
        READ(IUNIT1,23) I, J, DINMAP(I,J,2)
        READ(IUNIT2,23) I, J, DINMAP(I,J,3)
        READ(IUNIT3,23) I, J, DINMAP(I,J,4)
        READ(IUNIT4,23) I, J, DINMAP(I,J,5)
        READ(IUNIT5,23) I, J, DINMAP(I,J,6)
        READ(IUNIT6,23) I, J, DINMAP(I,J,7)
  15  CONTINUE

C read in the day averaged short-wave radiation
      NUMDAYS = (NSTEPS*DTI)/86400.0 + 1.0
      DO 17 N = 1,NUMDAYS
        READ(IUDRF,*) DASWRA(N)
   17 CONTINUE

C read in observational data
      DO 19 N = 1,NOBS_ALEX
        READ(IUPNT,25) OPT_DAT(N,1), OPT_DAT(N,2), OPT_DAT(N,3),
     .     OPT_DAT(N,4), OPT_DAT(N,5), OPT_DAT(N,6), OPT_DAT(N,7),
     .     OPT_DAT(N,8)
  19  CONTINUE

C Monthly Median Germination Potential Values
      GP(1) = 21.90
      GP(2) = 11.25
      GP(3) = 78.0
      GP(4) = 85.0
      GP(5) = 96.8
      GP(6) = 93.0
      GP(7) = 60.0
      GP(8) = 50.0
      GP(9) = 10.0
      GP(10) = 11.5
      GP(11) = 17.0
      GP(12) = 34.5

C Mid-point yeardays of each month (non leap-year, 1/1 00:00 = yearday 0)
      DAYMM(1) = 15.5
      DAYMM(2) = 45.0
      DAYMM(3) = 74.5
      DAYMM(4) = 105.0
      DAYMM(5) = 135.5
      DAYMM(6) = 166.0
      DAYMM(7) = 196.5
      DAYMM(8) = 227.5
      DAYMM(9) = 258.0
      DAYMM(10) = 288.5
      DAYMM(11) = 319.0
      DAYMM(12) = 349.5

C Normalize to 1 (logic: germination rate experiments were done
C during peak germination potential, which is a bit under 100%.
C Those full rates should be realized).

      DO 100 I = 1,12
        GPN(I) = GP(I)
        GPN(I) = GPN(I)/(MAX(GP(1),GP(2),GP(3),GP(4),GP(5),GP(6),
     &                   GP(7),GP(8),GP(9),GP(10),GP(11),GP(12)))
 100  CONTINUE

  21  FORMAT(I3,3X,I3,1X,F7.1)
  23  FORMAT(I3,2X,I3,F9.1)
  25  FORMAT(F1.0,2X,F3.0,2X,F3.0,2X,F6.2,2X,F6.2,2X,F5.0,2X,F3.1,
     .         2X,F4.0)

      END 
