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

Last change on this file since 3300 was 2899, checked in by emillour, 22 months ago

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

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