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