source: trunk/LMDZ.GENERIC/libf/phystd/sfluxi.F @ 2987

Last change on this file since 2987 was 2899, checked in by emillour, 21 months ago

Generic PCM:
More code tidying: turn aeropacity, aeroptproperties, gfluxi, gfluxv,
sfluxi and sfluxv into modules.
EM

File size: 7.2 KB
RevLine 
[2899]1      module sfluxi_mod
2     
3      implicit none
4     
5      contains
6     
[135]7      SUBROUTINE SFLUXI(PLEV,TLEV,DTAUI,TAUCUMI,UBARI,RSFI,WNOI,DWNI,
[1781]8     *                  COSBI,WBARI,NFLUXTOPI,NFLUXTOPI_nu,
[135]9     *                  FMNETI,fluxupi,fluxdni,fluxupi_nu,
10     *                  FZEROI,TAUGSURF)
[2056]11     
[2899]12      use radinc_h, only: NTfac, NTstart, L_LEVELS, L_NSPECTI, L_NGAUSS
13      use radinc_h, only: L_NLAYRAD, L_NLEVRAD
[1781]14      use radcommon_h, only: planckir, tlimit,sigma, gweight
[1384]15      use comcstfi_mod, only: pi
[2899]16      use gfluxi_mod, only: gfluxi
[2056]17     
[135]18      implicit none
[2056]19     
[135]20      integer NLEVRAD, L, NW, NG, NTS, NTT
[2056]21     
[135]22      real*8 TLEV(L_LEVELS), PLEV(L_LEVELS)
23      real*8 TAUCUMI(L_LEVELS,L_NSPECTI,L_NGAUSS)
24      real*8 FMNETI(L_NLAYRAD)
25      real*8 WNOI(L_NSPECTI), DWNI(L_NSPECTI)
26      real*8 DTAUI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
27      real*8 FMUPI(L_NLEVRAD), FMDI(L_NLEVRAD)
28      real*8 COSBI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
29      real*8 WBARI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
[1781]30      real*8 NFLUXTOPI
[135]31      real*8 NFLUXTOPI_nu(L_NSPECTI)
32      real*8 fluxupi_nu(L_NLAYRAD,L_NSPECTI)
33      real*8 FTOPUP
[2056]34     
[135]35      real*8 UBARI, RSFI, TSURF, BSURF, TTOP, BTOP, TAUTOP
36      real*8 PLANCK, PLTOP
37      real*8 fluxupi(L_NLAYRAD), fluxdni(L_NLAYRAD)
38      real*8 FZEROI(L_NSPECTI)
39      real*8 taugsurf(L_NSPECTI,L_NGAUSS-1), fzero
[2056]40     
[135]41      real*8 fup_tmp(L_NSPECTI),fdn_tmp(L_NSPECTI)
[600]42      real*8 PLANCKSUM,PLANCKREF
[2056]43     
44! AB : variables for interpolation
45      REAL*8 C1
46      REAL*8 C2
47      REAL*8 P1
48     
49!======================================================================C
50     
[135]51      NLEVRAD = L_NLEVRAD
[2056]52     
53! ZERO THE NET FLUXES
[959]54      NFLUXTOPI = 0.0D0
[2056]55     
[135]56      DO NW=1,L_NSPECTI
[959]57        NFLUXTOPI_nu(NW) = 0.0D0
[135]58        DO L=1,L_NLAYRAD
[959]59           FLUXUPI_nu(L,NW) = 0.0D0
[2056]60           fup_tmp(nw)=0.0D0
61           fdn_tmp(nw)=0.0D0
[135]62        END DO
63      END DO
[2056]64     
[135]65      DO L=1,L_NLAYRAD
[959]66        FMNETI(L)  = 0.0D0
67        FLUXUPI(L) = 0.0D0
68        FLUXDNI(L) = 0.0D0
[135]69      END DO
[2056]70     
71! WE NOW ENTER A MAJOR LOOP OVER SPECTRAL INTERVALS IN THE INFRARED
72! TO CALCULATE THE NET FLUX IN EACH SPECTRAL INTERVAL
73     
[526]74      TTOP  = TLEV(2)  ! JL12 why not (1) ???
[135]75      TSURF = TLEV(L_LEVELS)
76
[2283]77      NTS   = int(TSURF*NTfac)-NTstart+1
78      NTT   = int(TTOP *NTfac)-NTstart+1
[135]79
[600]80!JL12 corrects the surface planck function so that its integral is equal to sigma Tsurf^4
[2056]81!JL12 this ensure that no flux is lost due to:
[600]82!JL12          -truncation of the planck function at high/low wavenumber
83!JL12          -numerical error during first spectral integration
84!JL12          -discrepancy between Tsurf and NTS/NTfac
[2056]85      PLANCKSUM = 0.d0
86      PLANCKREF = TSURF * TSURF
87      PLANCKREF = sigma * PLANCKREF * PLANCKREF
88     
[600]89      DO NW=1,L_NSPECTI
[2056]90! AB : PLANCKIR(NW,NTS) is replaced by P1, the linear interpolation result for a temperature TSURF
91         C1 = TSURF * NTfac - int(TSURF * NTfac)
92         P1 = (1.0D0 - C1) * PLANCKIR(NW,NTS) + C1 * PLANCKIR(NW,NTS+1)
93         PLANCKSUM = PLANCKSUM + P1 * DWNI(NW)
[600]94      ENDDO
[2056]95     
96      PLANCKSUM = PLANCKREF / (PLANCKSUM * Pi)
[600]97!JL12
[2056]98     
[135]99      DO 501 NW=1,L_NSPECTI
[2056]100! SURFACE EMISSIONS - INDEPENDENT OF GAUSS POINTS
101! AB : PLANCKIR(NW,NTS) is replaced by P1, the linear interpolation result for a temperature TSURF
102! AB : idem for PLANCKIR(NW,NTT) and PLTOP
103         C1 = TSURF * NTfac - int(TSURF * NTfac)
104         C2 = TTOP  * NTfac - int(TTOP  * NTfac)
105         P1 = (1.0D0 - C1) * PLANCKIR(NW,NTS) + C1 * PLANCKIR(NW,NTS+1)
106         BSURF = (1. - RSFI) * P1 * PLANCKSUM
107         PLTOP = (1.0D0 - C2) * PLANCKIR(NW,NTT) + C2*PLANCKIR(NW,NTT+1)
[135]108         
[2056]109! If FZEROI(NW) = 1, then the k-coefficients are zero - skip to the
110! special Gauss point at the end.
111         FZERO = FZEROI(NW)
112         
113         IF(FZERO.ge.0.99) goto 40
114         
115         DO NG=1,L_NGAUSS-1
116           
117            if(TAUGSURF(NW,NG).lt. TLIMIT) then
118               fzero = fzero + (1.0D0-FZEROI(NW))*GWEIGHT(NG)
119               goto 30
120            end if
121           
122! SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE IR
123! CALCULATE THE DOWNWELLING RADIATION AT THE TOP OF THE MODEL
124! OR THE TOP LAYER WILL COOL TO SPACE UNPHYSICALLY
125           
126!            TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
127            TAUTOP = TAUCUMI(2,NW,NG)
128            BTOP   = (1.0D0-EXP(-TAUTOP/UBARI))*PLTOP
129           
130! WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
131! CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
132! WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
133           
134            CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
[135]135     *                TAUCUMI(1,NW,NG),
136     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
137     *                BSURF,FTOPUP,FMUPI,FMDI)
[2056]138         
139! NOW CALCULATE THE CUMULATIVE IR NET FLUX
140            NFLUXTOPI = NFLUXTOPI+FTOPUP*DWNI(NW)*GWEIGHT(NG)
141     *                * (1.0D0-FZEROI(NW))
142           
143! and same thing by spectral band... (RDW)
144            NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW) + FTOPUP * DWNI(NW)
145     *                       * GWEIGHT(NG) * (1.0D0-FZEROI(NW))
146           
147            DO L=1,L_NLEVRAD-1
148!           CORRECT FOR THE WAVENUMBER INTERVALS
149               FMNETI(L)  = FMNETI(L) + (FMUPI(L)-FMDI(L)) * DWNI(NW)
150     *                    * GWEIGHT(NG)*(1.0D0-FZEROI(NW))
151               FLUXUPI(L) = FLUXUPI(L) + FMUPI(L)*DWNI(NW)*GWEIGHT(NG)
152     *                    * (1.0D0-FZEROI(NW))
153               FLUXDNI(L) = FLUXDNI(L) + FMDI(L)*DWNI(NW)*GWEIGHT(NG)
154     *                    * (1.0D0-FZEROI(NW))
155!         and same thing by spectral band... (RW)
156               FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW) + FMUPI(L)*DWNI(NW)
157     *                          * GWEIGHT(NG) * (1.0D0 - FZEROI(NW))
158            END DO
159           
160   30       CONTINUE
161         
162         END DO       !End NGAUSS LOOP
163         
164   40    CONTINUE
165         
166! SPECIAL 17th Gauss point
167         NG     = L_NGAUSS
168         
169!         TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
170         TAUTOP = TAUCUMI(2,NW,NG)
171         BTOP   = (1.0D0-EXP(-TAUTOP/UBARI))*PLTOP
172         
173! WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
174! CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
175! WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
176         
177         CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
[135]178     *                TAUCUMI(1,NW,NG),
179     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
180     *                BSURF,FTOPUP,FMUPI,FMDI)
[2056]181         
182! NOW CALCULATE THE CUMULATIVE IR NET FLUX
183         NFLUXTOPI = NFLUXTOPI+FTOPUP*DWNI(NW)*FZERO
184         
185!         and same thing by spectral band... (RW)
186         NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW)
[135]187     *      +FTOPUP*DWNI(NW)*FZERO
[2056]188         
189         DO L=1,L_NLEVRAD-1
190! CORRECT FOR THE WAVENUMBER INTERVALS
191            FMNETI(L)  = FMNETI(L)+(FMUPI(L)-FMDI(L))*DWNI(NW)*FZERO
192            FLUXUPI(L) = FLUXUPI(L) + FMUPI(L)*DWNI(NW)*FZERO
193            FLUXDNI(L) = FLUXDNI(L) + FMDI(L)*DWNI(NW)*FZERO
194! and same thing by spectral band... (RW)
195            FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW)
196     *                       + FMUPI(L) * DWNI(NW) * FZERO
197         END DO
198         
[135]199  501 CONTINUE      !End Spectral Interval LOOP
[2056]200! *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE INFRARED****
201     
[2899]202      END SUBROUTINE SFLUXI
203
204      end module sfluxi_mod
Note: See TracBrowser for help on using the repository browser.