source: trunk/LMDZ.PLUTO/libf/phypluto/gfluxv.F @ 3409

Last change on this file since 3409 was 3409, checked in by afalco, 3 months ago

Pluto PCM:
Take into account zeros in aerosol optical properties.
AF

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