2 SUBROUTINE mrenv(kw,mass,mt,mc,lum,rad,rc,aj,tm,ltms,lbgb,lhei,
3 & rzams,rtms,rg,menv,renv,k2e)
6 real*8 mass,mt,mc,lum,rad,rc,aj,tm
7 real*8 k2e,menv,menvg,menvt,menvz,renv,renvg,renvt,renvz,rzr
9 real*8 k2bgb,k2g,k2z,logm,logmt,lbgb,ltms,lhei,rg,rtms,rzams
10 real*8 teff,tebgb,tetms,tau,tauenv,tautms
36 a = min(0.81d0,max(0.68d0,0.68d0+0.4d0*logm))
37 c = max(-2.5d0,min(-1.5d0,-2.5d0+5.d0*logm))
43 k2z = min(0.21d0,max(0.09d0-0.27d0*logm,0.037d0+0.033d0*logm))
44 if(logm.gt.1.3d0) k2z = k2z - 0.055d0*(logm-1.3d0)**2
45 k2bgb = min(0.15d0,min(0.147d0+0.03d0*logm,0.162d0-0.04d0*logm))
47 if(kw.ge.3.and.kw.le.6)
then
58 f = 0.208d0 + 0.125d0*logmt - 0.035d0*logmt**2
59 b = 1.0d+04*mt**(3.d0/2.d0)/(1.d0+0.1d0*mt**(3.d0/2.d0))
61 y = (f - 0.033d0*log10(lbgb))/k2bgb - 1.d0
62 k2g = (f - 0.033d0*log10(lum) + 0.4d0*x)/(1.d0+y*(lbgb/lum)+x)
67 b = 3.0d+04*mt**(3.d0/2.d0)
68 x = (max(0.d0,lum/b-0.5d0))**2
69 k2g = (k2bgb + 0.4d0*x)/(1.d0 + 0.4d0*x)
77 elseif(kw.eq.3.and.lum.lt.3.d0*lbgb)
then
81 x = min(3.d0,lhei/lbgb)
82 tau = max(0.d0,min(1.d0,(x-lum/lbgb)/(x-1.d0)))
83 menvg = 1.d0 - 0.5d0*tau**2
84 renvg = 1.d0 - 0.35d0*tau**2
110 rzr = max(1.d0,rad/rzams)
111 k2e = (k2z-e)*rzr**c + e*rzr**d
115 k2e = 0.08d0 - 0.03d0*tau
118 k2e = 0.08d0*rzams/rad
126 teff = sqrt(sqrt(lum)/rad)
127 tebgb = sqrt(sqrt(lbgb)/rg)
128 tauenv = max(0.d0,min(1.d0,(tebgb/teff-a)/(1.d0-a)))
130 tauenv = max(0.d0,min(1.d0,(sqrt(rad/rg)-a)/(1.d0-a)))
133 if(tauenv.gt.0.d0)
then
134 menv = menvg*tauenv**5
135 renv = renvg*tauenv**(5.d0/4.d0)
138 x = max(0.d0,min(1.d0,(0.1d0-logm)/0.55d0))
139 menvz = 0.18d0*x + 0.82d0*x**5
140 renvz = 0.4d0*x**(1.d0/4.d0) + 0.6d0*x**10
143 tetms = sqrt(sqrt(ltms)/rtms)
144 tautms = max(0.d0,min(1.d0,(tebgb/tetms-a)/(1.d0-a)))
145 menvt = menvg*tautms**5
146 renvt = renvg*tautms**(5.d0/4.d0)
149 if(tautms.gt.0.d0)
then
150 menv = menvz + tau**y*menv*(menvt - menvz)/menvt
151 renv = renvz + tau**y*renv*(renvt - renvz)/renvt
156 k2e = k2e + tau**y*tauenv**3*(k2g - k2e)
158 k2e = k2e + tauenv**3*(k2g - k2e)
173 menv = menv*(mt - mc)
174 renv = renv*(rad - rc)
175 menv = max(menv,1.0d-10)
176 renv = max(renv,1.0d-10)