1 | SUBROUTINE OPTCV(PQMO,NLAY,PLEV,TMID,PMID, & |
---|
2 | DTAUV,TAUV,TAUCUMV,WBARV,COSBV,TAURAY,TAUGSURF,SEASHAZEFACT) |
---|
3 | |
---|
4 | use radinc_h |
---|
5 | use radcommon_h, only: gasv,gasv_recomb,tlimit,Cmk,gzlat_ig, & |
---|
6 | tgasref,pfgasref,wnov,scalep,indv,gweight |
---|
7 | use gases_h |
---|
8 | use comcstfi_mod, only: r |
---|
9 | use callkeys_mod, only: continuum,graybody,callgasvis,corrk_recombin, & |
---|
10 | callclouds,callmufi,seashaze,uncoupl_optic_haze |
---|
11 | use tracer_h, only: nmicro,nice |
---|
12 | use MMP_OPTICS |
---|
13 | |
---|
14 | implicit none |
---|
15 | |
---|
16 | !================================================================== |
---|
17 | ! |
---|
18 | ! Purpose |
---|
19 | ! ------- |
---|
20 | ! Calculates shortwave optical constants at each level. |
---|
21 | ! |
---|
22 | ! Authors |
---|
23 | ! ------- |
---|
24 | ! Adapted from the NASA Ames code by R. Wordsworth (2009) |
---|
25 | ! Clean and adaptation to Titan by J. Vatant d'Ollone (2016-17) |
---|
26 | ! |
---|
27 | !================================================================== |
---|
28 | ! |
---|
29 | ! THIS SUBROUTINE SETS THE OPTICAL CONSTANTS IN THE VISUAL |
---|
30 | ! IT CALCULATES FOR EACH LAYER, FOR EACH SPECTRAL INTERVAL IN THE VISUAL |
---|
31 | ! LAYER: WBAR, DTAU, COSBAR |
---|
32 | ! LEVEL: TAU |
---|
33 | ! |
---|
34 | ! TAUV(L,NW,NG) is the cumulative optical depth at the top of radiation code |
---|
35 | ! layer L. NW is spectral wavelength interval, ng the Gauss point index. |
---|
36 | ! |
---|
37 | ! TLEV(L) - Temperature at the layer boundary |
---|
38 | ! PLEV(L) - Pressure at the layer boundary (i.e. level) |
---|
39 | ! GASV(NT,NPS,NW,NG) - Visible k-coefficients |
---|
40 | ! |
---|
41 | !------------------------------------------------------------------- |
---|
42 | |
---|
43 | |
---|
44 | !========================================================== |
---|
45 | ! Input/Output |
---|
46 | !========================================================== |
---|
47 | REAL*8, INTENT(IN) :: PQMO(nlay,nmicro) ! Tracers for microphysics optics (X/m2). |
---|
48 | INTEGER, INTENT(IN) :: NLAY ! Number of pressure layers (for pqmo) |
---|
49 | REAL*8, INTENT(IN) :: PLEV(L_LEVELS) |
---|
50 | REAL*8, INTENT(IN) :: TMID(L_LEVELS), PMID(L_LEVELS) |
---|
51 | REAL*8, INTENT(IN) :: TAURAY(L_NSPECTV) |
---|
52 | REAL*8, INTENT(IN) :: SEASHAZEFACT(L_LEVELS) |
---|
53 | |
---|
54 | REAL*8, INTENT(OUT) :: DTAUV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) |
---|
55 | REAL*8, INTENT(OUT) :: TAUV(L_NLEVRAD,L_NSPECTV,L_NGAUSS) |
---|
56 | REAL*8, INTENT(OUT) :: TAUCUMV(L_LEVELS,L_NSPECTV,L_NGAUSS) |
---|
57 | REAL*8, INTENT(OUT) :: COSBV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) |
---|
58 | REAL*8, INTENT(OUT) :: WBARV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) |
---|
59 | REAL*8, INTENT(OUT) :: TAUGSURF(L_NSPECTV,L_NGAUSS-1) |
---|
60 | ! ========================================================== |
---|
61 | |
---|
62 | real*8 DTAUKV(L_LEVELS,L_NSPECTV,L_NGAUSS) |
---|
63 | |
---|
64 | ! Titan customisation |
---|
65 | ! J. Vatant d'Ollone (2016) |
---|
66 | real*8 DHAZE_T(L_LEVELS,L_NSPECTI) |
---|
67 | real*8 DHAZES_T(L_LEVELS,L_NSPECTI) |
---|
68 | real*8 SSA_T(L_LEVELS,L_NSPECTI) |
---|
69 | real*8 ASF_T(L_LEVELS,L_NSPECTI) |
---|
70 | real*8 INT_DTAU(L_NLAYRAD,L_NSPECTI) |
---|
71 | real*8 K_HAZE(L_NLAYRAD,L_NSPECTI) |
---|
72 | |
---|
73 | CHARACTER*2 str2 |
---|
74 | ! ========================== |
---|
75 | |
---|
76 | integer L, NW, NG, K, LK, IAER |
---|
77 | integer MT(L_LEVELS), MP(L_LEVELS), NP(L_LEVELS) |
---|
78 | real*8 ANS, TAUGAS |
---|
79 | real*8 TRAY(L_LEVELS,L_NSPECTV) |
---|
80 | real*8 DPR(L_LEVELS), U(L_LEVELS) |
---|
81 | real*8 LCOEF(4), LKCOEF(L_LEVELS,4) |
---|
82 | |
---|
83 | real*8 DCONT |
---|
84 | real*8 DRAYAER |
---|
85 | double precision wn_cont, p_cont, p_air, T_cont, dtemp, dtempc |
---|
86 | double precision p_cross |
---|
87 | |
---|
88 | real*8 KCOEF(4) |
---|
89 | |
---|
90 | ! temporary variable to reduce memory access time to gasv |
---|
91 | real*8 tmpk(2,2) |
---|
92 | |
---|
93 | ! temporary variables for multiple aerosol calculation |
---|
94 | real*8 atemp(L_NLAYRAD,L_NSPECTV) |
---|
95 | real*8 btemp(L_NLAYRAD,L_NSPECTV) |
---|
96 | real*8 ctemp(L_NLAYRAD,L_NSPECTV) |
---|
97 | |
---|
98 | ! variables for k in units m^-1 |
---|
99 | real*8 dz(L_LEVELS) |
---|
100 | |
---|
101 | integer igas, jgas, ilay |
---|
102 | |
---|
103 | integer interm |
---|
104 | |
---|
105 | real*8 m0as,m3as,m0af,m3af |
---|
106 | real*8 ext_s,sca_s,ssa_s,asf_s |
---|
107 | real*8 ext_f,sca_f,ssa_f,asf_f |
---|
108 | logical,save :: firstcall=.true. |
---|
109 | !$OMP THREADPRIVATE(firstcall) |
---|
110 | |
---|
111 | |
---|
112 | !! AS: to save time in computing continuum (see bilinearbig) |
---|
113 | IF (.not.ALLOCATED(indv)) THEN |
---|
114 | ALLOCATE(indv(L_NSPECTV,ngasmx,ngasmx)) |
---|
115 | indv = -9999 ! this initial value means "to be calculated" |
---|
116 | ENDIF |
---|
117 | |
---|
118 | ! Some initialisation beacause there's a pb with disr_haze at the limits (nw=1) |
---|
119 | ! I should check this - For now we set vars to zero : better than nans - JVO 2017 |
---|
120 | |
---|
121 | dhaze_t(:,:) = 0. |
---|
122 | ssa_t(:,:) = 0. |
---|
123 | asf_t(:,:) = 0. |
---|
124 | |
---|
125 | |
---|
126 | !======================================================================= |
---|
127 | ! Determine the total gas opacity throughout the column, for each |
---|
128 | ! spectral interval, NW, and each Gauss point, NG. |
---|
129 | ! Calculate the continuum opacities, i.e., those that do not depend on |
---|
130 | ! NG, the Gauss index. |
---|
131 | |
---|
132 | taugsurf(:,:) = 0.0 |
---|
133 | dpr(:) = 0.0 |
---|
134 | lkcoef(:,:) = 0.0 |
---|
135 | |
---|
136 | do K=2,L_LEVELS |
---|
137 | |
---|
138 | ilay = k / 2 ! int. arithmetic => gives the gcm layer index |
---|
139 | |
---|
140 | DPR(k) = PLEV(K)-PLEV(K-1) |
---|
141 | |
---|
142 | ! if we have continuum opacities, we need dz |
---|
143 | |
---|
144 | dz(k) = dpr(k)*R*TMID(K)/(gzlat_ig(ilay)*PMID(K)) |
---|
145 | U(k) = Cmk(ilay)*DPR(k) ! only Cmk line in optcv.F |
---|
146 | |
---|
147 | call tpindex(PMID(K),TMID(K),pfgasref,tgasref,LCOEF,MT(K),MP(K)) |
---|
148 | |
---|
149 | do LK=1,4 |
---|
150 | LKCOEF(K,LK) = LCOEF(LK) |
---|
151 | end do |
---|
152 | end do ! levels |
---|
153 | |
---|
154 | ! Rayleigh scattering |
---|
155 | do NW=1,L_NSPECTV |
---|
156 | do K=2,L_LEVELS |
---|
157 | TRAY(K,NW) = TAURAY(NW) * DPR(K) |
---|
158 | end do ! levels |
---|
159 | end do |
---|
160 | |
---|
161 | ! we ignore K=1... |
---|
162 | do K=2,L_LEVELS |
---|
163 | |
---|
164 | ilay = k / 2 ! int. arithmetic => gives the gcm layer index |
---|
165 | |
---|
166 | do NW=1,L_NSPECTV |
---|
167 | |
---|
168 | ! Optical coupling of YAMMS is plugged but inactivated (if false) for now |
---|
169 | ! as long as the microphysics only isn't fully debugged -- JVO 01/18 |
---|
170 | IF (callmufi .AND. (.NOT. uncoupl_optic_haze)) THEN |
---|
171 | m0as = pqmo(ilay,1) |
---|
172 | m3as = pqmo(ilay,2) |
---|
173 | m0af = pqmo(ilay,3) |
---|
174 | m3af = pqmo(ilay,4) |
---|
175 | |
---|
176 | IF (.NOT.mmp_sph_optics_vis(m0as,m3as,nw,ext_s,sca_s,ssa_s,asf_s)) & |
---|
177 | CALL abort_gcm("optcv", "Fatal error in mmp_sph_optics_vis", 12) |
---|
178 | IF (.NOT.mmp_fra_optics_vis(m0af,m3af,nw,ext_f,sca_f,ssa_f,asf_f)) & |
---|
179 | CALL abort_gcm("optcv", "Fatal error in mmp_fra_optics_vis", 12) |
---|
180 | dhaze_T(k,nw) = ext_s+ext_f |
---|
181 | SSA_T(k,nw) = (sca_s+sca_f)/dhaze_T(k,nw) |
---|
182 | ASF_T(k,nw) = (asf_s*sca_s + asf_f*sca_f) /(sca_s+sca_f) |
---|
183 | IF (callclouds.and.firstcall) & |
---|
184 | WRITE(*,*) 'WARNING: In optcv, optical properties & |
---|
185 | &calculations are not implemented yet' |
---|
186 | ELSE |
---|
187 | ! Call fixed vertical haze profile of extinction - same for all columns |
---|
188 | call disr_haze(dz(k),plev(k),wnov(nw),dhaze_T(k,nw),SSA_T(k,nw),ASF_T(k,nw)) |
---|
189 | if (seashaze) dhaze_T(k,nw) = dhaze_T(k,nw)*seashazefact(k) |
---|
190 | ENDIF |
---|
191 | |
---|
192 | DRAYAER = TRAY(K,NW) |
---|
193 | ! DRAYAER is Tau RAYleigh scattering, plus AERosol opacity |
---|
194 | DRAYAER = DRAYAER + DHAZE_T(K,NW) ! Titan's aerosol |
---|
195 | |
---|
196 | DCONT = 0.0 ! continuum absorption |
---|
197 | |
---|
198 | if(continuum.and.(.not.graybody).and.callgasvis)then |
---|
199 | ! include continua if necessary |
---|
200 | wn_cont = dble(wnov(nw)) |
---|
201 | T_cont = dble(TMID(k)) |
---|
202 | do igas=1,ngasmx |
---|
203 | |
---|
204 | p_cont = dble(PMID(k)*scalep*gfrac(igas,ilay)) |
---|
205 | |
---|
206 | dtemp=0.0 |
---|
207 | if(igas.eq.igas_N2)then |
---|
208 | |
---|
209 | interm = indv(nw,igas,igas) |
---|
210 | ! call interpolateN2N2(wn_cont,T_cont,p_cont,dtemp,.false.,interm) |
---|
211 | indv(nw,igas,igas) = interm |
---|
212 | ! only goes to 500 cm^-1, so unless we're around a cold brown dwarf, this is irrelevant in the visible |
---|
213 | |
---|
214 | elseif(igas.eq.igas_H2)then |
---|
215 | |
---|
216 | ! first do self-induced absorption |
---|
217 | interm = indv(nw,igas,igas) |
---|
218 | call interpolateH2H2(wn_cont,T_cont,p_cont,dtemp,.false.,interm) |
---|
219 | indv(nw,igas,igas) = interm |
---|
220 | |
---|
221 | ! then cross-interactions with other gases |
---|
222 | do jgas=1,ngasmx |
---|
223 | p_cross = dble(PMID(k)*scalep*gfrac(jgas,ilay)) |
---|
224 | dtempc = 0.0 |
---|
225 | if(jgas.eq.igas_N2)then |
---|
226 | interm = indv(nw,igas,jgas) |
---|
227 | call interpolateN2H2(wn_cont,T_cont,p_cross,p_cont,dtempc,.false.,interm) |
---|
228 | indv(nw,igas,jgas) = interm |
---|
229 | ! should be irrelevant in the visible |
---|
230 | endif |
---|
231 | dtemp = dtemp + dtempc |
---|
232 | enddo |
---|
233 | |
---|
234 | elseif(igas.eq.igas_CH4)then |
---|
235 | |
---|
236 | ! first do self-induced absorption |
---|
237 | interm = indv(nw,igas,igas) |
---|
238 | call interpolateCH4CH4(wn_cont,T_cont,p_cont,dtemp,.false.,interm) |
---|
239 | indv(nw,igas,igas) = interm |
---|
240 | |
---|
241 | ! then cross-interactions with other gases |
---|
242 | do jgas=1,ngasmx |
---|
243 | p_cross = dble(PMID(k)*scalep*gfrac(jgas,ilay)) |
---|
244 | dtempc = 0.0 |
---|
245 | if(jgas.eq.igas_N2)then |
---|
246 | interm = indv(nw,igas,jgas) |
---|
247 | call interpolateN2CH4(wn_cont,T_cont,p_cross,p_cont,dtempc,.false.,interm) |
---|
248 | indv(nw,igas,jgas) = interm |
---|
249 | endif |
---|
250 | dtemp = dtemp + dtempc |
---|
251 | enddo |
---|
252 | |
---|
253 | endif |
---|
254 | |
---|
255 | DCONT = DCONT + dtemp |
---|
256 | |
---|
257 | enddo |
---|
258 | |
---|
259 | DCONT = DCONT*dz(k) |
---|
260 | |
---|
261 | endif |
---|
262 | |
---|
263 | do ng=1,L_NGAUSS-1 |
---|
264 | |
---|
265 | ! Now compute TAUGAS |
---|
266 | |
---|
267 | ! JVO 2017 : added tmpk because the repeated calls to gasi/v increased dramatically |
---|
268 | ! the execution time of optci/v -> ~ factor 2 on the whole radiative |
---|
269 | ! transfer on the tested simulations ! |
---|
270 | |
---|
271 | if (corrk_recombin) then |
---|
272 | tmpk = GASV_RECOMB(MT(K):MT(K)+1,MP(K):MP(K)+1,NW,NG) |
---|
273 | else |
---|
274 | tmpk = GASV(MT(K):MT(K)+1,MP(K):MP(K)+1,1,NW,NG) |
---|
275 | endif |
---|
276 | |
---|
277 | KCOEF(1) = tmpk(1,1) ! KCOEF(1) = GASV(MT(K),MP(K),1,NW,NG) |
---|
278 | KCOEF(2) = tmpk(1,2) ! KCOEF(2) = GASV(MT(K),MP(K)+1,1,NW,NG) |
---|
279 | KCOEF(3) = tmpk(2,2) ! KCOEF(3) = GASV(MT(K)+1,MP(K)+1,1,NW,NG) |
---|
280 | KCOEF(4) = tmpk(2,1) ! KCOEF(4) = GASV(MT(K)+1,MP(K),1,NW,NG) |
---|
281 | |
---|
282 | ! Interpolate the gaseous k-coefficients to the requested T,P values |
---|
283 | |
---|
284 | ANS = LKCOEF(K,1)*KCOEF(1) + LKCOEF(K,2)*KCOEF(2) + & |
---|
285 | LKCOEF(K,3)*KCOEF(3) + LKCOEF(K,4)*KCOEF(4) |
---|
286 | |
---|
287 | |
---|
288 | TAUGAS = U(k)*ANS |
---|
289 | |
---|
290 | TAUGSURF(NW,NG) = TAUGSURF(NW,NG) + TAUGAS + DCONT |
---|
291 | DTAUKV(K,nw,ng) = TAUGAS & |
---|
292 | + DRAYAER & ! DRAYAER includes all scattering contributions |
---|
293 | + DCONT ! For parameterized continuum aborption |
---|
294 | |
---|
295 | end do |
---|
296 | |
---|
297 | ! Now fill in the "clear" part of the spectrum (NG = L_NGAUSS), |
---|
298 | ! which holds continuum opacity only |
---|
299 | |
---|
300 | NG = L_NGAUSS |
---|
301 | DTAUKV(K,nw,ng) = DRAYAER + DCONT ! Scattering + parameterized continuum absorption, including Titan's haze |
---|
302 | |
---|
303 | end do |
---|
304 | end do |
---|
305 | |
---|
306 | |
---|
307 | !======================================================================= |
---|
308 | ! Now the full treatment for the layers, where besides the opacity |
---|
309 | ! we need to calculate the scattering albedo and asymmetry factors |
---|
310 | ! ====================================================================== |
---|
311 | |
---|
312 | ! Haze scattering |
---|
313 | DO NW=1,L_NSPECTV |
---|
314 | DO K=2,L_LEVELS |
---|
315 | DHAZES_T(K,NW) = DHAZE_T(K,NW) * SSA_T(K,NW) ! effect of scattering albedo on haze |
---|
316 | ENDDO |
---|
317 | ENDDO |
---|
318 | |
---|
319 | |
---|
320 | DO NW=1,L_NSPECTV |
---|
321 | DO L=1,L_NLAYRAD-1 |
---|
322 | K = 2*L+1 |
---|
323 | atemp(L,NW) = ASF_T(K,NW)*DHAZES_T(K,NW) + ASF_T(K+1,NW)*DHAZES_T(K+1,NW) |
---|
324 | btemp(L,NW) = DHAZES_T(K,NW) + DHAZES_T(K+1,NW) |
---|
325 | ctemp(L,NW) = btemp(L,NW) + 0.9999*(TRAY(K,NW) + TRAY(K+1,NW)) ! JVO 2017 : does this 0.999 is really meaningful ? |
---|
326 | btemp(L,NW) = btemp(L,NW) + TRAY(K,NW) + TRAY(K+1,NW) |
---|
327 | COSBV(L,NW,1:L_NGAUSS) = atemp(L,NW)/btemp(L,NW) |
---|
328 | END DO ! L vertical loop |
---|
329 | |
---|
330 | ! Last level |
---|
331 | L = L_NLAYRAD |
---|
332 | K = 2*L+1 |
---|
333 | atemp(L,NW) = ASF_T(K,NW)*DHAZES_T(K,NW) |
---|
334 | btemp(L,NW) = DHAZES_T(K,NW) |
---|
335 | ctemp(L,NW) = btemp(L,NW) + 0.9999*TRAY(K,NW) ! JVO 2017 : does this 0.999 is really meaningful ? |
---|
336 | btemp(L,NW) = btemp(L,NW) + TRAY(K,NW) |
---|
337 | COSBV(L,NW,1:L_NGAUSS) = atemp(L,NW)/btemp(L,NW) |
---|
338 | |
---|
339 | |
---|
340 | END DO ! NW spectral loop |
---|
341 | |
---|
342 | DO NG=1,L_NGAUSS |
---|
343 | DO NW=1,L_NSPECTV |
---|
344 | DO L=1,L_NLAYRAD-1 |
---|
345 | |
---|
346 | K = 2*L+1 |
---|
347 | DTAUV(L,nw,ng) = DTAUKV(K,NW,NG) + DTAUKV(K+1,NW,NG) |
---|
348 | WBARV(L,nw,ng) = ctemp(L,NW) / DTAUV(L,nw,ng) |
---|
349 | |
---|
350 | END DO ! L vertical loop |
---|
351 | |
---|
352 | ! Last level |
---|
353 | |
---|
354 | L = L_NLAYRAD |
---|
355 | K = 2*L+1 |
---|
356 | DTAUV(L,nw,ng) = DTAUKV(K,NW,NG) |
---|
357 | |
---|
358 | WBARV(L,NW,NG) = ctemp(L,NW) / DTAUV(L,NW,NG) |
---|
359 | |
---|
360 | END DO ! NW spectral loop |
---|
361 | END DO ! NG Gauss loop |
---|
362 | |
---|
363 | ! Total extinction optical depths |
---|
364 | |
---|
365 | DO NG=1,L_NGAUSS ! full gauss loop |
---|
366 | DO NW=1,L_NSPECTV |
---|
367 | TAUV(1,NW,NG)=0.0D0 |
---|
368 | DO L=1,L_NLAYRAD |
---|
369 | TAUV(L+1,NW,NG)=TAUV(L,NW,NG)+DTAUV(L,NW,NG) |
---|
370 | END DO |
---|
371 | |
---|
372 | TAUCUMV(1,NW,NG)=0.0D0 |
---|
373 | DO K=2,L_LEVELS |
---|
374 | TAUCUMV(K,NW,NG)=TAUCUMV(K-1,NW,NG)+DTAUKV(K,NW,NG) |
---|
375 | END DO |
---|
376 | END DO |
---|
377 | END DO ! end full gauss loop |
---|
378 | |
---|
379 | |
---|
380 | ! Titan's outputs (JVO, 2016)=============================================== |
---|
381 | ! do l=1,L_NLAYRAD |
---|
382 | ! do nw=1,L_NSPECTV |
---|
383 | ! INT_DTAU(L,NW) = 0.0d+0 |
---|
384 | ! DO NG=1,L_NGAUSS |
---|
385 | ! INT_DTAU(L,NW)= INT_DTAU(L,NW) + dtauv(L,nw,ng)*gweight(NG) |
---|
386 | ! enddo |
---|
387 | ! enddo |
---|
388 | ! enddo |
---|
389 | |
---|
390 | ! do nw=1,L_NSPECTV |
---|
391 | ! write(str2,'(i2.2)') nw |
---|
392 | ! call writediagfi(1,'kgv'//str2,'Gaz extinction coefficient VI band '//str2,'m-1',1,int_dtau(L_NLAYRAD:1:-1,nw)/dz_lay(L_NLAYRAD:1:-1)) |
---|
393 | ! call writediagfi(1,'khv'//str2,'Haze extinction coefficient VI band '//str2,'m-1',1,k_haze(L_NLAYRAD:1:-1,nw)/dz_lay(L_NLAYRAD:1:-1)) |
---|
394 | ! enddo |
---|
395 | |
---|
396 | ! ============================================================================== |
---|
397 | |
---|
398 | if(firstcall) firstcall = .false. |
---|
399 | |
---|
400 | return |
---|
401 | |
---|
402 | |
---|
403 | end subroutine optcv |
---|