1 | SUBROUTINE GFLUXI(NLL,TLEV,NW,DW,DTAU,TAUCUM,W0,COSBAR,UBARI, |
---|
2 | * RSF,BTOP,BSURF,FTOPUP,FMIDP,FMIDM) |
---|
3 | |
---|
4 | C THIS SUBROUTINE TAKES THE OPTICAL CONSTANTS AND BOUNDARY CONDITIONS |
---|
5 | C FOR THE INFRARED FLUX AT ONE WAVELENGTH AND SOLVES FOR THE FLUXES AT |
---|
6 | C THE LEVELS. THIS VERSION IS SET UP TO WORK WITH LAYER OPTICAL DEPTHS |
---|
7 | C MEASURED FROM THE TOP OF EACH LAYER. THE TOP OF EACH LAYER HAS |
---|
8 | C OPTICAL DEPTH ZERO. IN THIS SUB LEVEL N IS ABOVE LAYER N. THAT IS LAYER N |
---|
9 | C HAS LEVEL N ON TOP AND LEVEL N+1 ON BOTTOM. OPTICAL DEPTH INCREASES |
---|
10 | C FROM TOP TO BOTTOM. SEE C.P. MCKAY, TGM NOTES. |
---|
11 | C THE TRI-DIAGONAL MATRIX SOLVER IS DSOLVER AND IS DOUBLE PRECISION SO MANY |
---|
12 | C VARIABLES ARE PASSED AS SINGLE THEN BECOME DOUBLE IN DSOLVER |
---|
13 | C |
---|
14 | C NLL = NUMBER OF LEVELS (NLAYERS + 1) MUST BE LESS THAT NL (101) |
---|
15 | C TLEV(L_LEVELS) = ARRAY OF TEMPERATURES AT GCM LEVELS |
---|
16 | C WAVEN = WAVELENGTH FOR THE COMPUTATION |
---|
17 | C DW = WAVENUMBER INTERVAL |
---|
18 | C DTAU(NLAYER) = ARRAY OPTICAL DEPTH OF THE LAYERS |
---|
19 | C W0(NLEVEL) = SINGLE SCATTERING ALBEDO |
---|
20 | C COSBAR(NLEVEL) = ASYMMETRY FACTORS, 0=ISOTROPIC |
---|
21 | C UBARI = AVERAGE ANGLE, MUST BE EQUAL TO 0.5 IN IR |
---|
22 | C RSF = SURFACE REFLECTANCE |
---|
23 | C BTOP = UPPER BOUNDARY CONDITION ON IR INTENSITY (NOT FLUX) |
---|
24 | C BSURF = SURFACE EMISSION = (1-RSFI)*PLANCK, INTENSITY (NOT FLUX) |
---|
25 | C FP(NLEVEL) = UPWARD FLUX AT LEVELS |
---|
26 | C FM(NLEVEL) = DOWNWARD FLUX AT LEVELS |
---|
27 | C FMIDP(NLAYER) = UPWARD FLUX AT LAYER MIDPOINTS |
---|
28 | C FMIDM(NLAYER) = DOWNWARD FLUX AT LAYER MIDPOINTS |
---|
29 | C |
---|
30 | C----------------------------------------------------------------------C |
---|
31 | |
---|
32 | use radinc_h |
---|
33 | use radcommon_h, only: planckir |
---|
34 | use comcstfi_mod, only: pi |
---|
35 | |
---|
36 | implicit none |
---|
37 | |
---|
38 | |
---|
39 | INTEGER NLL, NLAYER, L, NW, NT, NT2 |
---|
40 | REAL*8 TERM, CPMID, CMMID |
---|
41 | REAL*8 PLANCK |
---|
42 | REAL*8 EM,EP |
---|
43 | REAL*8 COSBAR(L_NLAYRAD), W0(L_NLAYRAD), DTAU(L_NLAYRAD) |
---|
44 | REAL*8 TAUCUM(L_LEVELS), DTAUK |
---|
45 | REAL*8 TLEV(L_LEVELS) |
---|
46 | REAL*8 WAVEN, DW, UBARI, RSF |
---|
47 | REAL*8 BTOP, BSURF, FMIDP(L_NLAYRAD), FMIDM(L_NLAYRAD) |
---|
48 | REAL*8 B0(L_NLAYRAD),B1(L_NLAYRAD),ALPHA(L_NLAYRAD) |
---|
49 | REAL*8 LAMDA(L_NLAYRAD),XK1(L_NLAYRAD),XK2(L_NLAYRAD) |
---|
50 | REAL*8 GAMA(L_NLAYRAD),CP(L_NLAYRAD),CM(L_NLAYRAD) |
---|
51 | REAL*8 CPM1(L_NLAYRAD),CMM1(L_NLAYRAD),E1(L_NLAYRAD) |
---|
52 | REAL*8 E2(L_NLAYRAD),E3(L_NLAYRAD),E4(L_NLAYRAD) |
---|
53 | |
---|
54 | REAL*8 FTOPUP, FLUXUP, FLUXDN |
---|
55 | |
---|
56 | real*8 :: TAUMAX = L_TAUMAX |
---|
57 | |
---|
58 | C======================================================================C |
---|
59 | |
---|
60 | C WE GO WITH THE HEMISPHERIC CONSTANT APPROACH IN THE INFRARED |
---|
61 | |
---|
62 | |
---|
63 | NLAYER = L_NLAYRAD |
---|
64 | |
---|
65 | DO L=1,L_NLAYRAD-1 |
---|
66 | |
---|
67 | !---------------------------------------------------- |
---|
68 | ! There is a problem when W0 = 1 |
---|
69 | ! open(888,file='W0') |
---|
70 | ! if ((W0(L).eq.0.).or.(W0(L).eq.1.)) then |
---|
71 | ! write(888,*) W0(L), L, 'gfluxi' |
---|
72 | ! endif |
---|
73 | ! Prevent this with an if statement: |
---|
74 | if (W0(L).eq.1.D0) then |
---|
75 | W0(L) = 0.99999D0 |
---|
76 | endif |
---|
77 | !---------------------------------------------------- |
---|
78 | |
---|
79 | ALPHA(L) = SQRT( (1.0D0-W0(L))/(1.0D0-W0(L)*COSBAR(L)) ) |
---|
80 | LAMDA(L) = ALPHA(L)*(1.0D0-W0(L)*COSBAR(L))/UBARI |
---|
81 | |
---|
82 | NT = int(TLEV(2*L)*NTfac) - NTstar+1 |
---|
83 | NT2 = int(TLEV(2*L+2)*NTfac) - NTstar+1 |
---|
84 | |
---|
85 | B1(L) = (PLANCKIR(NW,NT2)-PLANCKIR(NW,NT))/DTAU(L) |
---|
86 | B0(L) = PLANCKIR(NW,NT) |
---|
87 | END DO |
---|
88 | |
---|
89 | C Take care of special lower layer |
---|
90 | |
---|
91 | L = L_NLAYRAD |
---|
92 | |
---|
93 | if (W0(L).eq.1.) then |
---|
94 | W0(L) = 0.99999D0 |
---|
95 | end if |
---|
96 | |
---|
97 | ALPHA(L) = SQRT( (1.0D0-W0(L))/(1.0D0-W0(L)*COSBAR(L)) ) |
---|
98 | LAMDA(L) = ALPHA(L)*(1.0D0-W0(L)*COSBAR(L))/UBARI |
---|
99 | |
---|
100 | ! Tsurf is used for 1st layer source function |
---|
101 | ! -- same results for most thin atmospheres |
---|
102 | ! -- and stabilizes integrations |
---|
103 | NT = int(TLEV(2*L+1)*NTfac) - NTstar+1 |
---|
104 | !! For deep, opaque, thick first layers (e.g. Saturn) |
---|
105 | !! what is below works much better, not unstable, ... |
---|
106 | !! ... and actually fully accurate because 1st layer temp (JL) |
---|
107 | !NT = int(TLEV(2*L)*NTfac) - NTstar+1 |
---|
108 | !! (or this one yields same results |
---|
109 | !NT = int( (TLEV(2*L)+TLEV(2*L+1))*0.5*NTfac ) - NTstar+1 |
---|
110 | |
---|
111 | NT2 = int(TLEV(2*L)*NTfac) - NTstar+1 |
---|
112 | B1(L) = (PLANCKIR(NW,NT)-PLANCKIR(NW,NT2))/DTAU(L) |
---|
113 | B0(L) = PLANCKIR(NW,NT2) |
---|
114 | |
---|
115 | DO L=1,L_NLAYRAD |
---|
116 | GAMA(L) = (1.0D0-ALPHA(L))/(1.0D0+ALPHA(L)) |
---|
117 | TERM = UBARI/(1.0D0-W0(L)*COSBAR(L)) |
---|
118 | |
---|
119 | C CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE |
---|
120 | C BOTTOM OF THE LAYER. THAT IS AT DTAU OPTICAL DEPTH |
---|
121 | |
---|
122 | CP(L) = B0(L)+B1(L)*DTAU(L) +B1(L)*TERM |
---|
123 | CM(L) = B0(L)+B1(L)*DTAU(L) -B1(L)*TERM |
---|
124 | |
---|
125 | C CPM1 AND CMM1 ARE THE CPLUS AND CMINUS TERMS EVALUATED |
---|
126 | C AT THE TOP OF THE LAYER, THAT IS ZERO OPTICAL DEPTH |
---|
127 | |
---|
128 | CPM1(L) = B0(L)+B1(L)*TERM |
---|
129 | CMM1(L) = B0(L)-B1(L)*TERM |
---|
130 | END DO |
---|
131 | |
---|
132 | C NOW CALCULATE THE EXPONENTIAL TERMS NEEDED |
---|
133 | C FOR THE TRIDIAGONAL ROTATED LAYERED METHOD |
---|
134 | C WARNING IF DTAU(J) IS GREATER THAN ABOUT 35 (VAX) |
---|
135 | C WE CLIP IT TO AVOID OVERFLOW. |
---|
136 | |
---|
137 | DO L=1,L_NLAYRAD |
---|
138 | |
---|
139 | C CLIP THE EXPONENTIAL HERE. |
---|
140 | |
---|
141 | EP = EXP( MIN((LAMDA(L)*DTAU(L)),TAUMAX)) |
---|
142 | EM = 1.0D0/EP |
---|
143 | E1(L) = EP+GAMA(L)*EM |
---|
144 | E2(L) = EP-GAMA(L)*EM |
---|
145 | E3(L) = GAMA(L)*EP+EM |
---|
146 | E4(L) = GAMA(L)*EP-EM |
---|
147 | END DO |
---|
148 | |
---|
149 | c B81=BTOP ! RENAME BEFORE CALLING DSOLVER - used to be to set |
---|
150 | c B82=BSURF ! them to real*8 - but now everything is real*8 |
---|
151 | c R81=RSF ! so this may not be necessary |
---|
152 | |
---|
153 | C Double precision tridiagonal solver |
---|
154 | |
---|
155 | CALL DSOLVER(NLAYER,GAMA,CP,CM,CPM1,CMM1,E1,E2,E3,E4,BTOP, |
---|
156 | * BSURF,RSF,XK1,XK2) |
---|
157 | |
---|
158 | |
---|
159 | C NOW WE CALCULATE THE FLUXES AT THE MIDPOINTS OF THE LAYERS. |
---|
160 | |
---|
161 | DO L=1,L_NLAYRAD-1 |
---|
162 | DTAUK = TAUCUM(2*L+1)-TAUCUM(2*L) |
---|
163 | EP = EXP(MIN(LAMDA(L)*DTAUK,TAUMAX)) ! CLIPPED EXPONENTIAL |
---|
164 | EM = 1.0D0/EP |
---|
165 | TERM = UBARI/(1.D0-W0(L)*COSBAR(L)) |
---|
166 | |
---|
167 | C CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE |
---|
168 | C BOTTOM OF THE LAYER. THAT IS AT DTAU OPTICAL DEPTH |
---|
169 | |
---|
170 | CPMID = B0(L)+B1(L)*DTAUK +B1(L)*TERM |
---|
171 | CMMID = B0(L)+B1(L)*DTAUK -B1(L)*TERM |
---|
172 | FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID |
---|
173 | FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID |
---|
174 | |
---|
175 | C FOR FLUX WE INTEGRATE OVER THE HEMISPHERE TREATING INTENSITY CONSTANT |
---|
176 | |
---|
177 | FMIDP(L) = FMIDP(L)*PI |
---|
178 | FMIDM(L) = FMIDM(L)*PI |
---|
179 | END DO |
---|
180 | |
---|
181 | C And now, for the special bottom layer |
---|
182 | |
---|
183 | L = L_NLAYRAD |
---|
184 | |
---|
185 | EP = EXP(MIN((LAMDA(L)*DTAU(L)),TAUMAX)) ! CLIPPED EXPONENTIAL |
---|
186 | EM = 1.0D0/EP |
---|
187 | TERM = UBARI/(1.D0-W0(L)*COSBAR(L)) |
---|
188 | |
---|
189 | C CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE |
---|
190 | C BOTTOM OF THE LAYER. THAT IS AT DTAU OPTICAL DEPTH |
---|
191 | |
---|
192 | CPMID = B0(L)+B1(L)*DTAU(L) +B1(L)*TERM |
---|
193 | CMMID = B0(L)+B1(L)*DTAU(L) -B1(L)*TERM |
---|
194 | FMIDP(L) = XK1(L)*EP + GAMA(L)*XK2(L)*EM + CPMID |
---|
195 | FMIDM(L) = XK1(L)*EP*GAMA(L) + XK2(L)*EM + CMMID |
---|
196 | |
---|
197 | C FOR FLUX WE INTEGRATE OVER THE HEMISPHERE TREATING INTENSITY CONSTANT |
---|
198 | |
---|
199 | FMIDP(L) = FMIDP(L)*PI |
---|
200 | FMIDM(L) = FMIDM(L)*PI |
---|
201 | |
---|
202 | C FLUX AT THE PTOP LEVEL |
---|
203 | |
---|
204 | EP = 1.0D0 |
---|
205 | EM = 1.0D0 |
---|
206 | TERM = UBARI/(1.0D0-W0(1)*COSBAR(1)) |
---|
207 | |
---|
208 | C CP AND CM ARE THE CPLUS AND CMINUS TERMS EVALUATED AT THE |
---|
209 | C BOTTOM OF THE LAYER. THAT IS AT DTAU OPTICAL DEPTH |
---|
210 | |
---|
211 | CPMID = B0(1)+B1(1)*TERM |
---|
212 | CMMID = B0(1)-B1(1)*TERM |
---|
213 | |
---|
214 | FLUXUP = XK1(1)*EP + GAMA(1)*XK2(1)*EM + CPMID |
---|
215 | FLUXDN = XK1(1)*EP*GAMA(1) + XK2(1)*EM + CMMID |
---|
216 | |
---|
217 | C FOR FLUX WE INTEGRATE OVER THE HEMISPHERE TREATING INTENSITY CONSTANT |
---|
218 | |
---|
219 | FTOPUP = (FLUXUP-FLUXDN)*PI |
---|
220 | |
---|
221 | |
---|
222 | RETURN |
---|
223 | END |
---|