source: trunk/LMDZ.GENERIC/libf/phystd/sfluxv.F @ 848

Last change on this file since 848 was 366, checked in by rwordsworth, 13 years ago

OSR output bugs fixed.
Improvements to kcm for pure H2 atmospheres.

File size: 5.2 KB
Line 
1      SUBROUTINE SFLUXV(DTAUV,TAUV,TAUCUMV,RSFV,DWNV,WBARV,COSBV,
2     *                  UBAR0,STEL,GWEIGHT,NFLUXTOPV,NFLUXOUTV_nu,
3     *                  NFLUXGNDV_nu,
4     *                  FMNETV,FLUXUPV,FLUXDNV,FZEROV,taugsurf)
5
6      use radinc_h
7      use radcommon_h, only: tlimit
8
9      implicit none
10
11      real*8 FMNETV(L_NLAYRAD)
12      real*8 TAUCUMV(L_LEVELS,L_NSPECTV,L_NGAUSS)
13      real*8 TAUV(L_NLEVRAD,L_NSPECTV,L_NGAUSS)
14      real*8 DTAUV(L_NLAYRAD,L_NSPECTV,L_NGAUSS), DWNV(L_NSPECTV)
15      real*8 FMUPV(L_NLAYRAD), FMDV(L_NLAYRAD)
16      real*8 COSBV(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
17      real*8 WBARV(L_NLAYRAD,L_NSPECTV,L_NGAUSS)
18      real*8 STEL(L_NSPECTV)
19      real*8 FLUXUPV(L_NLAYRAD), FLUXDNV(L_NLAYRAD)
20      real*8 NFLUXTOPV, FLUXUP, FLUXDN
21      real*8 NFLUXOUTV_nu(L_NSPECTV)
22      real*8 NFLUXGNDV_nu(L_NSPECTV)
23      real*8 GWEIGHT(L_NGAUSS)
24
25      integer L, NG, NW, NG1,k
26      real*8  rsfv, ubar0, f0pi, btop, bsurf, taumax, eterm
27      real*8 FZEROV(L_NSPECTV)
28
29      real*8 DIFFV, DIFFVT
30      real*8 taugsurf(L_NSPECTV,L_NGAUSS-1), fzero
31
32C======================================================================C
33
34      TAUMAX = L_TAUMAX
35
36C     ZERO THE NET FLUXES
37
38      NFLUXTOPV = 0.0
39
40      DO NW=1,L_NSPECTV
41         NFLUXOUTV_nu(NW)=0.0
42         NFLUXGNDV_nu(NW)=0.0
43      END DO
44
45      DO L=1,L_NLAYRAD
46        FMNETV(L)  = 0.0
47        FLUXUPV(L) = 0.0
48        FLUXDNV(L) = 0.0
49      END DO
50
51      DIFFVT = 0.0
52
53C     WE NOW ENTER A MAJOR LOOP OVER SPECTRAL INTERVALS IN THE VISIBLE
54C     TO CALCULATE THE NET FLUX IN EACH SPECTRAL INTERVAL
55
56      DO 500 NW=1,L_NSPECTV
57     
58        F0PI = STEL(NW)
59
60        FZERO = FZEROV(NW)
61        IF(FZERO.ge.0.99) goto 40
62        DO NG=1,L_NGAUSS-1
63
64          if(TAUGSURF(NW,NG) .lt. TLIMIT) then
65
66            fzero = fzero + (1.0-FZEROV(NW))*GWEIGHT(NG)
67
68            goto 30
69          end if
70
71C         SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE VISIBLE
72
73          BTOP  = 0.0
74          !BSURF = 0./0. ! why was this here?
75          BSURF = 0.
76C         LOOP OVER THE NTERMS BEGINNING HERE
77 
78
79!      FACTOR    = 1.0D0 - WDEL(1)*CDEL(1)**2
80!      TAU(1)    = TDEL(1)*FACTOR
81
82
83          ETERM = MIN(TAUV(L_NLEVRAD,NW,NG),TAUMAX)
84          BSURF = RSFV*UBAR0*STEL(NW)*EXP(-ETERM/UBAR0)
85
86C         WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
87C         CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
88C         WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
89C
90C         FUW AND FDW ARE WORKING FLUX ARRAYS THAT WILL BE USED TO
91C         RETURN FLUXES FOR A GIVEN NT
92
93
94          CALL GFLUXV(DTAUV(1,NW,NG),TAUV(1,NW,NG),TAUCUMV(1,NW,NG),
95     *                WBARV(1,NW,NG),COSBV(1,NW,NG),UBAR0,F0PI,RSFV,
96     *                BTOP,BSURF,FMUPV,FMDV,DIFFV,FLUXUP,FLUXDN)
97
98C         NOW CALCULATE THE CUMULATIVE VISIBLE NET FLUX
99
100          NFLUXTOPV = NFLUXTOPV+(FLUXUP-FLUXDN)*GWEIGHT(NG)*
101     *                          (1.0-FZEROV(NW))
102          DO L=1,L_NLAYRAD
103            FMNETV(L)=FMNETV(L)+( FMUPV(L)-FMDV(L) )*
104     *                           GWEIGHT(NG)*(1.0-FZEROV(NW))
105            FLUXUPV(L) = FLUXUPV(L) + FMUPV(L)*GWEIGHT(NG)*
106     *                   (1.0-FZEROV(NW))
107            FLUXDNV(L) = FLUXDNV(L) + FMDV(L)*GWEIGHT(NG)*
108     *                   (1.0-FZEROV(NW))
109          END DO
110
111c     band-resolved flux leaving TOA (RDW)
112          NFLUXOUTV_nu(NW) = NFLUXOUTV_nu(NW)
113     *      +FLUXUP*GWEIGHT(NG)*(1.0-FZEROV(NW))
114
115c     band-resolved flux at ground (RDW)
116          NFLUXGNDV_nu(NW) = NFLUXGNDV_nu(NW)
117     *      +FMDV(L_NLAYRAD)*GWEIGHT(NG)*(1.0-FZEROV(NW))
118
119
120C         THE DIFFUSE COMPONENT OF THE DOWNWARD STELLAR FLUX
121
122          DIFFVT = DIFFVT + DIFFV*GWEIGHT(NG)*(1.0-FZEROV(NW))
123
124   30     CONTINUE
125
126        END DO   ! the Gauss loop
127
128   40   continue
129C       Special 17th Gauss point
130
131        NG = L_NGAUSS
132
133C       SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE VISIBLE
134 
135        BTOP = 0.0
136
137C       LOOP OVER THE NTERMS BEGINNING HERE
138 
139        ETERM = MIN(TAUV(L_NLEVRAD,NW,NG),TAUMAX)
140        BSURF = RSFV*UBAR0*STEL(NW)*EXP(-ETERM/UBAR0)
141
142
143C       WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
144C       CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
145C       WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
146C
147C       FUW AND FDW ARE WORKING FLUX ARRAYS THAT WILL BE USED TO
148C       RETURN FLUXES FOR A GIVEN NT
149
150        CALL GFLUXV(DTAUV(1,NW,NG),TAUV(1,NW,NG),TAUCUMV(1,NW,NG),
151     *              WBARV(1,NW,NG),COSBV(1,NW,NG),UBAR0,F0PI,RSFV,
152     *              BTOP,BSURF,FMUPV,FMDV,DIFFV,FLUXUP,FLUXDN)
153
154
155C       NOW CALCULATE THE CUMULATIVE VISIBLE NET FLUX
156
157        NFLUXTOPV = NFLUXTOPV+(FLUXUP-FLUXDN)*FZERO
158        DO L=1,L_NLAYRAD
159          FMNETV(L)=FMNETV(L)+( FMUPV(L)-FMDV(L) )*FZERO
160          FLUXUPV(L) = FLUXUPV(L) + FMUPV(L)*FZERO
161          FLUXDNV(L) = FLUXDNV(L) + FMDV(L)*FZERO
162        END DO
163
164c     band-resolved flux leaving TOA (RDW)
165          NFLUXOUTV_nu(NW) = NFLUXOUTV_nu(NW)
166     *      +FLUXUP*FZERO
167
168c     band-resolved flux at ground (RDW)
169          NFLUXGNDV_nu(NW) = NFLUXGNDV_nu(NW)+FMDV(L_NLAYRAD)*FZERO
170
171
172C       THE DIFFUSE COMPONENT OF THE DOWNWARD STELLAR FLUX
173
174        DIFFVT = DIFFVT + DIFFV*FZERO
175
176
177  500 CONTINUE
178
179
180C     *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE VISIBLE*****
181
182
183      RETURN
184      END
Note: See TracBrowser for help on using the repository browser.