1 | MODULE optcv_pluto_mod |
---|
2 | |
---|
3 | IMPLICIT NONE |
---|
4 | |
---|
5 | CONTAINS |
---|
6 | |
---|
7 | SUBROUTINE OPTCV_pluto(DTAUV,TAUV,TAUCUMV,PLEV, & |
---|
8 | QXVAER,QSVAER,GVAER,WBARV,COSBV, & |
---|
9 | TAURAY,TAUAERO,TMID,PMID,TAUGSURF,QVAR) |
---|
10 | |
---|
11 | use radinc_h, only: L_NLAYRAD, L_NLEVRAD, L_LEVELS, L_NSPECTV, L_NGAUSS, L_REFVAR, NAERKIND |
---|
12 | use radcommon_h, only: gasv, tlimit, wrefVAR, Cmk, tgasref, pfgasref,wnov,scalep,indv,glat_ig |
---|
13 | use gases_h, only: gfrac, ngasmx, igas_H2, igas_H2O, igas_He, igas_N2, & |
---|
14 | igas_CH4, igas_N2 |
---|
15 | use comcstfi_mod, only: g, r, mugaz |
---|
16 | use callkeys_mod, only: kastprof,continuum,graybody,callgasvis |
---|
17 | use recombin_corrk_mod, only: corrk_recombin, gasv_recomb |
---|
18 | use tpindex_mod, only: tpindex |
---|
19 | |
---|
20 | implicit none |
---|
21 | |
---|
22 | !================================================================== |
---|
23 | ! |
---|
24 | ! Purpose |
---|
25 | ! ------- |
---|
26 | ! Calculates shortwave optical constants at each level. |
---|
27 | ! |
---|
28 | ! Authors |
---|
29 | ! ------- |
---|
30 | ! Adapted from the NASA Ames code by R. Wordsworth (2009) |
---|
31 | ! |
---|
32 | !================================================================== |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | ! THIS SUBROUTINE SETS THE OPTICAL CONSTANTS IN THE VISUAL |
---|
37 | ! IT CALCUALTES FOR EACH LAYER, FOR EACH SPECRAL INTERVAL IN THE VISUAL |
---|
38 | ! LAYER: WBAR, DTAU, COSBAR |
---|
39 | ! LEVEL: TAU |
---|
40 | ! |
---|
41 | ! TAUV(L,NW,NG) is the cumulative optical depth at the top of radiation code |
---|
42 | ! layer L. NW is spectral wavelength interval, ng the Gauss point index. |
---|
43 | ! |
---|
44 | ! TLEV(L) - Temperature at the layer boundary |
---|
45 | ! PLEV(L) - Pressure at the layer boundary (i.e. level) |
---|
46 | ! GASV(NT,NPS,NW,NG) - Visual CO2 k-coefficients |
---|
47 | ! |
---|
48 | !----------------------------------------------------------------------C |
---|
49 | |
---|
50 | |
---|
51 | real*8 DTAUV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) |
---|
52 | real*8 DTAUKV(L_LEVELS,L_NSPECTV,L_NGAUSS) |
---|
53 | real*8 TAUV(L_NLEVRAD,L_NSPECTV,L_NGAUSS) |
---|
54 | real*8 TAUCUMV(L_LEVELS,L_NSPECTV,L_NGAUSS) |
---|
55 | real*8 PLEV(L_LEVELS) |
---|
56 | real*8 TMID(L_LEVELS), PMID(L_LEVELS) |
---|
57 | real*8 COSBV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) |
---|
58 | real*8 WBARV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) |
---|
59 | |
---|
60 | ! For aerosols |
---|
61 | real*8 QXVAER(L_LEVELS,L_NSPECTV,NAERKIND) |
---|
62 | real*8 QSVAER(L_LEVELS,L_NSPECTV,NAERKIND) |
---|
63 | real*8 GVAER(L_LEVELS,L_NSPECTV,NAERKIND) |
---|
64 | real*8 TAUAERO(L_LEVELS,NAERKIND) |
---|
65 | real*8 TAUAEROLK(L_LEVELS,L_NSPECTV,NAERKIND) |
---|
66 | real*8 TAEROS(L_LEVELS,L_NSPECTV,NAERKIND) |
---|
67 | |
---|
68 | integer L, NW, NG, K, NG1(L_NSPECTV), LK, IAER |
---|
69 | integer MT(L_LEVELS), MP(L_LEVELS), NP(L_LEVELS) |
---|
70 | real*8 ANS, TAUGAS |
---|
71 | real*8 TAURAY(L_NSPECTV) |
---|
72 | real*8 TRAY(L_LEVELS,L_NSPECTV) |
---|
73 | real*8 DPR(L_LEVELS), U(L_LEVELS) |
---|
74 | real*8 LCOEF(4), LKCOEF(L_LEVELS,4) |
---|
75 | |
---|
76 | real*8 taugsurf(L_NSPECTV,L_NGAUSS-1), TRAYAER |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | |
---|
81 | |
---|
82 | ! mixing ratio variables |
---|
83 | real*8 QVAR(L_LEVELS), WRATIO(L_LEVELS) |
---|
84 | real*8 KCOEF(4) |
---|
85 | integer NVAR(L_LEVELS) |
---|
86 | |
---|
87 | ! temporary variables for multiple aerosol calculation |
---|
88 | real*8 atemp(L_NLAYRAD,L_NSPECTV) |
---|
89 | real*8 btemp(L_NLAYRAD,L_NSPECTV) |
---|
90 | real*8 ctemp(L_NLAYRAD,L_NSPECTV) |
---|
91 | |
---|
92 | ! variables for k in units m^-1 |
---|
93 | real*8 rho, dz |
---|
94 | |
---|
95 | !======================================================================= |
---|
96 | ! Determine the total gas opacity throughout the column, for each |
---|
97 | ! spectral interval, NW, and each Gauss point, NG. |
---|
98 | ! Calculate the continuum opacities, i.e., those that do not depend on |
---|
99 | ! NG, the Gauss index. |
---|
100 | |
---|
101 | taugsurf(:,:) = 0.0 |
---|
102 | |
---|
103 | do K=2,L_LEVELS |
---|
104 | DPR(K) = PLEV(K)-PLEV(K-1) |
---|
105 | |
---|
106 | |
---|
107 | ! rho = PLEV(K)/(R*TMID(K)) |
---|
108 | rho = PMID(K)/(R*TMID(K)) |
---|
109 | dz = -DPR(k)/(g*rho) |
---|
110 | |
---|
111 | U(k) = Cmk*DPR(k) |
---|
112 | |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | call tpindex(PMID(K),TMID(K),QVAR(K),pfgasref,tgasref,WREFVAR, & |
---|
117 | LCOEF,MT(K),MP(K),NVAR(K),WRATIO(K)) |
---|
118 | |
---|
119 | do LK=1,4 |
---|
120 | LKCOEF(K,LK) = LCOEF(LK) |
---|
121 | end do |
---|
122 | end do ! levels |
---|
123 | |
---|
124 | ! Spectral dependance of aerosol absorption |
---|
125 | do iaer=1,naerkind |
---|
126 | do NW=1,L_NSPECTV |
---|
127 | do K=2,L_LEVELS |
---|
128 | TAEROS(K,NW,IAER) = TAUAERO(K,IAER) * QXVAER(K,NW,IAER) |
---|
129 | end do |
---|
130 | end do |
---|
131 | end do |
---|
132 | |
---|
133 | ! Rayleigh scattering |
---|
134 | do NW=1,L_NSPECTV |
---|
135 | do K=2,L_LEVELS |
---|
136 | TRAY(K,NW) = TAURAY(NW) * DPR(K) |
---|
137 | end do |
---|
138 | end do |
---|
139 | |
---|
140 | ! we ignore K=1... hope this is ok... |
---|
141 | do K=2,L_LEVELS |
---|
142 | |
---|
143 | do NW=1,L_NSPECTV |
---|
144 | |
---|
145 | TRAYAER = TRAY(K,NW) |
---|
146 | ! TRAYAER is Tau RAYleigh scattering, plus AERosol opacity |
---|
147 | do iaer=1,naerkind |
---|
148 | TRAYAER = TRAYAER + TAEROS(K,NW,IAER) |
---|
149 | end do |
---|
150 | |
---|
151 | do NG=1,L_NGAUSS-1 |
---|
152 | |
---|
153 | ! Now compute TAUGAS |
---|
154 | |
---|
155 | ! Interpolate between water mixing ratios |
---|
156 | ! WRATIO = 0.0 if the requested water amount is equal to, or outside the |
---|
157 | ! the water data range |
---|
158 | |
---|
159 | if (L_REFVAR.eq.1)then ! added by RW for special no variable case |
---|
160 | |
---|
161 | KCOEF(1) = GASV(MT(K),MP(K),1,NW,NG) |
---|
162 | KCOEF(2) = GASV(MT(K),MP(K)+1,1,NW,NG) |
---|
163 | KCOEF(3) = GASV(MT(K)+1,MP(K)+1,1,NW,NG) |
---|
164 | KCOEF(4) = GASV(MT(K)+1,MP(K),1,NW,NG) |
---|
165 | |
---|
166 | else |
---|
167 | |
---|
168 | KCOEF(1) = GASV(MT(K),MP(K),NVAR(K),NW,NG) + WRATIO(K)* & |
---|
169 | (GASV(MT(K),MP(K),NVAR(K)+1,NW,NG) - & |
---|
170 | GASV(MT(K),MP(K),NVAR(K),NW,NG)) |
---|
171 | |
---|
172 | KCOEF(2) = GASV(MT(K),MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)* & |
---|
173 | (GASV(MT(K),MP(K)+1,NVAR(K)+1,NW,NG) - & |
---|
174 | GASV(MT(K),MP(K)+1,NVAR(K),NW,NG)) |
---|
175 | |
---|
176 | KCOEF(3) = GASV(MT(K)+1,MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)* & |
---|
177 | (GASV(MT(K)+1,MP(K)+1,NVAR(K)+1,NW,NG) - & |
---|
178 | GASV(MT(K)+1,MP(K)+1,NVAR(K),NW,NG)) |
---|
179 | |
---|
180 | KCOEF(4) = GASV(MT(K)+1,MP(K),NVAR(K),NW,NG) + WRATIO(K)* & |
---|
181 | (GASV(MT(K)+1,MP(K),NVAR(K)+1,NW,NG) - & |
---|
182 | GASV(MT(K)+1,MP(K),NVAR(K),NW,NG)) |
---|
183 | endif |
---|
184 | |
---|
185 | ! Interpolate the gaseous k-coefficients to the requested T,P values |
---|
186 | |
---|
187 | ANS = LKCOEF(K,1)*KCOEF(1) + LKCOEF(K,2)*KCOEF(2) + & |
---|
188 | LKCOEF(K,3)*KCOEF(3) + LKCOEF(K,4)*KCOEF(4) |
---|
189 | |
---|
190 | TAUGAS = U(k)*ANS |
---|
191 | |
---|
192 | TAUGSURF(NW,NG) = TAUGSURF(NW,NG) + TAUGAS |
---|
193 | DTAUKV(K,nw,ng) = TAUGAS + TRAYAER |
---|
194 | ! write(21,*) 'TB17 taugas',K,NW,ng,TAUGAS |
---|
195 | |
---|
196 | |
---|
197 | end do |
---|
198 | |
---|
199 | |
---|
200 | ! Now fill in the "clear" part of the spectrum (NG = L_NGAUSS), |
---|
201 | ! which holds continuum opacity only |
---|
202 | |
---|
203 | NG = L_NGAUSS |
---|
204 | DTAUKV(K,nw,ng) = TRAYAER ! Scattering |
---|
205 | |
---|
206 | end do |
---|
207 | end do |
---|
208 | |
---|
209 | !======================================================================= |
---|
210 | ! Now the full treatment for the layers, where besides the opacity |
---|
211 | ! we need to calculate the scattering albedo and asymmetry factors |
---|
212 | !TAUAEROLK(:,:,:) = 1.e-20 ! TB17 |
---|
213 | |
---|
214 | do iaer=1,naerkind |
---|
215 | DO NW=1,L_NSPECTV |
---|
216 | DO K=2,L_LEVELS |
---|
217 | TAUAEROLK(K,NW,IAER) = TAUAERO(K,IAER) * QSVAER(K,NW,IAER) ! effect of scattering albedo |
---|
218 | !TAUAEROLK(K,NW,IAER) = max(TAUAEROLK(K,NW,IAER),1.e-20) ! TB17 |
---|
219 | end do |
---|
220 | ENDDO |
---|
221 | ENDDO |
---|
222 | !print*, 'TBbug TAUAEROLK =', TAUAEROLK |
---|
223 | |
---|
224 | DO NW=1,L_NSPECTV |
---|
225 | DO L=1,L_NLAYRAD-1 |
---|
226 | K = 2*L+1 |
---|
227 | atemp(L,NW) = SUM(GVAER(K,NW,1:naerkind) * TAUAEROLK(K,NW,1:naerkind))+SUM(GVAER(K+1,NW,1:naerkind) * TAUAEROLK(K+1,NW,1:naerkind)) |
---|
228 | btemp(L,NW) = SUM(TAUAEROLK(K,NW,1:naerkind)) + SUM(TAUAEROLK(K+1,NW,1:naerkind)) |
---|
229 | ctemp(L,NW) = btemp(L,NW) + 0.9999*(TRAY(K,NW) + TRAY(K+1,NW)) ! JVO 2017 : does this 0.999 is really meaningful ? |
---|
230 | btemp(L,NW) = btemp(L,NW) + TRAY(K,NW) + TRAY(K+1,NW) |
---|
231 | COSBV(L,NW,1:L_NGAUSS) = atemp(L,NW)/btemp(L,NW) |
---|
232 | END DO ! L vertical loop |
---|
233 | |
---|
234 | ! Last level |
---|
235 | L = L_NLAYRAD |
---|
236 | K = 2*L+1 |
---|
237 | atemp(L,NW) = SUM(GVAER(K,NW,1:naerkind) * TAUAEROLK(K,NW,1:naerkind)) |
---|
238 | btemp(L,NW) = SUM(TAUAEROLK(K,NW,1:naerkind)) |
---|
239 | ctemp(L,NW) = btemp(L,NW) + 0.9999*TRAY(K,NW) ! JVO 2017 : does this 0.999 is really meaningful ? |
---|
240 | btemp(L,NW) = btemp(L,NW) + TRAY(K,NW) |
---|
241 | COSBV(L,NW,1:L_NGAUSS) = atemp(L,NW)/btemp(L,NW) |
---|
242 | |
---|
243 | |
---|
244 | END DO ! NW spectral loop |
---|
245 | |
---|
246 | DO NG=1,L_NGAUSS |
---|
247 | DO NW=1,L_NSPECTV |
---|
248 | DO L=1,L_NLAYRAD-1 |
---|
249 | |
---|
250 | K = 2*L+1 |
---|
251 | DTAUV(L,nw,ng) = DTAUKV(K,NW,NG) + DTAUKV(K+1,NW,NG) |
---|
252 | WBARV(L,nw,ng) = ctemp(L,NW) / DTAUV(L,nw,ng) |
---|
253 | |
---|
254 | END DO ! L vertical loop |
---|
255 | |
---|
256 | ! Last level |
---|
257 | |
---|
258 | L = L_NLAYRAD |
---|
259 | K = 2*L+1 |
---|
260 | DTAUV(L,nw,ng) = DTAUKV(K,NW,NG) |
---|
261 | |
---|
262 | WBARV(L,NW,NG) = ctemp(L,NW) / DTAUV(L,NW,NG) |
---|
263 | !print*, 'TB22 : WBARV(L)=',WBARV(L,NW,NG),NW,NG |
---|
264 | !print*, 'TB22 : ctemp(L)=',ctemp(L,NW),NW |
---|
265 | !print*, 'TB22 : dtauv(L)=',DTAUV(L,NW,NG),NW,NG |
---|
266 | END DO ! NW spectral loop |
---|
267 | END DO ! NG Gauss loop |
---|
268 | |
---|
269 | ! Total extinction optical depths |
---|
270 | |
---|
271 | DO NG=1,L_NGAUSS ! full gauss loop |
---|
272 | DO NW=1,L_NSPECTV |
---|
273 | TAUV(1,NW,NG)=0.0D0 |
---|
274 | DO L=1,L_NLAYRAD |
---|
275 | TAUV(L+1,NW,NG)=TAUV(L,NW,NG)+DTAUV(L,NW,NG) |
---|
276 | END DO |
---|
277 | |
---|
278 | TAUCUMV(1,NW,NG)=0.0D0 |
---|
279 | DO K=2,L_LEVELS |
---|
280 | TAUCUMV(K,NW,NG)=TAUCUMV(K-1,NW,NG)+DTAUKV(K,NW,NG) |
---|
281 | END DO |
---|
282 | END DO |
---|
283 | END DO ! end full gauss loop |
---|
284 | |
---|
285 | |
---|
286 | return |
---|
287 | |
---|
288 | |
---|
289 | end subroutine optcv_pluto |
---|
290 | |
---|
291 | END MODULE optcv_pluto_mod |
---|