1 | module gfluxv_mod |
---|
2 | |
---|
3 | implicit none |
---|
4 | |
---|
5 | contains |
---|
6 | |
---|
7 | SUBROUTINE GFLUXV(DTDEL,TDEL,TAUCUMIN,WDEL,CDEL,UBAR0,F0PI,RSF, |
---|
8 | * BTOP,BSURF,FMIDP,FMIDM,DIFFV,FLUXUP,FLUXDN) |
---|
9 | |
---|
10 | |
---|
11 | C THIS SUBROUTINE TAKES THE OPTICAL CONSTANTS AND BOUNDARY CONDITIONS |
---|
12 | C FOR THE VISIBLE FLUX AT ONE WAVELENGTH AND SOLVES FOR THE FLUXES AT |
---|
13 | C THE LEVELS. THIS VERSION IS SET UP TO WORK WITH LAYER OPTICAL DEPTHS |
---|
14 | C MEASURED FROM THE TOP OF EACH LAYER. (DTAU) TOP OF EACH LAYER HAS |
---|
15 | C OPTICAL DEPTH TAU(N).IN THIS SUB LEVEL N IS ABOVE LAYER N. THAT IS LAYER N |
---|
16 | C HAS LEVEL N ON TOP AND LEVEL N+1 ON BOTTOM. OPTICAL DEPTH INCREASES |
---|
17 | C FROM TOP TO BOTTOM. SEE C.P. MCKAY, TGM NOTES. |
---|
18 | C THIS SUBROUTINE DIFFERS FROM ITS IR COUNTERPART IN THAT HERE WE SOLVE FOR |
---|
19 | C THE FLUXES DIRECTLY USING THE GENERALIZED NOTATION OF MEADOR AND WEAVOR |
---|
20 | C J.A.S., 37, 630-642, 1980. |
---|
21 | C THE TRI-DIAGONAL MATRIX SOLVER IS DSOLVER AND IS DOUBLE PRECISION SO MANY |
---|
22 | C VARIABLES ARE PASSED AS SINGLE THEN BECOME DOUBLE IN DSOLVER |
---|
23 | C |
---|
24 | C NLL = NUMBER OF LEVELS (NAYER + 1) THAT WILL BE SOLVED |
---|
25 | C NAYER = NUMBER OF LAYERS (NOTE DIFFERENT SPELLING HERE) |
---|
26 | C WAVEN = WAVELENGTH FOR THE COMPUTATION |
---|
27 | C DTDEL(NLAYER) = ARRAY OPTICAL DEPTH OF THE LAYERS |
---|
28 | C TDEL(NLL) = ARRAY COLUMN OPTICAL DEPTH AT THE LEVELS |
---|
29 | C WDEL(NLEVEL) = SINGLE SCATTERING ALBEDO |
---|
30 | C CDEL(NLL) = ASYMMETRY FACTORS, 0=ISOTROPIC |
---|
31 | C UBARV = AVERAGE ANGLE, |
---|
32 | C UBAR0 = SOLAR ZENITH ANGLE |
---|
33 | C F0PI = INCIDENT SOLAR DIRECT BEAM FLUX |
---|
34 | C RSF = SURFACE REFLECTANCE |
---|
35 | C BTOP = UPPER BOUNDARY CONDITION ON DIFFUSE FLUX |
---|
36 | C BSURF = REFLECTED DIRECT BEAM = (1-RSFI)*F0PI*EDP-TAU/U |
---|
37 | C FP(NLEVEL) = UPWARD FLUX AT LEVELS |
---|
38 | C FM(NLEVEL) = DOWNWARD FLUX AT LEVELS |
---|
39 | C FMIDP(NLAYER) = UPWARD FLUX AT LAYER MIDPOINTS |
---|
40 | C FMIDM(NLAYER) = DOWNWARD FLUX AT LAYER MIDPOINTS |
---|
41 | C added Dec 2002 |
---|
42 | C DIFFV = downward diffuse solar flux at the surface |
---|
43 | C |
---|
44 | !======================================================================! |
---|
45 | |
---|
46 | use radinc_h, only: L_TAUMAX, L_NLAYRAD, L_NLEVRAD, L_LEVELS |
---|
47 | |
---|
48 | implicit none |
---|
49 | |
---|
50 | !! INTEGER NLP |
---|
51 | !! PARAMETER (NLP=101) ! MUST BE LARGER THAN NLEVEL |
---|
52 | |
---|
53 | REAL*8 EM, EP, EXPTRM |
---|
54 | REAL*8 W0(L_NLAYRAD), COSBAR(L_NLAYRAD), DTAU(L_NLAYRAD) |
---|
55 | REAL*8 TAU(L_NLEVRAD), WDEL(L_NLAYRAD), CDEL(L_NLAYRAD) |
---|
56 | REAL*8 DTDEL(L_NLAYRAD), TDEL(L_NLEVRAD) |
---|
57 | REAL*8 FMIDP(L_NLAYRAD), FMIDM(L_NLAYRAD) |
---|
58 | REAL*8 LAMDA(L_NLAYRAD), ALPHA(L_NLAYRAD), XK1(L_NLAYRAD) |
---|
59 | REAL*8 XK2(L_NLAYRAD),G1(L_NLAYRAD), G2(L_NLAYRAD) |
---|
60 | REAL*8 G3(L_NLAYRAD), GAMA(L_NLAYRAD),CP(L_NLAYRAD),CM(L_NLAYRAD) |
---|
61 | REAL*8 CPM1(L_NLAYRAD),CMM1(L_NLAYRAD), E1(L_NLAYRAD) |
---|
62 | REAL*8 E2(L_NLAYRAD),E3(L_NLAYRAD),E4(L_NLAYRAD) |
---|
63 | REAL*8 FLUXUP, FLUXDN |
---|
64 | REAL*8 FACTOR, TAUCUMIN(L_LEVELS), TAUCUM(L_LEVELS) |
---|
65 | |
---|
66 | integer NAYER, L, K |
---|
67 | real*8 ubar0, f0pi, rsf, btop, bsurf, g4, denom, am, ap |
---|
68 | real*8 taumax, taumid, cpmid, cmmid |
---|
69 | real*8 diffv |
---|
70 | |
---|
71 | C======================================================================C |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | NAYER = L_NLAYRAD |
---|
77 | TAUMAX = L_TAUMAX !Default is 35.0 |
---|
78 | |
---|
79 | ! Delta-Eddington Scaling |
---|
80 | |
---|
81 | |
---|
82 | FACTOR = 1.0D0 - WDEL(1)*CDEL(1)**2 |
---|
83 | |
---|
84 | TAU(1) = TDEL(1)*FACTOR |
---|
85 | TAUCUM(1) = 0.0D0 |
---|
86 | TAUCUM(2) = TAUCUMIN(2)*FACTOR |
---|
87 | TAUCUM(3) = TAUCUM(2) +(TAUCUMIN(3)-TAUCUMIN(2))*FACTOR |
---|
88 | |
---|
89 | |
---|
90 | DO L=1,L_NLAYRAD-1 |
---|
91 | FACTOR = 1.0D0 - WDEL(L)*CDEL(L)**2 |
---|
92 | W0(L) = WDEL(L)*(1.0D0-CDEL(L)**2)/FACTOR |
---|
93 | COSBAR(L) = CDEL(L)/(1.0D0+CDEL(L)) |
---|
94 | |
---|
95 | DTAU(L) = DTDEL(L)*FACTOR |
---|
96 | TAU(L+1) = TAU(L)+DTAU(L) |
---|
97 | K = 2*(L+1) |
---|
98 | TAUCUM(K) = TAU(L+1) |
---|
99 | TAUCUM(K+1) = TAUCUM(K) + (TAUCUMIN(K+1)-TAUCUMIN(K))*FACTOR |
---|
100 | END DO |
---|
101 | |
---|
102 | ! Bottom layer |
---|
103 | |
---|
104 | L = L_NLAYRAD |
---|
105 | FACTOR = 1.0D0 - WDEL(L)*CDEL(L)**2 |
---|
106 | W0(L) = WDEL(L)*(1.0D0-CDEL(L)**2)/FACTOR |
---|
107 | COSBAR(L) = CDEL(L)/(1.0D0+CDEL(L)) |
---|
108 | DTAU(L) = DTDEL(L)*FACTOR |
---|
109 | TAU(L+1) = TAU(L)+DTAU(L) |
---|
110 | TAUCUM(2*L+1) = TAU(L+1) |
---|
111 | |
---|
112 | BSURF = RSF*UBAR0*F0PI*EXP(-MIN(TAU(L+1),TAUMAX)/UBAR0) |
---|
113 | ! new definition of BSURF |
---|
114 | ! the old one was false because it used tau, not tau' |
---|
115 | ! tau' includes the contribution to the downward flux |
---|
116 | ! of the radiation scattered in the forward direction |
---|
117 | |
---|
118 | C WE GO WITH THE QUADRATURE APPROACH HERE. THE "SQRT(3)" factors |
---|
119 | C ARE THE UBARV TERM. |
---|
120 | |
---|
121 | DO L=1,L_NLAYRAD |
---|
122 | |
---|
123 | ALPHA(L)=SQRT( (1.0-W0(L))/(1.0-W0(L)*COSBAR(L) ) ) |
---|
124 | |
---|
125 | C SET OF CONSTANTS DETERMINED BY DOM |
---|
126 | |
---|
127 | ! Quadrature method |
---|
128 | G1(L) = (SQRT(3.0)*0.5)*(2.0- W0(L)*(1.0+COSBAR(L))) |
---|
129 | G2(L) = (SQRT(3.0)*W0(L)*0.5)*(1.0-COSBAR(L)) |
---|
130 | G3(L) = 0.5*(1.0-SQRT(3.0)*COSBAR(L)*UBAR0) |
---|
131 | |
---|
132 | ! ----- some other methods... (RDW) ------ |
---|
133 | |
---|
134 | ! Eddington method |
---|
135 | ! G1(L) = 0.25*(7.0 - W0(L)*(4.0 - 3.0*COSBAR(L))) |
---|
136 | ! G2(L) = -0.25*(1.0 - W0(L)*(4.0 - 3.0*COSBAR(L))) |
---|
137 | ! G3(L) = 0.25*(2.0 - 3.0*COSBAR(L)*UBAR0) |
---|
138 | |
---|
139 | ! delta-Eddington method |
---|
140 | ! G1(L) = (7.0 - 3.0*g^2 - W0(L)*(4.0 + 3.0*g) + W0(L)*g^2*(4*beta0 + 3*g)) / & |
---|
141 | ! (4* (1 - g^2*() )) 0.25*(7.0 - W0(L)*(4.0 - 3.0*COSBAR(L))) |
---|
142 | |
---|
143 | ! Hybrid modified Eddington-delta function method |
---|
144 | |
---|
145 | ! ---------------------------------------- |
---|
146 | |
---|
147 | c So they use Quadrature |
---|
148 | c but the scaling is Eddington? |
---|
149 | |
---|
150 | LAMDA(L) = SQRT(G1(L)**2 - G2(L)**2) |
---|
151 | GAMA(L) = (G1(L)-LAMDA(L))/G2(L) |
---|
152 | END DO |
---|
153 | |
---|
154 | |
---|
155 | DO L=1,L_NLAYRAD |
---|
156 | G4 = 1.0-G3(L) |
---|
157 | DENOM = LAMDA(L)**2 - 1./UBAR0**2 |
---|
158 | |
---|
159 | C THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0 |
---|
160 | C THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN |
---|
161 | C THE SCATTERING GOES TO ZERO |
---|
162 | C PREVENT THIS WITH AN IF STATEMENT |
---|
163 | |
---|
164 | IF ( DENOM .EQ. 0.) THEN |
---|
165 | DENOM=1.E-10 |
---|
166 | END IF |
---|
167 | |
---|
168 | |
---|
169 | AM = F0PI*W0(L)*(G4 *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM |
---|
170 | AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4 )/DENOM |
---|
171 | |
---|
172 | C CPM1 AND CMM1 ARE THE CPLUS AND CMINUS TERMS EVALUATED |
---|
173 | C AT THE TOP OF THE LAYER, THAT IS LOWER OPTICAL DEPTH TAU(L) |
---|
174 | |
---|
175 | CPM1(L) = AP*EXP(-TAU(L)/UBAR0) |
---|
176 | CMM1(L) = AM*EXP(-TAU(L)/UBAR0) |
---|
177 | |
---|
178 | C CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE |
---|
179 | C BOTTOM OF THE LAYER. THAT IS AT HIGHER OPTICAL DEPTH TAU(L+1) |
---|
180 | |
---|
181 | CP(L) = AP*EXP(-TAU(L+1)/UBAR0) |
---|
182 | CM(L) = AM*EXP(-TAU(L+1)/UBAR0) |
---|
183 | |
---|
184 | END DO |
---|
185 | |
---|
186 | |
---|
187 | |
---|
188 | C NOW CALCULATE THE EXPONENTIAL TERMS NEEDED |
---|
189 | C FOR THE TRIDIAGONAL ROTATED LAYERED METHOD |
---|
190 | |
---|
191 | DO L=1,L_NLAYRAD |
---|
192 | EXPTRM = MIN(TAUMAX,LAMDA(L)*DTAU(L)) ! CLIPPED EXPONENTIAL |
---|
193 | EP = EXP(EXPTRM) |
---|
194 | |
---|
195 | EM = 1.0/EP |
---|
196 | E1(L) = EP+GAMA(L)*EM |
---|
197 | E2(L) = EP-GAMA(L)*EM |
---|
198 | E3(L) = GAMA(L)*EP+EM |
---|
199 | E4(L) = GAMA(L)*EP-EM |
---|
200 | END DO |
---|
201 | |
---|
202 | CALL DSOLVER(NAYER,GAMA,CP,CM,CPM1,CMM1,E1,E2,E3,E4,BTOP, |
---|
203 | * BSURF,RSF,XK1,XK2) |
---|
204 | |
---|
205 | C NOW WE CALCULATE THE FLUXES AT THE MIDPOINTS OF THE LAYERS. |
---|
206 | |
---|
207 | DO L=1,L_NLAYRAD-1 |
---|
208 | EXPTRM = MIN(TAUMAX,LAMDA(L)*(TAUCUM(2*L+1)-TAUCUM(2*L))) |
---|
209 | |
---|
210 | EP = EXP(EXPTRM) |
---|
211 | |
---|
212 | EM = 1.0/EP |
---|
213 | G4 = 1.0-G3(L) |
---|
214 | DENOM = LAMDA(L)**2 - 1./UBAR0**2 |
---|
215 | |
---|
216 | C THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0 |
---|
217 | C THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN |
---|
218 | C THE SCATTERING GOES TO ZERO |
---|
219 | C PREVENT THIS WITH A IF STATEMENT |
---|
220 | |
---|
221 | |
---|
222 | IF ( DENOM .EQ. 0.) THEN |
---|
223 | DENOM=1.E-10 |
---|
224 | END IF |
---|
225 | |
---|
226 | AM = F0PI*W0(L)*(G4 *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM |
---|
227 | AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4 )/DENOM |
---|
228 | |
---|
229 | C CPMID AND CMMID ARE THE CPLUS AND CMINUS TERMS EVALUATED |
---|
230 | C AT THE MIDDLE OF THE LAYER. |
---|
231 | |
---|
232 | TAUMID = TAUCUM(2*L+1) |
---|
233 | |
---|
234 | CPMID = AP*EXP(-TAUMID/UBAR0) |
---|
235 | CMMID = AM*EXP(-TAUMID/UBAR0) |
---|
236 | |
---|
237 | FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID |
---|
238 | FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID |
---|
239 | |
---|
240 | C ADD THE DIRECT FLUX TO THE DOWNWELLING TERM |
---|
241 | |
---|
242 | FMIDM(L)= FMIDM(L)+UBAR0*F0PI*EXP(-MIN(TAUMID,TAUMAX)/UBAR0) |
---|
243 | |
---|
244 | END DO |
---|
245 | |
---|
246 | C FLUX AT THE Ptop layer |
---|
247 | |
---|
248 | ! EP = 1.0 |
---|
249 | ! EM = 1.0 |
---|
250 | C JL18 correction to account for the fact that the radiative top is not at zero optical depth. |
---|
251 | EXPTRM = MIN(TAUMAX,LAMDA(L)*(TAUCUM(2))) |
---|
252 | EP = EXP(EXPTRM) |
---|
253 | EM = 1.0/EP |
---|
254 | G4 = 1.0-G3(1) |
---|
255 | DENOM = LAMDA(1)**2 - 1./UBAR0**2 |
---|
256 | |
---|
257 | C THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0 |
---|
258 | C THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN |
---|
259 | C THE SCATTERING GOES TO ZERO |
---|
260 | C PREVENT THIS WITH A IF STATEMENT |
---|
261 | |
---|
262 | IF ( DENOM .EQ. 0.) THEN |
---|
263 | DENOM=1.E-10 |
---|
264 | END IF |
---|
265 | |
---|
266 | AM = F0PI*W0(1)*(G4 *(G1(1)+1./UBAR0) +G2(1)*G3(1) )/DENOM |
---|
267 | AP = F0PI*W0(1)*(G3(1)*(G1(1)-1./UBAR0) +G2(1)*G4 )/DENOM |
---|
268 | |
---|
269 | C CPMID AND CMMID ARE THE CPLUS AND CMINUS TERMS EVALUATED |
---|
270 | C AT THE MIDDLE OF THE LAYER. |
---|
271 | |
---|
272 | C CPMID = AP |
---|
273 | C CMMID = AM |
---|
274 | C JL18 correction to account for the fact that the radiative top is not at zero optical depth. |
---|
275 | TAUMID = TAUCUM(2) |
---|
276 | CPMID = AP*EXP(-TAUMID/UBAR0) |
---|
277 | CMMID = AM*EXP(-TAUMID/UBAR0) |
---|
278 | |
---|
279 | FLUXUP = XK1(1)*EP + GAMA(1)*XK2(1)*EM + CPMID |
---|
280 | FLUXDN = XK1(1)*EP*GAMA(1) + XK2(1)*EM + CMMID |
---|
281 | |
---|
282 | C ADD THE DIRECT FLUX TO THE DOWNWELLING TERM |
---|
283 | |
---|
284 | ! fluxdn = fluxdn+UBAR0*F0PI*EXP(-MIN(TAUCUM(1),TAUMAX)/UBAR0) |
---|
285 | !JL18 the line above assumed that the top of the radiative model was P=0 |
---|
286 | ! it seems to be better for the IR to use the middle of the last physical layer as the radiative top. |
---|
287 | ! so we correct the downwelling flux below for the calculation of the heating rate |
---|
288 | fluxdn = fluxdn+UBAR0*F0PI*EXP(-TAUCUM(2)/UBAR0) |
---|
289 | |
---|
290 | C This is for the "special" bottom layer, where we take |
---|
291 | C DTAU instead of DTAU/2. |
---|
292 | |
---|
293 | L = L_NLAYRAD |
---|
294 | EXPTRM = MIN(TAUMAX,LAMDA(L)*(TAUCUM(L_LEVELS)- |
---|
295 | * TAUCUM(L_LEVELS-1))) |
---|
296 | |
---|
297 | EP = EXP(EXPTRM) |
---|
298 | EM = 1.0/EP |
---|
299 | G4 = 1.0-G3(L) |
---|
300 | DENOM = LAMDA(L)**2 - 1./UBAR0**2 |
---|
301 | |
---|
302 | |
---|
303 | C THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0 |
---|
304 | C THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN |
---|
305 | C THE SCATTERING GOES TO ZERO |
---|
306 | C PREVENT THIS WITH A IF STATEMENT |
---|
307 | |
---|
308 | |
---|
309 | IF ( DENOM .EQ. 0.) THEN |
---|
310 | DENOM=1.E-10 |
---|
311 | END IF |
---|
312 | |
---|
313 | AM = F0PI*W0(L)*(G4 *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM |
---|
314 | AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4 )/DENOM |
---|
315 | |
---|
316 | C CPMID AND CMMID ARE THE CPLUS AND CMINUS TERMS EVALUATED |
---|
317 | C AT THE MIDDLE OF THE LAYER. |
---|
318 | |
---|
319 | TAUMID = MIN(TAUCUM(L_LEVELS),TAUMAX) |
---|
320 | CPMID = AP*EXP(-MIN(TAUMID,TAUMAX)/UBAR0) |
---|
321 | CMMID = AM*EXP(-MIN(TAUMID,TAUMAX)/UBAR0) |
---|
322 | |
---|
323 | |
---|
324 | FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID |
---|
325 | FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID |
---|
326 | |
---|
327 | C Save the diffuse downward flux for TEMPGR calculations |
---|
328 | |
---|
329 | DIFFV = FMIDM(L) |
---|
330 | |
---|
331 | |
---|
332 | C ADD THE DIRECT FLUX TO THE DOWNWELLING TERM |
---|
333 | |
---|
334 | FMIDM(L)= FMIDM(L)+UBAR0*F0PI*EXP(-MIN(TAUMID,TAUMAX)/UBAR0) |
---|
335 | |
---|
336 | |
---|
337 | END SUBROUTINE GFLUXV |
---|
338 | |
---|
339 | end module gfluxv_mod |
---|