source: trunk/LMDZ.TITAN.old/libf/phytitan/sfluxv.F @ 3557

Last change on this file since 3557 was 1461, checked in by emillour, 10 years ago

Titan GCM:
Turned the common block "tgmdat.F" into a module "tgmdat_mod.F90".
This fixes issues in "debug" mode with common variables which seemed to not be correctly shared between routines.
EM

File size: 4.8 KB
Line 
1      SUBROUTINE SFLUXV(IPRINT,IG,dist_sol,falbe,icld)
2
3      use dimphy
4      USE TGMDAT_MOD, ONLY: UBARI,UBARV,UBAR0
5      USE TGMDAT_MOD, ONLY: F0PI
6      IMPLICIT NONE
7#include "dimensions.h"
8#include "comorbit.h"
9
10c  ASTUCE POUR EVITER klon... EN ATTENDANT MIEUX
11      INTEGER   ngrid
12      PARAMETER (ngrid=(jjm-1)*iim+2)  ! = klon
13c
14      INTEGER IG,IPRINT,icld
15      real dist_sol,falbe(ngrid)
16
17      INTEGER NLAYER,NLEVEL,NSPECV,NSPC1V
18      PARAMETER (NLAYER=llm,NLEVEL=NLAYER+1)
19      PARAMETER (NSPECV=24,NSPC1V=25)
20      INTEGER NT,NTERM(NSPECV),J,K
21
22      REAL FUW(NLEVEL),FDW(NLEVEL)
23      REAL DT0(NLAYER),T0(NLEVEL),WB0(NLAYER),CO0(NLAYER)
24      REAL BTOP, BSURF
25      REAL ATERM(4,NSPECV),BTERM(4,NSPECV)
26      REAL PEXPON(NSPECV), SOLARF(NSPECV)
27      REAL  DTAUV(ngrid,NLAYER,NSPECV,4)
28     &     ,TAUV (ngrid,NLEVEL,NSPECV,4)
29     &     ,WBARV(ngrid,NLAYER,NSPECV,4)
30     &     ,COSBV(ngrid,NLAYER,NSPECV,4)
31     &     ,DTAUVP(ngrid,NLAYER,NSPECV,4)
32     &     ,TAUVP(ngrid,NLEVEL,NSPECV,4)
33     &     ,WBARVP(ngrid,NLAYER,NSPECV,4)
34     &     ,COSBVP(ngrid,NLAYER,NSPECV,4)
35      REAL BWNV(NSPC1V),WNOV(NSPECV)
36     &     ,DWNV(NSPECV),WLNV(NSPECV)
37      REAL  FNETV(ngrid,NLEVEL),     
38     &      FUPV(ngrid,NLEVEL,NSPECV),
39     &      FDV(ngrid,NLEVEL,NSPECV),
40     &      FMNETV(ngrid,NLEVEL),
41     &      FMUPV(NLEVEL),FMDV(NLEVEL)
42
43      COMMON /VISGAS/SOLARF,NTERM,PEXPON,
44     &         ATERM,BTERM
45
46      COMMON /OPTICV/  DTAUV
47     &                ,TAUV
48     &                ,WBARV
49     &                ,COSBV
50     &                ,DTAUVP
51     &                ,TAUVP
52     &                ,WBARVP
53     &                ,COSBVP
54
55      COMMON /SPECTV/ BWNV,WNOV
56     &               ,DWNV,WLNV
57
58      COMMON /FLUXvV/ FNETV,     
59     &               FUPV,
60     &               FDV,
61     &               FMNETV
62
63
64* ON NE FAIT PAS LE CALCUL POUR TOUS LES IG EN MEME TEMPS
65* IG EST EN ARGUMENT...et SFLUXV EST APPELLEE NGRIDMX FOIS!
66
67C ZERO THE NET FLUXES
68      DO 212 J=1,NLEVEL
69      FNETV(ig,J)=-0.
70      FMNETV(ig,J)=-0.
71  212 CONTINUE
72C
73C WE NOW ENTER A MAJOR LOOP OVER SPECRAL INTERVALS IN THE VISIBLE
74C AND OVER THE HORIZONTAL GRIDS
75C TO CALCULATE THE NET FLUX IN EACH SPECTRAL INTERVAL
76C
77C ***************************************************************
78
79
80      DO 500 K=1,NSPECV          ! #2
81C ZERO THE SPECTRAL FLUXES IN ANTCIPATION OF SUMMING OVER NTERMS
82
83       DO 214 J=1,NLEVEL         ! #3
84       FUPV(ig,J,K)=0.
85       FDV(ig,J,K)=0.
86 214   CONTINUE
87C
88C SET UP THE UPPER AND LOWER BOUNDARY CONDITIONS ON THE VISIBLE
89      F0PI=SOLARF(K)*(p_elips/dist_sol)**2.
90      BTOP=0.0
91C
92C LOOP OVER THE NTERMS BEGINING HERE
93      DO 912 NT=1,NTERM(K)
94      IF (ICLD.eq.1) THEN
95        BSURF=0.+ falbe(ig)*UBAR0*F0PI*EXP(-TAUV(ig,NLEVEL,K,NT)/UBAR0)
96      ELSE
97        BSURF=0.+ falbe(ig)*UBAR0*F0PI*EXP(-TAUVP(ig,NLEVEL,K,NT)/UBAR0)
98      ENDIF
99C
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
103C
104C FUW AND FDW ARE WORKING FLUX ARRAYS THAT WILL BE USED TO
105C RETURN FLUXES FOR A GIVEN NT
106C
107C23456789012345678901234567890123456789012345678901234567890123456789012
108C
109C  USE DT0,T0,WB0,CO0 INSTEAD OF DTAUV(ig,1,K,NT)..etc...
110
111       IF (ICLD.EQ.1) THEN
112         DO  J=1,NLAYER       
113           DT0(J)=DTAUV(ig,J,K,NT)
114           T0(J) =TAUV(ig,J,K,NT)
115           WB0(J)=WBARV(ig,J,K,NT)
116           CO0(J)=COSBV(ig,J,K,NT)
117         ENDDO
118         T0(NLEVEL)=TAUV(ig,NLEVEL,K,NT)
119       ELSE
120         DO  J=1,NLAYER       
121           DT0(J)=DTAUVP(ig,J,K,NT)
122           T0(J) =TAUVP(ig,J,K,NT)
123           WB0(J)=WBARVP(ig,J,K,NT)
124           CO0(J)=COSBVP(ig,J,K,NT)
125         ENDDO
126         T0(NLEVEL)=TAUVP(ig,NLEVEL,K,NT)
127
128       ENDIF
129
130c       PRINT*,'entree gfluxv #: ',ig,K
131c        write(*,*) (DT0(J),J=1,NLAYER)
132c        print*,'---'
133c        write(*,*) (T0(J),J=1,NLEVEL)
134c        print*,'---'
135c        write(*,*) (WB0(J),J=1,NLAYER)
136c        print*,'---'
137c        write(*,*) (CO0(J),J=1,NLAYER)
138c        print*,'UBAR0 ',UBAR0
139c      print*,NLEVEL,WNOV(K),F0PI,falbe(ig),BTOP,BSURF
140       FUW = 0.0
141       FDW = 0.0
142       FMUPV=0.0
143       FMDV= 0.0
144       
145      CALL GFLUXV(NLEVEL,WNOV(K),DT0,T0,
146     & WB0,CO0,F0PI,falbe(ig),BTOP,BSURF,FUW,FDW,FMUPV,
147     &    FMDV,IPRINT)
148c       PRINT*,'sortie gfluxv #: ',ig,K
149c        print*,'UBAR0 ',UBAR0
150
151C NOW CALCULTE THE CUMULATIVE VISIBLE NET FLUX
152
153             DO 300 J=1,NLEVEL         !<------------
154      FMNETV(ig,J)=FMNETV(ig,J)+( FMUPV(J)-FMDV(J) )*ATERM(NT,K)
155      FNETV(ig,J)=FNETV(ig,J)+( FUW(J)-FDW(J) )*ATERM(NT,K)
156
157C AND THE SPECTRAL FLUXES SUMMED OVER THE NTERMS
158      FUPV(ig,J,K)=FUPV(ig,J,K)+FUW(J)*ATERM(NT,K)
159      FDV(ig,J,K)=FDV(ig,J,K)+FDW(J)*ATERM(NT,K)
160  300         CONTINUE                !<--------------
161C
162C
163  912 CONTINUE
164  500 CONTINUE
165
166C *** END OF MAJOR SPECTRAL INTERVAL LOOP IN THE VISIBLE*****
167      RETURN
168      END
Note: See TracBrowser for help on using the repository browser.