C     Last change:  LKS  21 Jan 2008    9:57 am
      subroutine minzfunc(imincomp, z, minconc)
c
c     Example user routine on file minzfunc.f
c
c     This routine is called when the user has a continuous function that
c     defines the mineral concentration as a function of depth.
c     [Routine "minzdata" is called when the user has a data file of measured
c     (or simulated) mineral values at discrete depths.] 
c
c     Users can redefine this example Min(z) function as desired.
c
c     This routine is used when determining absorption and scattering
c     coefficients via bio-optical models.
c
      real z, minconc
      integer imincomp

c*****NOTE:  MUST save data values between subroutine calls:
      save
c
      data kall/0/
c
      if(kall.eq.0) then
c        initialization on the first call
c
c        set model parameters:
c  NOTE: these values are just for example purposes!!
c  NOTE: setting cmax = 0.0 gives a constant mineral profile:
c        minconc = cback at all depths

         cback = 1.0
         cmax = 5.0
         zsd = 10.0
         zmax = 30.0
c
         write(10,101) cback,cmax,zmax,zsd
         kall = 1
      endif
C
      minconc = cback + cmax*exp(-0.5*((z-zmax)/zsd)**2)

      return
c
  101 format(//5x,'The mineral profile is determined from a',
     1' constant background plus a Gaussian:'//
     210x,'Min(z) = Mback + Mmax*exp[0.5((z-zmax)/zsd)^2]'//
     310x,'with parameters values '//
     410x,'Mback =',f8.3,' grams/m^3'/
     510x,'Mmax  =',f8.3,' grams/m^3'/
     610x,'zmax  =',f8.3,' m'/
     710x,'zsd   =',f8.3,' m')
      end
