source: trunk/LMDZ.GENERIC/libf/phystd/gfluxv.F @ 1243

Last change on this file since 1243 was 253, checked in by emillour, 13 years ago

Generic GCM

  • Massive update to version 0.7

EM+RW

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