SUBROUTINE OPTCV(DTAUV,TAUV,TAUCUMV,PLEV, & QXVAER,QSVAER,GVAER,WBARV,COSBV, & TAURAY,TAUAERO,TMID,PMID,TAUGSURF,QVAR) use radinc_h use radcommon_h, only: gasv, tlimit, wrefVAR, Cmk, tgasref, & pfgasref implicit none !================================================================== ! ! Purpose ! ------- ! Calculates shortwave optical constants at each level. ! ! Authors ! ------- ! Adapted from the NASA Ames code by R. Wordsworth (2009) ! !================================================================== C C THIS SUBROUTINE SETS THE OPTICAL CONSTANTS IN THE VISUAL C IT CALCUALTES FOR EACH LAYER, FOR EACH SPECRAL INTERVAL IN THE VISUAL C LAYER: WBAR, DTAU, COSBAR C LEVEL: TAU C C TAUV(L,NW,NG) is the cumulative optical depth at the top of radiation code C layer L. NW is spectral wavelength interval, ng the Gauss point index. C C TLEV(L) - Temperature at the layer boundary C PLEV(L) - Pressure at the layer boundary (i.e. level) C GASV(NT,NPS,NW,NG) - Visual CO2 k-coefficients C C----------------------------------------------------------------------C #include "callkeys.h" #include "comcstfi.h" real*8 DTAUV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) real*8 DTAUKV(L_LEVELS+1,L_NSPECTV,L_NGAUSS) real*8 TAUV(L_NLEVRAD,L_NSPECTV,L_NGAUSS) real*8 TAUCUMV(L_LEVELS,L_NSPECTV,L_NGAUSS) real*8 PLEV(L_LEVELS) real*8 TMID(L_LEVELS), PMID(L_LEVELS) real*8 COSBV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) real*8 WBARV(L_NLAYRAD,L_NSPECTV,L_NGAUSS) real*8 TAURAY(L_NSPECTV) ! For aerosols real*8 QXVAER(L_LEVELS+1,L_NSPECTV,NAERKIND) real*8 QSVAER(L_LEVELS+1,L_NSPECTV,NAERKIND) real*8 GVAER(L_LEVELS+1,L_NSPECTV,NAERKIND) real*8 TAUAERO(L_LEVELS+1,NAERKIND) real*8 TAUAEROLK(L_LEVELS+1,L_NSPECTV,NAERKIND) real*8 TAEROS(L_LEVELS,L_NSPECTV,NAERKIND) integer L, NW, NG, K, NG1(L_NSPECTV), LK, IAER integer MT(L_LEVELS), MP(L_LEVELS), NP(L_LEVELS) real*8 ANS, TAUGAS real*8 TRAY(L_LEVELS,L_NSPECTV) real*8 DPR(L_LEVELS), U(L_LEVELS) real*8 LCOEF(4), LKCOEF(L_LEVELS,4) real*8 taugsurf(L_NSPECTV,L_NGAUSS-1), TRAYAER ! mixing ratio variables real*8 QVAR(L_LEVELS), WRATIO(L_LEVELS) real*8 KCOEF(4) integer NVAR(L_LEVELS) ! temporary variables for multiple aerosol calculation real*8 atemp, btemp, ctemp ! variables for k in units m^-1 real*8 rho, dz !======================================================================= ! Determine the total gas opacity throughout the column, for each ! spectral interval, NW, and each Gauss point, NG. ! Calculate the continuum opacities, i.e., those that do not depend on ! NG, the Gauss index. do K=2,L_LEVELS DPR(K) = PLEV(K)-PLEV(K-1) ! rho = PLEV(K)/(R*TMID(K)) rho = PMID(K)/(R*TMID(K)) dz = -DPR(k)/(g*rho) U(k) = Cmk*DPR(k) call tpindex(PMID(K),TMID(K),QVAR(K),pfgasref,tgasref,WREFVAR, * LCOEF,MT(K),MP(K),NVAR(K),WRATIO(K)) do LK=1,4 LKCOEF(K,LK) = LCOEF(LK) end do DO NW=1,L_NSPECTV TRAY(K,NW) = TAURAY(NW) * DPR(K) do iaer=1,naerkind TAEROS(K,NW,IAER) = TAUAERO(K,IAER) * QXVAER(K,NW,IAER) ! write(20,*) 'TB17 taero',K,NW,IAER,TAEROS(K,NW,IAER) end do ! END DO end do ! TRAYAER is Tau RAYleigh scattering, plus AERosol opacity ! we ignore K=1... hope this is ok... do K=2,L_LEVELS do NW=1,L_NSPECTV TRAYAER = TRAY(K,NW) do iaer=1,naerkind TRAYAER = TRAYAER + TAEROS(K,NW,IAER) end do do NG=1,L_NGAUSS-1 !======================================================================= ! Now compute TAUGAS ! Interpolate between mixing ratios ! WRATIO = 0.0 if the requested amount is equal to, or outside the ! the data range if (L_REFVAR.eq.1)then ! added by RW for special no variable case KCOEF(1) = GASV(MT(K),MP(K),1,NW,NG) KCOEF(2) = GASV(MT(K),MP(K)+1,1,NW,NG) KCOEF(3) = GASV(MT(K)+1,MP(K)+1,1,NW,NG) KCOEF(4) = GASV(MT(K)+1,MP(K),1,NW,NG) else KCOEF(1) = GASV(MT(K),MP(K),NVAR(K),NW,NG) + WRATIO(K)* * (GASV(MT(K),MP(K),NVAR(K)+1,NW,NG) - * GASV(MT(K),MP(K),NVAR(K),NW,NG)) KCOEF(2) = GASV(MT(K),MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)* * (GASV(MT(K),MP(K)+1,NVAR(K)+1,NW,NG) - * GASV(MT(K),MP(K)+1,NVAR(K),NW,NG)) KCOEF(3) = GASV(MT(K)+1,MP(K)+1,NVAR(K),NW,NG) + WRATIO(K)* * (GASV(MT(K)+1,MP(K)+1,NVAR(K)+1,NW,NG) - * GASV(MT(K)+1,MP(K)+1,NVAR(K),NW,NG)) KCOEF(4) = GASV(MT(K)+1,MP(K),NVAR(K),NW,NG) + WRATIO(K)* * (GASV(MT(K)+1,MP(K),NVAR(K)+1,NW,NG) - * GASV(MT(K)+1,MP(K),NVAR(K),NW,NG)) endif ! Interpolate the gaseous k-coefficients to the requested T,P values ANS = LKCOEF(K,1)*KCOEF(1) + LKCOEF(K,2)*KCOEF(2) + * LKCOEF(K,3)*KCOEF(3) + LKCOEF(K,4)*KCOEF(4) TAUGAS = U(k)*ANS TAUGSURF(NW,NG) = TAUGSURF(NW,NG) + TAUGAS DTAUKV(K,nw,ng) = TAUGAS + TRAYAER ! write(21,*) 'TB17 taugas',K,NW,ng,TAUGAS end do ! Now fill in the "clear" part of the spectrum (NG = L_NGAUSS), ! which holds continuum opacity only NG = L_NGAUSS DTAUKV(K,nw,ng) = TRAY(K,NW) do iaer=1,naerkind DTAUKV(K,nw,ng) = DTAUKV(K,nw,ng) + TAEROS(K,NW,IAER) end do end do end do !======================================================================= ! Now the full treatment for the layers, where besides the opacity ! we need to calculate the scattering albedo and asymmetry factors TAUAEROLK(:,:,:) = 1.e-12 ! TB17 DO NW=1,L_NSPECTV DO K=2,L_LEVELS do iaer=1,naerkind TAUAEROLK(K,NW,IAER) = TAUAERO(K,IAER) * QSVAER(K,NW,IAER) TAUAEROLK(K,NW,IAER) = max(TAUAEROLK(K,NW,IAER),1.e-12) ! TB17 end do ENDDO ENDDO print*, 'TBbug TAUAEROLK =', TAUAEROLK DO NW=1,L_NSPECTV DO NG=1,L_NGAUSS DO L=1,L_NLAYRAD-1 K = 2*L+1 DTAUV(L,nw,ng) = DTAUKV(K,NW,NG)+DTAUKV(K+1,NW,NG) atemp=0. btemp=TRAY(K,NW) + TRAY(K+1,NW) ctemp=0.9999*(TRAY(K,NW) + TRAY(K+1,NW)) do iaer=1,naerkind atemp = atemp + * GVAER(K,NW,IAER) * TAUAEROLK(K,NW,IAER) + * GVAER(K+1,NW,IAER) * TAUAEROLK(K+1,NW,IAER) btemp = btemp + * TAUAEROLK(K,NW,IAER) + TAUAEROLK(K+1,NW,IAER) ctemp = ctemp + * TAUAEROLK(K,NW,IAER) + TAUAEROLK(K+1,NW,IAER) end do COSBV(L,NW,NG) = atemp/btemp WBARV(L,nw,ng) = ctemp/DTAUV(L,nw,ng) END DO ! No vertical averaging on bottom layer L = L_NLAYRAD K = 2*L+1 DTAUV(L,nw,ng) = DTAUKV(K,NW,NG) atemp=0. btemp=TRAY(K,NW) ctemp=0.9999*TRAY(K,NW) do iaer=1,naerkind atemp = atemp + GVAER(K,NW,IAER) * TAUAEROLK(K,NW,IAER) btemp = btemp + TAUAEROLK(K,NW,IAER) ctemp = ctemp + TAUAEROLK(K,NW,IAER) end do COSBV(L,NW,NG) = atemp/btemp WBARV(L,nw,ng) = ctemp/DTAUV(L,nw,ng) !WBARV(L,nw,ng) = WBARV(L-1,nw,ng) !TB17 !! bug END DO ! NG gauss point loop END DO ! NW spectral loop print*, 'TBbug WBARV =', WBARV ! Total extinction optical depths DO NW=1,L_NSPECTV DO NG=1,L_NGAUSS ! full gauss loop TAUV(1,NW,NG)=0.0D0 DO L=1,L_NLAYRAD TAUV(L+1,NW,NG)=TAUV(L,NW,NG)+DTAUV(L,NW,NG) END DO TAUCUMV(1,NW,NG)=0.0D0 DO K=2,L_LEVELS TAUCUMV(K,NW,NG)=TAUCUMV(K-1,NW,NG)+DTAUKV(K,NW,NG) END DO END DO ! end full gauss loop END DO RETURN END