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