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