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

Last change on this file since 537 was 526, checked in by jleconte, 13 years ago

13/02/2012 == JL + AS

  • All outputs are now in netCDF format. Even in 1D (No more G1D)
  • Clean up of the call to callcorrk when CLFvarying=true
  • Corrects a bug in writediagspecIR/VI. Output are now in W/m2/cm-1 as a function of the wavenumber in cm-1
  • Enable writediagspecIR/V to work in the CLFvarying=true case (output now done in Physiq after writediagfi)
  • Add a simple treatment for the supersaturation of CO2 (see forget et al 2012)
  • corrects a small bug when no clouds are present in aeropacity
File size: 5.5 KB
Line 
1      SUBROUTINE SFLUXI(PLEV,TLEV,DTAUI,TAUCUMI,UBARI,RSFI,WNOI,DWNI,
2     *                  COSBI,WBARI,GWEIGHT,NFLUXTOPI,NFLUXTOPI_nu,
3     *                  FMNETI,fluxupi,fluxdni,fluxupi_nu,
4     *                  FZEROI,TAUGSURF)
5
6      use radinc_h
7      use radcommon_h, only: planckir, tlimit
8
9      implicit none
10
11#include "comcstfi.h"
12
13      integer NLEVRAD, L, NW, NG, NTS, NTT
14
15      real*8 TLEV(L_LEVELS), PLEV(L_LEVELS)
16      real*8 TAUCUMI(L_LEVELS,L_NSPECTI,L_NGAUSS)
17      real*8 FMNETI(L_NLAYRAD)
18      real*8 WNOI(L_NSPECTI), DWNI(L_NSPECTI)
19      real*8 DTAUI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
20      real*8 FMUPI(L_NLEVRAD), FMDI(L_NLEVRAD)
21      real*8 COSBI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
22      real*8 WBARI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
23      real*8 GWEIGHT(L_NGAUSS), NFLUXTOPI
24      real*8 NFLUXTOPI_nu(L_NSPECTI)
25      real*8 fluxupi_nu(L_NLAYRAD,L_NSPECTI)
26      real*8 FTOPUP
27
28      real*8 UBARI, RSFI, TSURF, BSURF, TTOP, BTOP, TAUTOP
29      real*8 PLANCK, PLTOP
30      real*8 fluxupi(L_NLAYRAD), fluxdni(L_NLAYRAD)
31      real*8 FZEROI(L_NSPECTI)
32      real*8 taugsurf(L_NSPECTI,L_NGAUSS-1), fzero
33
34      real*8 fup_tmp(L_NSPECTI),fdn_tmp(L_NSPECTI)
35
36
37C======================================================================C
38 
39      NLEVRAD = L_NLEVRAD
40 
41
42C     ZERO THE NET FLUXES
43   
44      NFLUXTOPI = 0.0
45
46      DO NW=1,L_NSPECTI
47        NFLUXTOPI_nu(NW) = 0.0
48        DO L=1,L_NLAYRAD
49           FLUXUPI_nu(L,NW) = 0.0
50
51              fup_tmp(nw)=0.0
52              fdn_tmp(nw)=0.0
53
54        END DO
55      END DO
56
57      DO L=1,L_NLAYRAD
58        FMNETI(L)  = 0.0
59        FLUXUPI(L) = 0.0
60        FLUXDNI(L) = 0.0
61      END DO
62 
63C     WE NOW ENTER A MAJOR LOOP OVER SPECTRAL INTERVALS IN THE INFRARED
64C     TO CALCULATE THE NET FLUX IN EACH SPECTRAL INTERVAL
65
66      TTOP  = TLEV(2)  ! JL12 why not (1) ???
67      TSURF = TLEV(L_LEVELS)
68
69      NTS   = int(TSURF*10.0D0)-NTstar+1
70      NTT   = int(TTOP *10.0D0)-NTstar+1
71!      NTS   = TSURF*10.0D0-499
72!      NTT   = TTOP *10.0D0-499
73
74      DO 501 NW=1,L_NSPECTI
75
76C       SURFACE EMISSIONS - INDEPENDENT OF GAUSS POINTS
77        BSURF = (1.-RSFI)*PLANCKIR(NW,NTS) ! interpolate for accuracy??
78        PLTOP = PLANCKIR(NW,NTT)
79
80C  If FZEROI(NW) = 1, then the k-coefficients are zero - skip to the
81C  special Gauss point at the end.
82 
83        FZERO = FZEROI(NW)
84        IF(FZERO.ge.0.99) goto 40
85 
86        DO NG=1,L_NGAUSS-1
87         
88          if(TAUGSURF(NW,NG).lt. TLIMIT) then
89            fzero = fzero + (1.0-FZEROI(NW))*GWEIGHT(NG)
90            goto 30
91          end if
92
93C         SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE IR
94C         CALCULATE THE DOWNWELLING RADIATION AT THE TOP OF THE MODEL
95C         OR THE TOP LAYER WILL COOL TO SPACE UNPHYSICALLY
96 
97          TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
98          BTOP   = (1.0-EXP(-TAUTOP/UBARI))*PLTOP
99 
100C         WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
101C         CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
102C         WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
103         
104          CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
105     *                TAUCUMI(1,NW,NG),
106     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
107     *                BSURF,FTOPUP,FMUPI,FMDI)
108
109
110
111C         NOW CALCULATE THE CUMULATIVE IR NET FLUX
112
113          NFLUXTOPI = NFLUXTOPI+FTOPUP*DWNI(NW)*GWEIGHT(NG)*
114     *                           (1.0-FZEROI(NW))
115
116c         and same thing by spectral band... (RDW)
117          NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW)
118     *      +FTOPUP*DWNI(NW)*GWEIGHT(NG)*(1.0-FZEROI(NW))
119
120
121          DO L=1,L_NLEVRAD-1
122
123C           CORRECT FOR THE WAVENUMBER INTERVALS
124
125            FMNETI(L)  = FMNETI(L)+(FMUPI(L)-FMDI(L))*DWNI(NW)*
126     *                              GWEIGHT(NG)*(1.0-FZEROI(NW))
127            FLUXUPI(L) = FLUXUPI(L) + FMUPI(L)*DWNI(NW)*GWEIGHT(NG)*
128     *                                (1.0-FZEROI(NW))
129            FLUXDNI(L) = FLUXDNI(L) + FMDI(L)*DWNI(NW)*GWEIGHT(NG)*
130     *                                (1.0-FZEROI(NW))
131
132c         and same thing by spectral band... (RW)
133            FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW) +
134     *                FMUPI(L)*DWNI(NW)*GWEIGHT(NG)*(1.0-FZEROI(NW))
135
136          END DO
137
138   30     CONTINUE
139
140       END DO       !End NGAUSS LOOP
141
142   40  CONTINUE
143
144C      SPECIAL 17th Gauss point
145
146       NG     = L_NGAUSS
147
148       TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
149       BTOP   = (1.0-EXP(-TAUTOP/UBARI))*PLTOP
150
151C      WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
152C      CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
153C      WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
154
155
156       CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
157     *                TAUCUMI(1,NW,NG),
158     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
159     *                BSURF,FTOPUP,FMUPI,FMDI)
160 
161C      NOW CALCULATE THE CUMULATIVE IR NET FLUX
162
163       NFLUXTOPI = NFLUXTOPI+FTOPUP*DWNI(NW)*FZERO
164
165c         and same thing by spectral band... (RW)
166          NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW)
167     *      +FTOPUP*DWNI(NW)*FZERO
168
169       DO L=1,L_NLEVRAD-1
170
171C        CORRECT FOR THE WAVENUMBER INTERVALS
172
173         FMNETI(L)  = FMNETI(L)+(FMUPI(L)-FMDI(L))*DWNI(NW)*FZERO
174         FLUXUPI(L) = FLUXUPI(L) + FMUPI(L)*DWNI(NW)*FZERO
175         FLUXDNI(L) = FLUXDNI(L) + FMDI(L)*DWNI(NW)*FZERO
176
177c         and same thing by spectral band... (RW)
178         FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW) + FMUPI(L)*DWNI(NW)*FZERO
179
180       END DO
181
182  501 CONTINUE      !End Spectral Interval LOOP
183
184C *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE INFRARED****
185
186      RETURN
187      END
Note: See TracBrowser for help on using the repository browser.