source: trunk/LMDZ.PLUTO/libf/phypluto/optci.F90 @ 3959

Last change on this file since 3959 was 3959, checked in by debatzbr, 6 weeks ago

Pluto PCM: Take clouds into account in radiative transfer.
BBT

File size: 18.9 KB
Line 
1MODULE optci_mod
2
3IMPLICIT NONE
4
5CONTAINS
6
7subroutine optci(PLEV,TLEV,DTAUI,TAUCUMI,      &
8     QXIAER,QSIAER,GIAER,COSBI,WBARI,TAUAERO,  &
9     TMID,PMID,TAUGSURF,QVAR,MUVAR)
10
11  use radinc_h, only: L_LEVELS, L_NLAYRAD, L_NSPECTI, L_NGAUSS, &
12                      L_NLEVRAD, L_REFVAR, naerkind
13  use radcommon_h, only: gasi,tlimit,wrefVAR,Cmk,tgasref,pfgasref,wnoi,scalep,indi,glat_ig
14  use gases_h, only: gfrac, ngasmx, igas_N2, igas_He, igas_H2O, igas_H2, &
15                     igas_CH4, igas_N2
16  use comcstfi_mod, only: g, r, mugaz
17  use callkeys_mod, only: kastprof,continuum,graybody,callmufi,callmuclouds, &
18                          Fabs_aers_IR,Fabs_aerf_IR,Fabs_cldd_IR
19  use recombin_corrk_mod, only: corrk_recombin, gasi_recomb
20  use tpindex_mod, only: tpindex
21
22  implicit none
23
24  !==================================================================
25  !     
26  !     Purpose
27  !     -------
28  !     Calculates longwave optical constants at each level. For each
29  !     layer and spectral interval in the IR it calculates WBAR, DTAU
30  !     and COSBAR. For each level it calculates TAU.
31  !     
32  !     TAUCUMI(L,LW) is the cumulative optical depth at level L (or alternatively
33  !     at the *bottom* of layer L), LW is the spectral wavelength interval.
34  !     
35  !     TLEV(L) - Temperature at the layer boundary (i.e., level)
36  !     PLEV(L) - Pressure at the layer boundary (i.e., level)
37  !
38  !     Authors
39  !     -------
40  !     Adapted from the NASA Ames code by R. Wordsworth (2009)
41  !     
42  !==================================================================
43
44
45  real*8,intent(out) :: DTAUI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
46  real*8 DTAUKI(L_LEVELS,L_NSPECTI,L_NGAUSS)
47  real*8 TAUI(L_NLEVRAD,L_NSPECTI,L_NGAUSS)
48  real*8,intent(out) :: TAUCUMI(L_LEVELS,L_NSPECTI,L_NGAUSS)
49  real*8,intent(in) :: PLEV(L_LEVELS)
50  real*8,intent(in) :: TLEV(L_LEVELS) ! not used
51  real*8,intent(in) :: TMID(L_LEVELS)
52  real*8,intent(in) :: PMID(L_LEVELS)
53  real*8,intent(out) :: COSBI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
54  real*8,intent(out) :: WBARI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
55
56  ! for aerosols
57  real*8,intent(in) ::  QXIAER(L_LEVELS,L_NSPECTI,NAERKIND)
58  real*8,intent(in) ::  QSIAER(L_LEVELS,L_NSPECTI,NAERKIND)
59  real*8,intent(in) ::  GIAER(L_LEVELS,L_NSPECTI,NAERKIND)
60  real*8,intent(in) ::  TAUAERO(L_LEVELS,NAERKIND)
61
62  ! local variables (saved for convenience as need be allocated)
63  real*8,save,allocatable :: TAUAEROLK(:,:,:)
64  real*8,save,allocatable :: TAEROS(:,:,:)
65!$OMP THREADPRIVATE(TAUAEROLK,TAEROS)
66
67  integer L, NW, NG, K, LK, IAER
68  integer MT(L_LEVELS), MP(L_LEVELS), NP(L_LEVELS)
69  real*8  ANS, TAUGAS
70  real*8  DPR(L_LEVELS), U(L_LEVELS)
71  real*8  LCOEF(4), LKCOEF(L_LEVELS,4)
72
73  real*8,intent(out) :: taugsurf(L_NSPECTI,L_NGAUSS-1)
74  real*8 DCONT,DAERO
75  double precision wn_cont, p_cont, p_air, T_cont, dtemp, dtempc
76  double precision p_cross
77
78  ! variable species mixing ratio variables
79  real*8,intent(in) :: QVAR(L_LEVELS)
80  real*8,intent(in) :: MUVAR(L_LEVELS)
81  real*8  WRATIO(L_LEVELS)
82  real*8  KCOEF(4)
83  integer NVAR(L_LEVELS)
84 
85  ! temporary variables to reduce memory access time to gasi
86  real*8 tmpk(2,2)
87  real*8 tmpkvar(2,2,2)
88
89  ! temporary variables for multiple aerosol calculation
90  real*8 atemp
91  real*8 btemp(L_NLAYRAD,L_NSPECTI)
92
93  ! variables for k in units m^-1
94  real*8 dz(L_LEVELS)
95  !real*8 rho !! see test below
96
97  ! Variables for aerosol absorption
98  real*8 Fabs_aer(NAERKIND)
99
100  integer igas, jgas
101
102  integer interm
103 
104  logical :: firstcall=.true.
105!$OMP THREADPRIVATE(firstcall)
106
107  !--- Kasting's CIA ----------------------------------------
108  !real*8, parameter :: Ci(L_NSPECTI)=[                         &
109  !     3.8E-5, 1.2E-5, 2.8E-6, 7.6E-7, 4.5E-7, 2.3E-7,    &
110  !     5.4E-7, 1.6E-6, 0.0,                               &
111  !     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,            &
112  !     0.0, 4.0E-7, 4.0E-6, 1.4E-5,    &
113  !     1.0E-5, 1.2E-6, 2.0E-7, 5.0E-8, 3.0E-8, 0.0 ]
114  !real*8, parameter :: Ti(L_NSPECTI)=[ -2.2, -1.9,             &
115  !     -1.7, -1.7, -1.7, -1.7, -1.7, -1.7,                &
116  !     0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, &
117  !     -1.7,-1.7,-1.7,-1.7,-1.7,-1.7,-1.7, -1.7,0.0 ]
118  !----------------------------------------------------------
119
120  if (firstcall) then
121    ! allocate local arrays of size "naerkind" (which are also
122    ! "saved" so that this is done only once in for all even if
123    ! we don't need to store the value from a time step to the next)
124    allocate(TAUAEROLK(L_LEVELS,L_NSPECTI,NAERKIND))
125    allocate(TAEROS(L_LEVELS,L_NSPECTI,NAERKIND))
126    firstcall=.false.
127  endif ! of if (firstcall)
128
129  !! AS: to save time in computing continuum (see bilinearbig)
130  IF (.not.ALLOCATED(indi)) THEN
131      ALLOCATE(indi(L_NSPECTI,ngasmx,ngasmx))
132      indi = -9999  ! this initial value means "to be calculated"
133  ENDIF
134
135  !=======================================================================
136  !     Determine the total gas opacity throughout the column, for each
137  !     spectral interval, NW, and each Gauss point, NG.
138
139  dtaui(:,:,:) = 0.0
140  taucumi(:,:,:) = 0.0
141
142  taugsurf(:,:) = 0.0
143  dpr(:)        = 0.0
144  lkcoef(:,:)   = 0.0
145
146  if (callmufi) then
147   Fabs_aer(1) = Fabs_aers_IR
148   Fabs_aer(2) = Fabs_aerf_IR
149   if (callmuclouds) then
150      Fabs_aer(3) = Fabs_cldd_IR
151   endif
152  else
153   Fabs_aer(:) = 1.0
154  endif ! end callmufi
155
156  do K=2,L_LEVELS
157     DPR(k) = PLEV(K)-PLEV(K-1)
158
159     !--- Kasting's CIA ----------------------------------------
160     !dz(k)=dpr(k)*189.02*TMID(K)/(0.03720*PMID(K))
161     ! this is N2 path length (in cm) as written by Francois
162     ! delta_z = delta_p * R_specific * T / (g * P)
163     ! But Kasting states that W is in units of _atmosphere_ cm
164     ! So we do
165     !dz(k)=dz(k)*(PMID(K)/1013.25)
166     !dz(k)=dz(k)/100.0 ! in m for SI calc
167     !----------------------------------------------------------
168
169     ! if we have continuum opacities, we need dz
170     if(kastprof)then
171        dz(k) = dpr(k)*(1000.0d0*8.3145d0/muvar(k))*TMID(K)/(g*PMID(K))
172        U(k)  = Cmk*DPR(k)*mugaz/muvar(k)
173     else
174        dz(k) = dpr(k)*R*TMID(K)/(glat_ig*PMID(K))*mugaz/muvar(k)
175        U(k)  = Cmk*DPR(k)*mugaz/muvar(k)     ! only Cmk line in optci.F 
176            !JL13 the mugaz/muvar factor takes into account water meanmolecular weight if water is present
177     endif
178
179     call tpindex(PMID(K),TMID(K),QVAR(K),pfgasref,tgasref,WREFVAR, &
180          LCOEF,MT(K),MP(K),NVAR(K),WRATIO(K))
181
182     do LK=1,4
183        LKCOEF(K,LK) = LCOEF(LK)
184     end do
185  end do                    ! levels
186
187  ! Spectral dependance of aerosol absorption
188  do iaer=1,naerkind
189     DO NW=1,L_NSPECTI
190        do K=2,L_LEVELS
191           TAEROS(K,NW,IAER) = TAUAERO(K,IAER) * QXIAER(K,NW,IAER)
192           ! Aerosol/Cloud absorption correction --> impact on opacity.
193           if (callmufi .and. (TAEROS(K,NW,IAER).gt.0.d0)) then
194            TAEROS(K,NW,IAER) = TAEROS(K,NW,IAER) * &
195                                ((QSIAER(K,NW,IAER)/QXIAER(K,NW,IAER)) + Fabs_aer(IAER)*(1.-(QSIAER(K,NW,IAER)/QXIAER(K,NW,IAER))))
196           endif
197        end do ! L_LEVELS
198     END DO ! L_NSPECTI
199  end do ! naerkind
200
201  do NW=1,L_NSPECTI
202
203     do K=2,L_LEVELS
204     
205        DAERO=SUM(TAEROS(K,NW,1:naerkind)) ! aerosol absorption
206
207        DCONT = 0.0d0 ! continuum absorption
208
209        if(continuum.and.(.not.graybody))then
210           ! include continua if necessary
211           wn_cont = dble(wnoi(nw))
212           T_cont  = dble(TMID(k))
213           do igas=1,ngasmx
214
215              if(gfrac(igas).eq.-1)then ! variable
216                 p_cont  = dble(PMID(k)*scalep*QVAR(k)) ! qvar = mol/mol
217              else
218                 p_cont  = dble(PMID(k)*scalep*gfrac(igas)*(1.-QVAR(k)))
219              endif
220
221              dtemp=0.0d0
222              if(igas.eq.igas_N2)then
223
224                 interm = indi(nw,igas,igas)
225                 call interpolateN2N2(wn_cont,T_cont,p_cont,dtemp,.false.,interm)
226                 indi(nw,igas,igas) = interm
227
228            !   elseif(igas.eq.igas_H2)then !AF24: removed
229
230              elseif(igas.eq.igas_CH4)then
231
232                 ! first do self-induced absorption
233                 interm = indi(nw,igas,igas)
234                 call interpolateCH4CH4(wn_cont,T_cont,p_cont,dtemp,.false.,interm)
235                 indi(nw,igas,igas) = interm
236
237                 ! then cross-interactions with other gases !AF24: removed
238
239            !   elseif(igas.eq.igas_H2O.and.T_cont.gt.100.0)then !AF24: removed
240
241              endif
242              DCONT = DCONT + dtemp
243           enddo
244
245           ! Oobleck test
246           !rho = PMID(k)*scalep / (TMID(k)*286.99)
247           !if(WNOI(nw).gt.300.0 .and. WNOI(nw).lt.500.0)then
248           !   DCONT = rho * 0.125 * 4.6e-4
249           !elseif(WNOI(nw).gt.500.0 .and. WNOI(nw).lt.700.0)then
250           !   DCONT = 1000*dpr(k) * 1.0 * 4.6e-4 / g
251           !   DCONT = rho * 1.0 * 4.6e-4
252           !elseif(WNOI(nw).gt.700.0 .and. WNOI(nw).lt.900.0)then
253           !   DCONT = rho * 0.125 * 4.6e-4
254           !endif
255
256           DCONT = DCONT*dz(k)
257
258        endif
259
260        do ng=1,L_NGAUSS-1
261
262           ! Now compute TAUGAS
263
264           ! Interpolate between water mixing ratios
265           ! WRATIO = 0.0 if the requested water amount is equal to, or outside the
266           ! the water data range
267
268           if(L_REFVAR.eq.1)then ! added by RW for special no variable case
269           
270              ! JVO 2017 : added tmpk because the repeated calls to gasi/v increased dramatically
271              ! the execution time of optci/v -> ~ factor 2 on the whole radiative
272              ! transfer on the tested simulations !
273
274              IF (corrk_recombin) THEN ! added by JVO
275                tmpk = GASI_RECOMB(MT(K):MT(K)+1,MP(K):MP(K)+1,1,NW,NG) ! contains the mix of recombined species
276              ELSE
277                tmpk = GASI(MT(K):MT(K)+1,MP(K):MP(K)+1,1,NW,NG)
278              ENDIF
279
280              KCOEF(1) = tmpk(1,1) ! KCOEF(1) = GASI(MT(K),MP(K),1,NW,NG)
281              KCOEF(2) = tmpk(1,2) ! KCOEF(2) = GASI(MT(K),MP(K)+1,1,NW,NG)
282              KCOEF(3) = tmpk(2,2) ! KCOEF(3) = GASI(MT(K)+1,MP(K)+1,1,NW,NG)
283              KCOEF(4) = tmpk(2,1) ! KCOEF(4) = GASI(MT(K)+1,MP(K),1,NW,NG)
284
285           else
286
287              IF (corrk_recombin) THEN ! added by JVO
288                tmpkvar = GASI_RECOMB(MT(K):MT(K)+1,MP(K):MP(K)+1,NVAR(K):NVAR(K)+1,NW,NG)
289              ELSE
290                tmpkvar = GASI(MT(K):MT(K)+1,MP(K):MP(K)+1,NVAR(K):NVAR(K)+1,NW,NG)
291              ENDIF
292
293              KCOEF(1) = tmpkvar(1,1,1) + WRATIO(K) *  &
294                        ( tmpkvar(1,1,2)-tmpkvar(1,1,1) )
295
296              KCOEF(2) = tmpkvar(1,2,1) + WRATIO(K) *  &
297                        ( tmpkvar(1,2,2)-tmpkvar(1,2,1) )
298
299              KCOEF(3) = tmpkvar(2,2,1) + WRATIO(K) *  &
300                        ( tmpkvar(2,2,2)-tmpkvar(2,2,1) )
301             
302              KCOEF(4) = tmpkvar(2,1,1) + WRATIO(K) *  &
303                        ( tmpkvar(2,1,2)-tmpkvar(2,1,1) )
304
305           endif
306
307           ! Interpolate the gaseous k-coefficients to the requested T,P values
308
309           ANS = LKCOEF(K,1)*KCOEF(1) + LKCOEF(K,2)*KCOEF(2) +            &
310                LKCOEF(K,3)*KCOEF(3) + LKCOEF(K,4)*KCOEF(4)
311
312           TAUGAS  = U(k)*ANS
313
314           TAUGSURF(NW,NG) = TAUGSURF(NW,NG) + TAUGAS + DCONT
315           DTAUKI(K,nw,ng) = TAUGAS    &
316                             + DCONT   & ! For parameterized continuum absorption
317                             + DAERO     ! For aerosol absorption
318
319        end do
320
321        ! Now fill in the "clear" part of the spectrum (NG = L_NGAUSS),
322        ! which holds continuum opacity only
323
324        NG              = L_NGAUSS
325        DTAUKI(K,nw,ng) = 0.d0      &
326                          + DCONT   & ! For parameterized continuum absorption
327                          + DAERO     ! For aerosol absorption
328
329     end do
330  end do
331
332  !=======================================================================
333  !     Now the full treatment for the layers, where besides the opacity
334  !     we need to calculate the scattering albedo and asymmetry factors
335
336  do iaer=1,naerkind
337    DO NW=1,L_NSPECTI
338     DO K=2,L_LEVELS
339           TAUAEROLK(K,NW,IAER) = TAUAERO(K,IAER)*QSIAER(K,NW,IAER) ! effect of scattering albedo
340     ENDDO
341    ENDDO
342  end do
343
344  DO NW = 1, L_NSPECTI
345     DO L = 1, L_NLAYRAD-1
346        K = 2*L + 1
347        ! Aerosol absorption correction --> impact on single scattering albedo.
348        if (callmufi) then
349           ! Spherical aerosols
350           if ((TAEROS(K,NW,1).gt.0.d0) .and. TAEROS(K+1,NW,1).gt.0.d0) then
351              btemp(L,NW) = TAUAEROLK(K,NW,1) / &
352                          (QSIAER(K,NW,1)/QXIAER(K,NW,1) + &
353                             Fabs_aer(1)*(1.-QSIAER(K,NW,1)/QXIAER(K,NW,1))) + &
354                          TAUAEROLK(K+1,NW,1) / &
355                          (QSIAER(K+1,NW,1)/QXIAER(K+1,NW,1) + &
356                             Fabs_aer(1)*(1.-QSIAER(K+1,NW,1)/QXIAER(K+1,NW,1)))
357           else
358              btemp(L,NW) = TAUAEROLK(K,NW,1) + TAUAEROLK(K+1,NW,1)
359           endif
360           ! Fractal aerosols
361           if ((TAEROS(K,NW,2).gt.0.d0) .and. TAEROS(K+1,NW,2).gt.0.d0) then
362              btemp(L,NW) = btemp(L,NW) + &
363                          (TAUAEROLK(K,NW,2) / &
364                          (QSIAER(K,NW,2)/QXIAER(K,NW,2) + &
365                             Fabs_aer(2)*(1.-QSIAER(K,NW,2)/QXIAER(K,NW,2)))) + &
366                          (TAUAEROLK(K+1,NW,2) / &
367                          (QSIAER(K+1,NW,2)/QXIAER(K+1,NW,2) + &
368                             Fabs_aer(2)*(1.-QSIAER(K+1,NW,2)/QXIAER(K+1,NW,2))))
369           else
370              btemp(L,NW) = btemp(L,NW) + TAUAEROLK(K,NW,2) + TAUAEROLK(K+1,NW,2)
371           endif
372           ! Cloud absorption correction --> impact on single scattering albedo.
373           if (callmuclouds) then
374              if ((TAEROS(K,NW,3).gt.0.d0) .and. TAEROS(K+1,NW,3).gt.0.d0) then
375               btemp(L,NW) = btemp(L,NW) + &
376                           (TAUAEROLK(K,NW,3) / &
377                           (QSIAER(K,NW,3)/QXIAER(K,NW,3) + &
378                              Fabs_aer(3)*(1.-QSIAER(K,NW,3)/QXIAER(K,NW,3)))) + &
379                           (TAUAEROLK(K+1,NW,3) / &
380                           (QSIAER(K+1,NW,3)/QXIAER(K+1,NW,3) + &
381                              Fabs_aer(3)*(1.-QSIAER(K+1,NW,3)/QXIAER(K+1,NW,3))))
382              else
383               btemp(L,NW) = btemp(L,NW) + TAUAEROLK(K,NW,3) + TAUAEROLK(K+1,NW,3)
384              endif
385           endif ! end callmuclouds
386        else
387           btemp(L,NW) = SUM(TAUAEROLK(K,NW,1:naerkind)) + SUM(TAUAEROLK(K+1,NW,1:naerkind))
388        endif ! callmufi
389     END DO ! L vertical loop
390     
391     ! Last level
392     !-----------
393     L = L_NLAYRAD
394     K = 2*L+1
395     ! Aerosol absorption correction --> impact on single scattering albedo.
396     if (callmufi) then
397      ! Spherical aerosols
398      if (TAEROS(K,NW,1).gt.0.d0) then
399         btemp(L,NW) = TAUAEROLK(K,NW,1) / &
400                       (QSIAER(K,NW,1)/QXIAER(K,NW,1) + &
401                        Fabs_aer(1)*(1.-QSIAER(K,NW,1)/QXIAER(K,NW,1)))
402      else
403         btemp(L,NW) = TAUAEROLK(K,NW,1)
404      endif
405      ! Fractal aerosols
406      if (TAEROS(K,NW,2).gt.0.d0) then
407         btemp(L,NW) = btemp(L,NW) + &
408                       (TAUAEROLK(K,NW,2) / &
409                       (QSIAER(K,NW,2)/QXIAER(K,NW,2) + &
410                        Fabs_aer(2)*(1.-QSIAER(K,NW,2)/QXIAER(K,NW,2))))
411      else
412         btemp(L,NW) = btemp(L,NW) + TAUAEROLK(K,NW,2)
413      endif
414      ! Cloud absorption correction --> impact on single scattering albedo.
415      if (callmuclouds) then
416         if (TAEROS(K,NW,3).gt.0.d0) then
417            btemp(L,NW) = btemp(L,NW) + &
418                          (TAUAEROLK(K,NW,3) / &
419                          (QSIAER(K,NW,3)/QXIAER(K,NW,3) + &
420                           Fabs_aer(3)*(1.-QSIAER(K,NW,3)/QXIAER(K,NW,3))))
421         else
422            btemp(L,NW) = btemp(L,NW) + TAUAEROLK(K,NW,3)
423         endif
424      endif ! end callmuclouds
425     else
426      btemp(L,NW) = SUM(TAUAEROLK(K,NW,1:naerkind))
427     endif ! callmufi
428  END DO ! NW spectral loop
429 
430
431  DO NW=1,L_NSPECTI
432     NG = L_NGAUSS
433     DO L=1,L_NLAYRAD-1
434
435        K              = 2*L+1
436        DTAUI(L,nw,ng) = DTAUKI(K,NW,NG) + DTAUKI(K+1,NW,NG)! + 1.e-50
437
438        atemp = 0.
439        if(DTAUI(L,NW,NG) .GT. 1.0D-9) then
440           do iaer=1,naerkind
441              atemp = atemp +                                     &
442                   GIAER(K,NW,IAER)   * TAUAEROLK(K,NW,IAER) +    &
443                   GIAER(K+1,NW,IAER) * TAUAEROLK(K+1,NW,IAER)
444           end do
445           WBARI(L,nw,ng) = btemp(L,nw)  / DTAUI(L,NW,NG)
446        else
447           WBARI(L,nw,ng) = 0.0D0
448           DTAUI(L,NW,NG) = 1.0D-9
449        endif
450
451        if(btemp(L,nw) .GT. 0.0d0) then
452           cosbi(L,NW,NG) = atemp/btemp(L,nw)
453        else
454           cosbi(L,NW,NG) = 0.0D0
455        end if
456
457     END DO ! L vertical loop
458     
459     ! Last level
460     !-----------
461     L              = L_NLAYRAD
462     K              = 2*L+1
463     DTAUI(L,nw,ng) = DTAUKI(K,NW,NG) ! + 1.e-50
464
465     atemp = 0.
466     if(DTAUI(L,NW,NG) .GT. 1.0D-9) then
467        do iaer=1,naerkind
468           atemp = atemp + GIAER(K,NW,IAER)   * TAUAEROLK(K,NW,IAER)
469        end do
470        WBARI(L,nw,ng) = btemp(L,nw)  / DTAUI(L,NW,NG)
471     else
472        WBARI(L,nw,ng) = 0.0D0
473        DTAUI(L,NW,NG) = 1.0D-9
474     endif
475
476     if(btemp(L,nw) .GT. 0.0d0) then
477        cosbi(L,NW,NG) = atemp/btemp(L,nw)
478     else
479        cosbi(L,NW,NG) = 0.0D0
480     end if
481     
482
483     ! Now the other Gauss points, if needed.
484
485     DO NG=1,L_NGAUSS-1
486        IF(TAUGSURF(NW,NG) .gt. TLIMIT) THEN
487
488           DO L=1,L_NLAYRAD-1
489              K              = 2*L+1
490              DTAUI(L,nw,ng) = DTAUKI(K,NW,NG)+DTAUKI(K+1,NW,NG)! + 1.e-50
491
492              if(DTAUI(L,NW,NG) .GT. 1.0D-9) then
493
494                 WBARI(L,nw,ng) = btemp(L,nw)  / DTAUI(L,NW,NG)
495
496              else
497                 WBARI(L,nw,ng) = 0.0D0
498                 DTAUI(L,NW,NG) = 1.0D-9
499              endif
500
501              cosbi(L,NW,NG) = cosbi(L,NW,L_NGAUSS)
502           END DO ! L vertical loop
503           
504           ! Last level
505           L              = L_NLAYRAD
506           K              = 2*L+1
507           DTAUI(L,nw,ng) = DTAUKI(K,NW,NG)! + 1.e-50
508
509           if(DTAUI(L,NW,NG) .GT. 1.0D-9) then
510
511              WBARI(L,nw,ng) = btemp(L,nw)  / DTAUI(L,NW,NG)
512
513           else
514              WBARI(L,nw,ng) = 0.0D0
515              DTAUI(L,NW,NG) = 1.0D-9
516           endif
517
518           cosbi(L,NW,NG) = cosbi(L,NW,L_NGAUSS)
519           
520        END IF
521
522     END DO                 ! NG Gauss loop
523  END DO                    ! NW spectral loop
524
525  ! Total extinction optical depths
526
527  DO NG=1,L_NGAUSS       ! full gauss loop
528     DO NW=1,L_NSPECTI       
529        TAUCUMI(1,NW,NG)=0.0D0
530        DO K=2,L_LEVELS
531           TAUCUMI(K,NW,NG)=TAUCUMI(K-1,NW,NG)+DTAUKI(K,NW,NG)
532        END DO
533     END DO                 ! end full gauss loop
534  END DO
535
536  ! be aware when comparing with textbook results
537  ! (e.g. Pierrehumbert p. 218) that
538  ! taucumi does not take the <cos theta>=0.5 factor into
539  ! account. It is the optical depth for a vertically
540  ! ascending ray with angle theta = 0.
541
542  !open(127,file='taucum.out')
543  !do nw=1,L_NSPECTI
544  !   write(127,*) taucumi(L_LEVELS,nw,L_NGAUSS)
545  !enddo
546  !close(127)
547 
548!  print*,'WBARI'
549!  print*,WBARI
550!  print*,'DTAUI'
551!  print*,DTAUI
552!  call abort
553
554end subroutine optci
555
556END MODULE optci_mod
557
Note: See TracBrowser for help on using the repository browser.