source: trunk/LMDZ.PLUTO.old/libf/phypluto/gfluxv.F_verbose @ 3436

Last change on this file since 3436 was 3175, checked in by emillour, 11 months ago

Pluto PCM:
Add the old Pluto LMDZ for reference (required prior step to making
an LMDZ.PLUTO using the same framework as the other physics packages).
TB+EM

File size: 9.9 KB
Line 
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(L_NLAYRAD), ALPHA(L_NLAYRAD), XK1(L_NLAYRAD)
53      REAL*8 XK2(L_NLAYRAD),G1(L_NLAYRAD), G2(L_NLAYRAD)
54      REAL*8 G3(L_NLAYRAD), GAMA(L_NLAYRAD),CP(L_NLAYRAD),CM(L_NLAYRAD)
55      REAL*8 CPM1(L_NLAYRAD),CMM1(L_NLAYRAD), E1(L_NLAYRAD)
56      REAL*8 E2(L_NLAYRAD),E3(L_NLAYRAD),E4(L_NLAYRAD),EXPTRM(L_NLAYRAD)
57      REAL*8 FLUXUP, FLUXDN
58      REAL*8 FACTOR, TAUCUMIN(L_LEVELS), TAUCUM(L_LEVELS)
59
60      integer NAYER, L, K
61      real*8  ubar0, f0pi, rsf, btop, bsurf, g4, denom, am, ap
62      real*8  taumax, taumid, cpmid, cmmid
63      real*8  diffv
64
65C======================================================================C
66
67
68
69
70      NAYER  = L_NLAYRAD
71      TAUMAX = L_TAUMAX    !Default is 35.0
72     
73!  Delta-Eddington Scaling
74
75
76      FACTOR    = 1.0D0 - WDEL(1)*CDEL(1)**2
77
78      TAU(1)    = TDEL(1)*FACTOR
79      TAUCUM(1) = 0.0D0
80      TAUCUM(2) = TAUCUMIN(2)*FACTOR
81      TAUCUM(3) = TAUCUM(2) +(TAUCUMIN(3)-TAUCUMIN(2))*FACTOR
82
83      Print*, 'TBbug wdel= ',WDEL
84      Print*, 'TBbug cdel= ',CDEL
85
86      DO L=1,L_NLAYRAD-1
87        FACTOR      = 1.0D0 - WDEL(L)*CDEL(L)**2
88        W0(L)       = WDEL(L)*(1.0D0-CDEL(L)**2)/FACTOR
89        COSBAR(L)   = CDEL(L)/(1.0D0+CDEL(L))
90        DTAU(L)     = DTDEL(L)*FACTOR
91        TAU(L+1)    = TAU(L)+DTAU(L)
92        K           = 2*(L+1)
93        TAUCUM(K)   = TAU(L+1)
94        TAUCUM(K+1) = TAUCUM(K) + (TAUCUMIN(K+1)-TAUCUMIN(K))*FACTOR
95      END DO
96      !write(*,*),'gfluxv : cosbar=',COSBAR
97      !write(*,*),'gfluxv : w0, factor=',W0(1),FACTOR
98      !write(*,*),'gfluxv : wdel, cdel',WDEL(1),CDEL(1)
99
100
101!  Bottom layer
102
103      L             = L_NLAYRAD
104      FACTOR        = 1.0D0 - WDEL(L)*CDEL(L)**2
105      W0(L)         = WDEL(L)*(1.0D0-CDEL(L)**2)/FACTOR
106      COSBAR(L)     = CDEL(L)/(1.0D0+CDEL(L))
107      DTAU(L)       = DTDEL(L)*FACTOR
108      TAU(L+1)      = TAU(L)+DTAU(L)
109      TAUCUM(2*L+1) = TAU(L+1)
110
111      write(*,*),'gfluxv : w0(L), factor=',W0(L),FACTOR
112
113C     WE GO WITH THE QUADRATURE APPROACH HERE.  THE "SQRT(3)" factors
114C     ARE THE UBARV TERM.
115
116      DO L=1,L_NLAYRAD
117       
118        write(*,*),'gfluxv : alpha',L,W0(L),(1.0-W0(L)*COSBAR(L))
119
120        ALPHA(L)=SQRT( (1.0-W0(L))/(1.0-W0(L)*COSBAR(L)) )
121!        write(*,*),'gfluxv : alpha = ',ALPHA(L)
122
123
124C       SET OF CONSTANTS DETERMINED BY DOM
125
126        G1(L)    = (SQRT(3.0)*0.5)*(2.0- W0(L)*(1.0+COSBAR(L)))
127        G2(L)    = (SQRT(3.0)*W0(L)*0.5)*(1.0-COSBAR(L))
128        G3(L)    = 0.5*(1.0-SQRT(3.0)*COSBAR(L)*UBAR0)
129
130
131c     this is Quadrature
132c     but the scaling is Eddington?
133
134        LAMDA(L) = SQRT(G1(L)**2 - G2(L)**2)
135        Print*, 'TBbug = ',LAMDA
136        GAMA(L)  = (G1(L)-LAMDA(L))/G2(L)
137        write(*,*),'gfluxv : g2= ',G2(L),L
138      END DO
139      write(*,*),'gfluxv : check1'
140
141      DO L=1,L_NLAYRAD
142        G4    = 1.0-G3(L)
143        DENOM = LAMDA(L)**2 - 1./UBAR0**2
144 
145C       THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
146C       THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN
147C       THE SCATTERING GOES TO ZERO
148C       PREVENT THIS WITH AN IF STATEMENT
149
150        IF ( DENOM .EQ. 0.) THEN
151          DENOM=1.E-10
152        END IF
153
154
155        AM = F0PI*W0(L)*(G4   *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM
156        AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4    )/DENOM
157
158C       CPM1 AND CMM1 ARE THE CPLUS AND CMINUS TERMS EVALUATED
159C       AT THE TOP OF THE LAYER, THAT IS LOWER   OPTICAL DEPTH TAU(L)
160 
161        CPM1(L) = AP*EXP(-TAU(L)/UBAR0)
162        CMM1(L) = AM*EXP(-TAU(L)/UBAR0)
163
164C       CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE
165C       BOTTOM OF THE LAYER.  THAT IS AT HIGHER OPTICAL DEPTH TAU(L+1)
166
167        CP(L) = AP*EXP(-TAU(L+1)/UBAR0)
168        CM(L) = AM*EXP(-TAU(L+1)/UBAR0)
169
170      END DO
171      write(*,*),'gfluxv : check2'
172
173
174 
175C     NOW CALCULATE THE EXPONENTIAL TERMS NEEDED
176C     FOR THE TRIDIAGONAL ROTATED LAYERED METHOD
177
178      DO L=1,L_NLAYRAD
179        !print*, 'TBbug=',TAUMAX,LAMDA(L),DTAU(L)
180        EXPTRM(L) = MIN(TAUMAX,LAMDA(L)*DTAU(L))  ! CLIPPED EXPONENTIAL
181        EP = EXP(EXPTRM(L))
182
183        EM        = 1.0/EP
184        E1(L)     = EP+GAMA(L)*EM
185        E2(L)     = EP-GAMA(L)*EM
186        E3(L)     = GAMA(L)*EP+EM
187        E4(L)     = GAMA(L)*EP-EM
188      END DO
189      write(*,*),'gfluxv : check3'
190
191      CALL DSOLVER(NAYER,GAMA,CP,CM,CPM1,CMM1,E1,E2,E3,E4,BTOP,
192     *             BSURF,RSF,XK1,XK2)
193      write(*,*),'gfluxv : check31'
194
195C     NOW WE CALCULATE THE FLUXES AT THE MIDPOINTS OF THE LAYERS.
196 
197      DO L=1,L_NLAYRAD-1
198        EXPTRM(L) = MIN(TAUMAX,LAMDA(L)*(TAUCUM(2*L+1)-TAUCUM(2*L)))
199 
200        EP = EXP(EXPTRM(L))
201
202        EM    = 1.0/EP
203        G4    = 1.0-G3(L)
204        DENOM = LAMDA(L)**2 - 1./UBAR0**2
205
206C       THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
207C       THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN
208C       THE SCATTERING GOES TO ZERO
209C       PREVENT THIS WITH A IF STATEMENT
210
211
212        IF ( DENOM .EQ. 0.) THEN
213          DENOM=1.E-10
214        END IF
215
216        AM = F0PI*W0(L)*(G4   *(G1(L)+1./UBAR0) +G2(L)*G3(L) )/DENOM
217        AP = F0PI*W0(L)*(G3(L)*(G1(L)-1./UBAR0) +G2(L)*G4    )/DENOM
218
219C       CPMID AND CMMID  ARE THE CPLUS AND CMINUS TERMS EVALUATED
220C       AT THE MIDDLE OF THE LAYER.
221
222        TAUMID   = TAUCUM(2*L+1)
223
224        CPMID = AP*EXP(-TAUMID/UBAR0)
225        CMMID = AM*EXP(-TAUMID/UBAR0)
226
227        FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID
228        FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID
229 
230C       ADD THE DIRECT FLUX TO THE DOWNWELLING TERM
231
232        FMIDM(L)= FMIDM(L)+UBAR0*F0PI*EXP(-MIN(TAUMID,TAUMAX)/UBAR0)
233   
234      END DO
235      write(*,*),'gfluxv : check4'
236 
237C     FLUX AT THE Ptop layer
238
239      EP    = 1.0
240      EM    = 1.0
241      G4    = 1.0-G3(1)
242      DENOM = LAMDA(1)**2 - 1./UBAR0**2
243
244C     THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
245C     THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN
246C     THE SCATTERING GOES TO ZERO
247C     PREVENT THIS WITH A IF STATEMENT
248
249      IF ( DENOM .EQ. 0.) THEN
250        DENOM=1.E-10
251      END IF
252
253      AM = F0PI*W0(1)*(G4   *(G1(1)+1./UBAR0) +G2(1)*G3(1) )/DENOM
254      AP = F0PI*W0(1)*(G3(1)*(G1(1)-1./UBAR0) +G2(1)*G4    )/DENOM
255
256C     CPMID AND CMMID  ARE THE CPLUS AND CMINUS TERMS EVALUATED
257C     AT THE MIDDLE OF THE LAYER.
258
259      CPMID  = AP
260      CMMID  = AM
261
262      FLUXUP = XK1(1)*EP + GAMA(1)*XK2(1)*EM + CPMID
263      FLUXDN = XK1(1)*EP*GAMA(1) + XK2(1)*EM + CMMID
264
265C     ADD THE DIRECT FLUX TO THE DOWNWELLING TERM
266
267      fluxdn = fluxdn+UBAR0*F0PI*EXP(-MIN(TAUCUM(1),TAUMAX)/UBAR0)
268 
269C     This is for the "special" bottom layer, where we take
270C     DTAU instead of DTAU/2.
271
272      L     = L_NLAYRAD
273      EXPTRM(L) = MIN(TAUMAX,LAMDA(L)*(TAUCUM(L_LEVELS)-
274     *                                 TAUCUM(L_LEVELS-1)))
275
276      EP    = EXP(EXPTRM(L))
277      EM    = 1.0/EP
278      G4    = 1.0-G3(L)
279      DENOM = LAMDA(L)**2 - 1./UBAR0**2
280
281
282
283C     THERE IS A POTENTIAL PROBLEM HERE IF W0=0 AND UBARV=UBAR0
284C     THEN DENOM WILL VANISH. THIS ONLY HAPPENS PHYSICALLY WHEN
285C     THE SCATTERING GOES TO ZERO
286C     PREVENT THIS WITH A IF STATEMENT
287      write(*,*),'gfluxv : check5'
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
319
320      RETURN
321
322
323      END
Note: See TracBrowser for help on using the repository browser.