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

Last change on this file since 3436 was 3175, checked in by emillour, 11 months ago

Pluto PCM:
Add the old Pluto LMDZ for reference (required prior step to making
an LMDZ.PLUTO using the same framework as the other physics packages).
TB+EM

File size: 7.3 KB
Line 
1      SUBROUTINE SFLUXI(PLEV,TLEV,DTAUI,TAUCUMI,UBARI,RSFI,WNOI,DWNI,
2     *                  COSBI,WBARI,GWEIGHT,NFLUXTOPI,NFLUXTOPI_nu,
3     *                  FMNETI,fmneti_nu,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 FMNETI_NU(L_NLAYRAD,L_NSPECTI)
19      real*8 WNOI(L_NSPECTI), DWNI(L_NSPECTI)
20      real*8 DTAUI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
21      real*8 FMUPI(L_NLEVRAD), FMDI(L_NLEVRAD)
22      real*8 COSBI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
23      real*8 WBARI(L_NLAYRAD,L_NSPECTI,L_NGAUSS)
24      real*8 GWEIGHT(L_NGAUSS), NFLUXTOPI
25      real*8 NFLUXTOPI_nu(L_NSPECTI)
26      real*8 fluxupi_nu(L_NLAYRAD,L_NSPECTI)
27      real*8 FTOPUP
28
29      real*8 UBARI, RSFI, TSURF, BSURF, TTOP, BTOP, TAUTOP
30      real*8 PLANCK, PLTOP
31      real*8 fluxupi(L_NLAYRAD), fluxdni(L_NLAYRAD)
32      real*8 FZEROI(L_NSPECTI)
33      real*8 taugsurf(L_NSPECTI,L_NGAUSS-1), fzero
34
35      real*8 BSURFtest ! by RW for test
36
37      real*8 fup_tmp(L_NSPECTI),fdn_tmp(L_NSPECTI)
38      real*8 XX,YY   ! calcul intermediate
39
40
41C======================================================================C
42 
43      NLEVRAD = L_NLEVRAD
44 
45
46C     ZERO THE NET FLUXES
47   
48      NFLUXTOPI = 0.0
49      DO NW=1,L_NSPECTI
50        NFLUXTOPI_nu(NW) = 0.0
51        DO L=1,L_NLAYRAD
52           FLUXUPI_nu(L,NW) = 0.0
53           FMNETI_nu(L,NW)  = 0.0
54
55              fup_tmp(nw)=0.0
56              fdn_tmp(nw)=0.0
57
58        END DO
59      END DO
60
61      DO L=1,L_NLAYRAD
62        FMNETI(L)  = 0.0
63        FLUXUPI(L) = 0.0
64        FLUXDNI(L) = 0.0
65      END DO
66 
67C     WE NOW ENTER A MAJOR LOOP OVER SPECTRAL INTERVALS IN THE INFRARED
68C     TO CALCULATE THE NET FLUX IN EACH SPECTRAL INTERVAL
69
70      TTOP  = TLEV(2)
71      TSURF = TLEV(L_LEVELS)
72      !PRINT*, 'TB18 NTstar: ',NTstar,TSURF
73      NTS   = int(TSURF*10.0D0)-NTstar + 1
74      !PRINT*, 'TB18 NTS: ',NTS
75      !PRINT*, 'TB18 TLEV sfluxi: ',TLEV
76      NTT   = int(TTOP *10.0D0)-NTstar +1
77      !PRINT*, 'TB18 NTT: ',NTT
78
79! if temperatures superior to 50K
80!      NTS   = TSURF*10.0D0-499
81!      NTT   = TTOP *10.0D0-499
82
83! analyse
84c      write(*,*)'TTOP',TTOP
85c      write(*,*)'TSURF',TSURF
86c      write(*,*)'NTS',NTS
87c      write(*,*)'NTT',NTT
88c     DO L=1,L_LEVELS
89c         write(*,*)'TLEV',TLEV
90c      ENDDO
91      BSURFtest=0.0
92
93      DO 501  NW=1,L_NSPECTI
94
95C       SURFACE EMISSIONS - INDEPENDENT OF GAUSS POINTS
96        BSURF = (1.-RSFI)*PLANCKIR(NW,NTS) ! interpolate for accuracy??
97        PLTOP = PLANCKIR(NW,NTT)
98
99        !BSURFtest=BSURFtest+BSURF*DWNI(NW)
100        !if(NW.eq.L_NSPECTI)then
101        !     print*,'eps*sigma*T^4',5.67e-8*(1.-RSFI)*TSURF**4
102        !     print*,'BSURF in sfluxi=',pi*BSURFtest
103        !endif
104
105
106C  If FZEROI(NW) = 1, then the k-coefficients are zero - skip to the
107C  special Gauss point at the end.
108 
109        FZERO = FZEROI(NW)
110        IF(FZERO.ge.0.99) goto 40
111 
112        DO NG=1,L_NGAUSS-1
113         
114          if(TAUGSURF(NW,NG).lt. TLIMIT) then
115            fzero = fzero + (1.0-FZEROI(NW))*GWEIGHT(NG)
116            goto 30
117          end if
118
119C         SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE IR
120C         CALCULATE THE DOWNWELLING RADIATION AT THE TOP OF THE MODEL
121C         OR THE TOP LAYER WILL COOL TO SPACE UNPHYSICALLY
122 
123          TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
124          BTOP   = (1.0-EXP(-TAUTOP/UBARI))*PLTOP
125 
126C         WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
127C         CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
128C         WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
129         
130          CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
131     *                TAUCUMI(1,NW,NG),
132     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
133     *                BSURF,FTOPUP,FMUPI,FMDI)
134
135
136C         NOW CALCULATE THE CUMULATIVE IR NET FLUX
137          XX= FTOPUP*DWNI(NW)*GWEIGHT(NG)*(1.0-FZEROI(NW))
138          NFLUXTOPI =        NFLUXTOPI+ XX
139          NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW) + XX !same by spectral band.
140
141
142          DO L=1,L_NLEVRAD-1
143
144C           CORRECT FOR THE WAVENUMBER INTERVALS
145            YY = DWNI(NW)*GWEIGHT(NG)*(1.0-FZEROI(NW))
146
147            FMNETI(L)  = FMNETI(L)+(FMUPI(L)-FMDI(L))* YY
148            FMNETI_nu(L,NW)  = FMNETI_nu(L,NW)+(FMUPI(L)-FMDI(L))* YY !same by spectral band
149            FLUXDNI(L) = FLUXDNI(L) + FMDI(L)* YY
150
151            FLUXUPI(L) = FLUXUPI(L) +  FMUPI(L)* YY
152            FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW) +  FMUPI(L)* YY  !same by spectral band.
153          END DO
154
155         !fup_tmp(nw)=fup_tmp(nw)+FMUPI(L_NLEVRAD-1)*DWNI(NW)*GWEIGHT(NG)
156         !fdn_tmp(nw)=fdn_tmp(nw)+FMDI(L_NLEVRAD-1)*DWNI(NW)*GWEIGHT(NG)
157         !fup_tmp(nw)=fup_tmp(nw)+FMUPI(1)*DWNI(NW)*GWEIGHT(NG)
158         !fdn_tmp(nw)=fdn_tmp(nw)+FMDI(1)*DWNI(NW)*GWEIGHT(NG)
159
160   30     CONTINUE
161
162       END DO       !End NGAUSS LOOP
163
164           ! print*,'-----------------------------------'
165            !print*,'FMDI(',nw,')=',FMDI(L_NLEVRAD-1)
166            !print*,'FMUPI(',nw,')=',FMUPI(L_NLEVRAD-1)
167            !print*,'DWNI(',nw,')=',DWNI(nw)
168           ! print*,'-----------------------------------'
169
170   40  CONTINUE
171
172C      SPECIAL 17th Gauss point
173
174    !   print*,'fzero for ng=17',fzero
175
176
177       NG     = L_NGAUSS
178
179       TAUTOP = DTAUI(1,NW,NG)*PLEV(2)/(PLEV(4)-PLEV(2))
180       BTOP   = (1.0-EXP(-TAUTOP/UBARI))*PLTOP
181
182C      WE CAN NOW SOLVE FOR THE COEFFICIENTS OF THE TWO STREAM
183C      CALL A SUBROUTINE THAT SOLVES  FOR THE FLUX TERMS
184C      WITHIN EACH INTERVAL AT THE MIDPOINT WAVENUMBER
185
186
187       CALL GFLUXI(NLEVRAD,TLEV,NW,DWNI(NW),DTAUI(1,NW,NG),
188     *                TAUCUMI(1,NW,NG),
189     *                WBARI(1,NW,NG),COSBI(1,NW,NG),UBARI,RSFI,BTOP,
190     *                BSURF,FTOPUP,FMUPI,FMDI)
191 
192C      NOW CALCULATE THE CUMULATIVE IR NET FLUX
193
194       NFLUXTOPI = NFLUXTOPI+FTOPUP*DWNI(NW)*FZERO
195       NFLUXTOPI_nu(NW) = NFLUXTOPI_nu(NW)+FTOPUP*DWNI(NW)*FZERO !same by spectral band.
196
197       DO L=1,L_NLEVRAD-1
198
199C        CORRECT FOR THE WAVENUMBER INTERVALS
200
201         FLUXDNI(L) = FLUXDNI(L) + FMDI(L)*DWNI(NW)*FZERO
202
203         XX = (FMUPI(L)-FMDI(L))*DWNI(NW)*FZERO
204         FMNETI(L)  = FMNETI(L)+ XX
205         FMNETI_nu(L,NW)  = FMNETI_nu(L,NW)+XX !same by spectral band.
206
207         XX=  FMUPI(L)*DWNI(NW)*FZERO
208         FLUXUPI(L) = FLUXUPI(L) + XX
209         FLUXUPI_nu(L,NW) = FLUXUPI_nu(L,NW) + XX !same by spectral band.
210
211       END DO
212
213       !     print*,'-----------------------------------'
214       !     print*,'nw=',nw
215       !     print*,'ng=',ng
216       !     print*,'FMDI=',FMDI(L_NLEVRAD-1)
217       !     print*,'FMUPI=',FMUPI(L_NLEVRAD-1)
218       !     print*,'-----------------------------------'
219
220  501 CONTINUE      !End Spectral Interval LOOP
221
222C *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE INFRARED****
223
224            !print*,'-----------------------------------'
225            !print*,'gweight=',gweight
226            !print*,'FLUXDNI=',FLUXDNI(L_NLEVRAD-1)
227            !print*,'FLUXUPI=',FLUXUPI(L_NLEVRAD-1)
228            !print*,'-----------------------------------'
229
230            !do nw=1,L_NSPECTI
231            !   print*,'fup_tmp(',nw,')=',fup_tmp(nw)
232            !   print*,'fdn_tmp(',nw,')=',fdn_tmp(nw)
233            !enddo
234
235
236      RETURN
237      END
Note: See TracBrowser for help on using the repository browser.