source: trunk/LMDZ.TITAN/libf/phytitan/optcv.F90 @ 1788

Last change on this file since 1788 was 1788, checked in by jvatant, 7 years ago

Get rid of all the old-generic dummy aerosol scheme ( just left scatterers_h for compilation )
as the new microphysics for Titan will be plugged in
-> even removed sedimentation ( will be done in the microphysical model )
--JVO

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