/[lmdze]/trunk/Sources/phylmd/diagetpq.f
ViewVC logotype

Diff of /trunk/Sources/phylmd/diagetpq.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/libf/phylmd/diagetpq.f revision 47 by guez, Fri Jul 1 15:00:48 2011 UTC trunk/Sources/phylmd/diagetpq.f revision 178 by guez, Fri Mar 11 18:47:26 2016 UTC
# Line 1  Line 1 
1        SUBROUTINE diagetpq(airephy,tit,iprt,idiag,idiag2,dtime  module diagetpq_m
2       e  ,t,q,ql,qs,u,v,paprs  
3       s  , d_h_vcol, d_qt, d_qw, d_ql, d_qs, d_ec)    IMPLICIT NONE
4  !  
5  ! $Header: /home/cvsroot/LMDZ4/libf/phylmd/diagphy.F,v 1.1.1.1 2004/05/19 12:53:08 lmdzadmin Exp $  contains
6  !  
7  C======================================================================    SUBROUTINE diagetpq(airephy, tit, iprt, idiag, idiag2, dtime, t, q, ql, &
8  C         u, v, paprs, d_h_vcol, d_qt, d_ec)
9  C Purpose:  
10  C    Calcul la difference d'enthalpie et de masse d'eau entre 2 appels,      ! From LMDZ4/libf/phylmd/diagphy.F, version 1.1.1.1, 2004/05/19 12:53:08
11  C    et calcul le flux de chaleur et le flux d'eau necessaire a ces  
12  C    changements. Ces valeurs sont moyennees sur la surface de tout      ! Purpose:
13  C    le globe et sont exprime en W/2 et kg/s/m2  
14  C    Outil pour diagnostiquer la conservation de l'energie      ! Calcule la différence d'enthalpie et de masse d'eau entre deux
15  C    et de la masse dans la physique. Suppose que les niveau de      ! appels et calcule le flux de chaleur et le flux d'eau
16  c    pression entre couche ne varie pas entre 2 appels.      ! nécessaires à ces changements. Ces valeurs sont moyennées sur la
17  C      ! surface de tout le globe et sont exprimées en W/m2 et
18  C Plusieurs de ces diagnostics peuvent etre fait en parallele: les      ! kg/s/m2. Outil pour diagnostiquer la conservation de l'énergie
19  c bilans sont sauvegardes dans des tableaux indices. On parlera      ! et de la masse dans la physique. Suppose que les niveaux de
20  C "d'indice de diagnostic"      ! pression entre les couches ne varient pas entre deux appels.
21  c  
22  C      ! Plusieurs de ces diagnostics peuvent être faits en parallèle :
23  c======================================================================      ! les bilans sont sauvegardés dans des tableaux indices. On
24  C Arguments:      ! parlera "d'indice de diagnostic".
25  C airephy-------input-R-  grid area  
26  C tit-----imput-A15- Comment added in PRINT (CHARACTER*15)      ! Jean-Louis Dufresne, July 2002
27  C iprt----input-I-  PRINT level ( <=1 : no PRINT)  
28  C idiag---input-I- indice dans lequel sera range les nouveaux      USE dimphy, ONLY: klev, klon
29  C                  bilans d' entalpie et de masse      USE suphec_m, ONLY: rcpd, rcpv, rcw, rg, rlvtt
30  C idiag2--input-I-les nouveaux bilans d'entalpie et de masse  
31  C                 sont compare au bilan de d'enthalpie de masse de      ! Arguments:
32  C                 l'indice numero idiag2  
33  C                 Cas parriculier : si idiag2=0, pas de comparaison, on      ! Input variables
34  c                 sort directement les bilans d'enthalpie et de masse      real, intent(in):: airephy(klon) ! grid area
35  C dtime----input-R- time step (s)      CHARACTER(len=*), intent(in):: tit ! comment added in PRINT
36  c t--------input-R- temperature (K)      INTEGER, intent(in):: iprt ! PRINT level ( <=1 : no PRINT)
37  c q--------input-R- vapeur d'eau (kg/kg)  
38  c ql-------input-R- liquid watter (kg/kg)      INTEGER, intent(in):: idiag
39  c qs-------input-R- solid watter (kg/kg)      ! indice dans lequel seront rangés les nouveaux bilans d'enthalpie et
40  c u--------input-R- vitesse u      ! de masse
41  c v--------input-R- vitesse v  
42  c paprs----input-R- pression a intercouche (Pa)      INTEGER, intent(in):: idiag2
43  c      ! Les nouveaux bilans d'enthalpie et de masse sont comparés au
44  C the following total value are computed by UNIT of earth surface      ! bilan de d'enthalpie de masse de l'indice numéro idiag2. Cas
45  C      ! particulier : si idiag2=0, pas de comparaison, on sort
46  C d_h_vcol--output-R- Heat flux (W/m2) define as the Enthalpy      ! directement les bilans d'enthalpie et de masse.
47  c            change (J/m2) during one time step (dtime) for the whole  
48  C            atmosphere (air, watter vapour, liquid and solid)      REAL, intent(in):: dtime ! time step (s)
49  C d_qt------output-R- total water mass flux (kg/m2/s) defined as the      REAL, intent(in):: t(klon, klev) ! temperature (K)
50  C           total watter (kg/m2) change during one time step (dtime),      REAL, intent(in):: q(klon, klev) ! vapeur d'eau (kg/kg)
51  C d_qw------output-R- same, for the watter vapour only (kg/m2/s)      REAL, intent(in):: ql(klon, klev) ! liquid water (kg/kg)
52  C d_ql------output-R- same, for the liquid watter only (kg/m2/s)      REAL, intent(in):: u(klon, klev), v(klon, klev) ! vitesse
53  C d_qs------output-R- same, for the solid watter only (kg/m2/s)      REAL, intent(in):: paprs(klon, klev+1) ! pression a intercouche (Pa)
54  C d_ec------output-R- Cinetic Energy Budget (W/m2) for vertical air column  
55  C      ! The following total values are computed per UNIT of Earth surface
56  C     other (COMMON...)  
57  C     RCPD, RCPV, ....      REAL, intent(out):: d_h_vcol
58  C      ! heat flux (W/m2) defined as the enthalpy change (J/m2) during
59  C J.L. Dufresne, July 2002      ! one time step (dtime) for the whole atmosphere (air, water
60  c======================================================================      ! vapour, liquid and solid)
61    
62        use dimens_m      REAL, intent(out):: d_qt
63        use dimphy      ! total water mass flux (kg/m2/s) defined as the
64        use SUPHEC_M      ! total water (kg/m2) change during one time step (dtime)
65        use yoethf_m  
66        IMPLICIT NONE      REAL, intent(out):: d_ec
67  C      ! kinetic energy budget (W/m2) for vertical air column
68  C  
69  c     Input variables      ! Local:
70        real airephy(klon)  
71        CHARACTER*15 tit      REAL d_qw
72        INTEGER iprt,idiag, idiag2      ! water vapour mass flux (kg/m2/s) defined as the water vapour
73        REAL, intent(in):: dtime      ! (kg/m2) change during one time step (dtime)
74        REAL t(klon,klev), q(klon,klev), ql(klon,klev), qs(klon,klev)  
75        REAL u(klon,klev), v(klon,klev)      REAL d_ql ! same, for the liquid water only (kg/m2/s)
76        REAL, intent(in):: paprs(klon,klev+1)  
77  c     Output variables      REAL h_vcol_tot
78        REAL d_h_vcol, d_qt, d_qw, d_ql, d_qs, d_ec      ! total enthalpy of vertical air column (air with water vapour,
79  C      ! liquid and solid) (J/m2)
80  C     Local variables  
81  c      REAL h_dair_tot ! total enthalpy of dry air (J/m2)
82        REAL h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot      REAL h_qw_tot ! total enthalpy of water vapour (J/m2)
83       .  , h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot      REAL h_ql_tot ! total enthalpy of liquid water (J/m2)
84  c h_vcol_tot--  total enthalpy of vertical air column      REAL qw_tot ! total mass of water vapour (kg/m2)
85  C            (air with watter vapour, liquid and solid) (J/m2)      REAL ql_tot ! total mass of liquid water (kg/m2)
86  c h_dair_tot-- total enthalpy of dry air (J/m2)      real ec_tot ! total kinetic energy (kg/m2)
87  c h_qw_tot----  total enthalpy of watter vapour (J/m2)      REAL zairm(klon, klev) ! layer air mass (kg/m2)
88  c h_ql_tot----  total enthalpy of liquid watter (J/m2)      REAL zqw_col(klon)
89  c h_qs_tot----  total enthalpy of solid watter  (J/m2)      REAL zql_col(klon)
90  c qw_tot------  total mass of watter vapour (kg/m2)      REAL zec_col(klon)
91  c ql_tot------  total mass of liquid watter (kg/m2)      REAL zh_dair_col(klon)
92  c qs_tot------  total mass of solid watter (kg/m2)      REAL zh_qw_col(klon), zh_ql_col(klon)
93  c ec_tot------  total cinetic energy (kg/m2)      REAL airetot, zcpvap, zcwat
94  C      INTEGER i, k
95        REAL zairm(klon,klev) ! layer air mass (kg/m2)      INTEGER, PARAMETER:: ndiag = 10 ! max number of diagnostic in parallel
96        REAL  zqw_col(klon)      integer:: pas(ndiag) = 0
97        REAL  zql_col(klon)      REAL, save:: h_vcol_pre(ndiag)
98        REAL  zqs_col(klon)      REAL, save:: qw_pre(ndiag), ql_pre(ndiag)
99        REAL  zec_col(klon)      REAL, save:: ec_pre(ndiag)
100        REAL  zh_dair_col(klon)  
101        REAL  zh_qw_col(klon), zh_ql_col(klon), zh_qs_col(klon)      !-------------------------------------------------------------
102  C  
103        REAL      d_h_dair, d_h_qw, d_h_ql, d_h_qs      DO k = 1, klev
104  C         DO i = 1, klon
105        REAL airetot, zcpvap, zcwat, zcice            zairm(i, k) = (paprs(i, k)-paprs(i, k+1))/RG
106  C         ENDDO
107        INTEGER i, k      END DO
108  C  
109        INTEGER ndiag     ! max number of diagnostic in parallel      ! Reset variables
110        PARAMETER (ndiag=10)      DO i = 1, klon
111        integer pas(ndiag)         zqw_col(i)=0.
112        save pas         zql_col(i)=0.
113        data pas/ndiag*0/         zec_col(i) = 0.
114  C             zh_dair_col(i) = 0.
115        REAL      h_vcol_pre(ndiag), h_dair_pre(ndiag), h_qw_pre(ndiag)         zh_qw_col(i) = 0.
116       $    , h_ql_pre(ndiag), h_qs_pre(ndiag), qw_pre(ndiag)         zh_ql_col(i) = 0.
117       $    , ql_pre(ndiag), qs_pre(ndiag) , ec_pre(ndiag)      ENDDO
118        SAVE      h_vcol_pre, h_dair_pre, h_qw_pre, h_ql_pre  
119       $        , h_qs_pre, qw_pre, ql_pre, qs_pre , ec_pre      zcpvap=RCPV
120        zcwat=RCW
121  c======================================================================  
122  C      ! Compute vertical sum for each atmospheric column
123        DO k = 1, klev      DO k = 1, klev
124          DO i = 1, klon         DO i = 1, klon
125  C         layer air mass            ! Water mass
126            zairm(i,k) = (paprs(i,k)-paprs(i,k+1))/RG            zqw_col(i) = zqw_col(i) + q(i, k)*zairm(i, k)
127          ENDDO            zql_col(i) = zql_col(i) + ql(i, k)*zairm(i, k)
128        END DO            ! Kinetic Energy
129  C            zec_col(i) = zec_col(i) +0.5*(u(i, k)**2+v(i, k)**2)*zairm(i, k)
130  C     Reset variables            ! Air enthalpy
131        DO i = 1, klon            zh_dair_col(i) = zh_dair_col(i) &
132          zqw_col(i)=0.                 + RCPD*(1.-q(i, k)-ql(i, k))*zairm(i, k)*t(i, k)
133          zql_col(i)=0.            zh_qw_col(i) = zh_qw_col(i) + zcpvap*q(i, k)*zairm(i, k)*t(i, k)
134          zqs_col(i)=0.            zh_ql_col(i) = zh_ql_col(i) &
135          zec_col(i) = 0.                 + zcwat*ql(i, k)*zairm(i, k)*t(i, k) &
136          zh_dair_col(i) = 0.                 - RLVTT*ql(i, k)*zairm(i, k)
137          zh_qw_col(i) = 0.         END DO
138          zh_ql_col(i) = 0.      ENDDO
139          zh_qs_col(i) = 0.  
140        ENDDO      ! Mean over the planet surface
141  C      qw_tot = 0.
142        zcpvap=RCPV      ql_tot = 0.
143        zcwat=RCW      ec_tot = 0.
144        zcice=RCS      h_vcol_tot = 0.
145  C      h_dair_tot = 0.
146  C     Compute vertical sum for each atmospheric column      h_qw_tot = 0.
147  C     ================================================      h_ql_tot = 0.
148        DO k = 1, klev      airetot=0.
149          DO i = 1, klon  
150  C         Watter mass      do i=1, klon
151            zqw_col(i) = zqw_col(i) + q(i,k)*zairm(i,k)         qw_tot = qw_tot + zqw_col(i)*airephy(i)
152            zql_col(i) = zql_col(i) + ql(i,k)*zairm(i,k)         ql_tot = ql_tot + zql_col(i)*airephy(i)
153            zqs_col(i) = zqs_col(i) + qs(i,k)*zairm(i,k)         ec_tot = ec_tot + zec_col(i)*airephy(i)
154  C         Cinetic Energy         h_dair_tot = h_dair_tot + zh_dair_col(i)*airephy(i)
155            zec_col(i) =  zec_col(i)         h_qw_tot = h_qw_tot + zh_qw_col(i)*airephy(i)
156       $        +0.5*(u(i,k)**2+v(i,k)**2)*zairm(i,k)         h_ql_tot = h_ql_tot + zh_ql_col(i)*airephy(i)
157  C         Air enthalpy         airetot=airetot+airephy(i)
158            zh_dair_col(i) = zh_dair_col(i)      END DO
159       $        + RCPD*(1.-q(i,k)-ql(i,k)-qs(i,k))*zairm(i,k)*t(i,k)  
160            zh_qw_col(i) = zh_qw_col(i)      qw_tot = qw_tot/airetot
161       $        + zcpvap*q(i,k)*zairm(i,k)*t(i,k)      ql_tot = ql_tot/airetot
162            zh_ql_col(i) = zh_ql_col(i)      ec_tot = ec_tot/airetot
163       $        + zcwat*ql(i,k)*zairm(i,k)*t(i,k)      h_dair_tot = h_dair_tot/airetot
164       $        - RLVTT*ql(i,k)*zairm(i,k)      h_qw_tot = h_qw_tot/airetot
165            zh_qs_col(i) = zh_qs_col(i)      h_ql_tot = h_ql_tot/airetot
166       $        + zcice*qs(i,k)*zairm(i,k)*t(i,k)  
167       $        - RLSTT*qs(i,k)*zairm(i,k)      h_vcol_tot = h_dair_tot+h_qw_tot+h_ql_tot
168    
169          END DO      ! Compute the change of the atmospheric state compared to the one
170        ENDDO      ! stored in "idiag2", and convert it in flux. This computation is
171  C      ! performed if idiag2 /= 0 and if it is not the first call for
172  C     Mean over the planete surface      ! "idiag".
173  C     =============================  
174        qw_tot = 0.      IF (idiag2 > 0 .and. pas(idiag2) /= 0) THEN
175        ql_tot = 0.         d_h_vcol = (h_vcol_tot - h_vcol_pre(idiag2) )/dtime
176        qs_tot = 0.         d_qw = (qw_tot - qw_pre(idiag2) )/dtime
177        ec_tot = 0.         d_ql = (ql_tot - ql_pre(idiag2) )/dtime
178        h_vcol_tot = 0.         d_ec = (ec_tot - ec_pre(idiag2) )/dtime
179        h_dair_tot = 0.         d_qt = d_qw + d_ql
180        h_qw_tot = 0.      ELSE
181        h_ql_tot = 0.         d_h_vcol = 0.
182        h_qs_tot = 0.         d_qw = 0.
183        airetot=0.         d_ql = 0.
184  C         d_ec = 0.
185        do i=1,klon         d_qt = 0.
186          qw_tot = qw_tot + zqw_col(i)*airephy(i)      ENDIF
187          ql_tot = ql_tot + zql_col(i)*airephy(i)  
188          qs_tot = qs_tot + zqs_col(i)*airephy(i)      IF (iprt >= 2) THEN
189          ec_tot = ec_tot + zec_col(i)*airephy(i)         print 9000, tit, pas(idiag), d_qt, d_qw, d_ql
190          h_dair_tot = h_dair_tot + zh_dair_col(i)*airephy(i)         print 9001, tit, pas(idiag), d_h_vcol
191          h_qw_tot = h_qw_tot + zh_qw_col(i)*airephy(i)         print 9002, tit, pas(idiag), d_ec
192          h_ql_tot = h_ql_tot + zh_ql_col(i)*airephy(i)      END IF
193          h_qs_tot = h_qs_tot + zh_qs_col(i)*airephy(i)  
194          airetot=airetot+airephy(i)      ! Store the new atmospheric state in "idiag"
195        END DO      pas(idiag)=pas(idiag)+1
196  C      h_vcol_pre(idiag) = h_vcol_tot
197        qw_tot = qw_tot/airetot      qw_pre(idiag) = qw_tot
198        ql_tot = ql_tot/airetot      ql_pre(idiag) = ql_tot
199        qs_tot = qs_tot/airetot      ec_pre (idiag) = ec_tot
200        ec_tot = ec_tot/airetot  
201        h_dair_tot = h_dair_tot/airetot  9000 format('Physics water mass budget (kg/m2/s)', A15, 1i6, 10(1pE14.6))
202        h_qw_tot = h_qw_tot/airetot  9001 format('Physics enthalpy budget (W/m2) ', A15, 1i6, 10(F8.2))
203        h_ql_tot = h_ql_tot/airetot  9002 format('Physics kinetic energy budget (W/m2) ', A15, 1i6, 10(F8.2))
204        h_qs_tot = h_qs_tot/airetot  
205  C    END SUBROUTINE diagetpq
206        h_vcol_tot = h_dair_tot+h_qw_tot+h_ql_tot+h_qs_tot  
207  C  end module diagetpq_m
 C     Compute the change of the atmospheric state compare to the one  
 C     stored in "idiag2", and convert it in flux. THis computation  
 C     is performed IF idiag2 /= 0 and IF it is not the first CALL  
 c     for "idiag"  
 C     ===================================  
 C  
       IF ( (idiag2.gt.0) .and. (pas(idiag2) .ne. 0) ) THEN  
         d_h_vcol  = (h_vcol_tot - h_vcol_pre(idiag2) )/dtime  
         d_h_dair = (h_dair_tot- h_dair_pre(idiag2))/dtime  
         d_h_qw   = (h_qw_tot  - h_qw_pre(idiag2)  )/dtime  
         d_h_ql   = (h_ql_tot  - h_ql_pre(idiag2)  )/dtime  
         d_h_qs   = (h_qs_tot  - h_qs_pre(idiag2)  )/dtime  
         d_qw     = (qw_tot    - qw_pre(idiag2)    )/dtime  
         d_ql     = (ql_tot    - ql_pre(idiag2)    )/dtime  
         d_qs     = (qs_tot    - qs_pre(idiag2)    )/dtime  
         d_ec     = (ec_tot    - ec_pre(idiag2)    )/dtime  
         d_qt = d_qw + d_ql + d_qs  
       ELSE  
         d_h_vcol = 0.  
         d_h_dair = 0.  
         d_h_qw   = 0.  
         d_h_ql   = 0.  
         d_h_qs   = 0.  
         d_qw     = 0.  
         d_ql     = 0.  
         d_qs     = 0.  
         d_ec     = 0.  
         d_qt     = 0.  
       ENDIF  
 C  
       IF (iprt.ge.2) THEN  
         WRITE(6,9000) tit,pas(idiag),d_qt,d_qw,d_ql,d_qs  
  9000   format('Phys. Watter Mass Budget (kg/m2/s)',A15  
      $      ,1i6,10(1pE14.6))  
         WRITE(6,9001) tit,pas(idiag), d_h_vcol  
  9001   format('Phys. Enthalpy Budget (W/m2) ',A15,1i6,10(F8.2))  
         WRITE(6,9002) tit,pas(idiag), d_ec  
  9002   format('Phys. Cinetic Energy Budget (W/m2) ',A15,1i6,10(F8.2))  
       END IF  
 C  
 C     Store the new atmospheric state in "idiag"  
 C  
       pas(idiag)=pas(idiag)+1  
       h_vcol_pre(idiag)  = h_vcol_tot  
       h_dair_pre(idiag) = h_dair_tot  
       h_qw_pre(idiag)   = h_qw_tot  
       h_ql_pre(idiag)   = h_ql_tot  
       h_qs_pre(idiag)   = h_qs_tot  
       qw_pre(idiag)     = qw_tot  
       ql_pre(idiag)     = ql_tot  
       qs_pre(idiag)     = qs_tot  
       ec_pre (idiag)    = ec_tot  
 C  
       RETURN  
       END  

Legend:
Removed from v.47  
changed lines
  Added in v.178

  ViewVC Help
Powered by ViewVC 1.1.21