C     Last change:  LKS  21 Jan 2008    1:54 pm
      subroutine chlzfunc(icomp, z, chlconc)
c
c     Example user routine on file chlzfunc.f
c
c     This routine is called when the user has a continuous function that
c     defines the chlorophyll concentration as a function of depth.
c     [Routine "chlzdata" is called when the user has a data file of measured
c     (or simulated) Chlorophyll values at discrete depths.] 
c
c     Users can redefine this example Chl(z) function as desired.
c
c     This example routine uses a chlorophyll profile given by a
c     constant background value (cback) plus an exponential profile 
c     that peaks at depth zmax with magnitude cmax and half-width s.
c     This sort of profile can be seen in Lewis, et al. J Geophys 
c     Res 88, C4, 2565, 1983

c     This routine is used when determining absorption and scattering
c     coefficients via bio-optical models, and when computing
c     chlorophyll fluorescence.
c
c*****NOTE:  MUST save data values between subroutine calls:
      save
c
      data kall/0/
c
      if(kall.eq.0) then
c
c        initialization on the first call
c
c        set chlorophyll model parameters:
c  NOTE: these values are just for example purposes!!
c  NOTE: setting cmax = 0.0 gives a constant Chl profile:
c                chlconc = cback at all depths
         cback = 0.5
         cmax = 2.5
         zsd = 10.0
         zmax = 25.0
c
         write(10,101) cback,cmax,zmax,zsd
         kall = 1
      endif
c
      chlconc = cback + cmax*exp(-0.5*((z-zmax)/zsd)**2)
c
      return
c
  101 format(/5x,'The chlorophyll profile is determined from a',
     1' constant background plus a Gaussian:'/
     28x,'Chl(z) = Cback + Cmax*exp[0.5((z-zmax)/zsd)^2]'/
     35x,'where'/
     410x,'Cback =',f8.3/
     510x,'Cmax  =',f8.3/
     610x,'zmax  =',f8.3/
     710x,'zsd   =',f8.3)
      end
