source: trunk/LMDZ.PLUTO/libf/phypluto/sfluxi.F @ 3193

Last change on this file since 3193 was 3184, checked in by afalco, 10 months ago

Pluto PCM:
Added LMDZ.PLUTO, a copy of the generic model,
cleaned from some unnecessary modules (water, ...)
AF

File size: 7.2 KB
Line 
1      module sfluxi_mod
2     
3      implicit none
4     
5      contains
6     
7      SUBROUTINE SFLUXI(PLEV,TLEV,DTAUI,TAUCUMI,UBARI,RSFI,WNOI,DWNI,
8     *                  COSBI,WBARI,NFLUXTOPI,NFLUXTOPI_nu,
9     *                  FMNETI,fluxupi,fluxdni,fluxupi_nu,
10     *                  FZEROI,TAUGSURF)
11     
12      use radinc_h, only: NTfac, NTstart, L_LEVELS, L_NSPECTI, L_NGAUSS
13      use radinc_h, only: L_NLAYRAD, L_NLEVRAD
14      use radcommon_h, only: planckir, tlimit,sigma, gweight
15      use comcstfi_mod, only: pi
16      use gfluxi_mod, only: gfluxi
17     
18      implicit none
19     
20      integer NLEVRAD, L, NW, NG, NTS, NTT
21     
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)
30      real*8 NFLUXTOPI
31      real*8 NFLUXTOPI_nu(L_NSPECTI)
32      real*8 fluxupi_nu(L_NLAYRAD,L_NSPECTI)
33      real*8 FTOPUP
34     
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
40     
41      real*8 fup_tmp(L_NSPECTI),fdn_tmp(L_NSPECTI)
42      real*8 PLANCKSUM,PLANCKREF
43     
44! AB : variables for interpolation
45      REAL*8 C1
46      REAL*8 C2
47      REAL*8 P1
48     
49!======================================================================C
50     
51      NLEVRAD = L_NLEVRAD
52     
53! ZERO THE NET FLUXES
54      NFLUXTOPI = 0.0D0
55     
56      DO NW=1,L_NSPECTI
57        NFLUXTOPI_nu(NW) = 0.0D0
58        DO L=1,L_NLAYRAD
59           FLUXUPI_nu(L,NW) = 0.0D0
60           fup_tmp(nw)=0.0D0
61           fdn_tmp(nw)=0.0D0
62        END DO
63      END DO
64     
65      DO L=1,L_NLAYRAD
66        FMNETI(L)  = 0.0D0
67        FLUXUPI(L) = 0.0D0
68        FLUXDNI(L) = 0.0D0
69      END DO
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     
74      TTOP  = TLEV(2)  ! JL12 why not (1) ???
75      TSURF = TLEV(L_LEVELS)
76
77      NTS   = int(TSURF*NTfac)-NTstart+1
78      NTT   = int(TTOP *NTfac)-NTstart+1
79
80!JL12 corrects the surface planck function so that its integral is equal to sigma Tsurf^4
81!JL12 this ensure that no flux is lost due to:
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
85      PLANCKSUM = 0.d0
86      PLANCKREF = TSURF * TSURF
87      PLANCKREF = sigma * PLANCKREF * PLANCKREF
88     
89      DO NW=1,L_NSPECTI
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)
94      ENDDO
95     
96      PLANCKSUM = PLANCKREF / (PLANCKSUM * Pi)
97!JL12
98     
99      DO 501 NW=1,L_NSPECTI
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)
108         
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     *                TAUCUMI(1,NW,NG),
136     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
137     *                BSURF,FTOPUP,FMUPI,FMDI)
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),
178     *                TAUCUMI(1,NW,NG),
179     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
180     *                BSURF,FTOPUP,FMUPI,FMDI)
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)
187     *      +FTOPUP*DWNI(NW)*FZERO
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         
199  501 CONTINUE      !End Spectral Interval LOOP
200! *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE INFRARED****
201     
202      END SUBROUTINE SFLUXI
203
204      end module sfluxi_mod
Note: See TracBrowser for help on using the repository browser.