1 | ! |
---|
2 | ! $Id: diagedyn.f90 5285 2024-10-28 13:33:29Z evignon $ |
---|
3 | ! |
---|
4 | |
---|
5 | !====================================================================== |
---|
6 | SUBROUTINE diagedyn(tit,iprt,idiag,idiag2,dtime & |
---|
7 | , ucov , vcov , ps, p ,pk , teta , q, ql) |
---|
8 | !====================================================================== |
---|
9 | ! |
---|
10 | ! Purpose: |
---|
11 | ! Calcul la difference d'enthalpie et de masse d'eau entre 2 appels, |
---|
12 | ! et calcul le flux de chaleur et le flux d'eau necessaire a ces |
---|
13 | ! changements. Ces valeurs sont moyennees sur la surface de tout |
---|
14 | ! le globe et sont exprime en W/2 et kg/s/m2 |
---|
15 | ! Outil pour diagnostiquer la conservation de l'energie |
---|
16 | ! et de la masse dans la dynamique. |
---|
17 | ! |
---|
18 | ! |
---|
19 | !====================================================================== |
---|
20 | ! Arguments: |
---|
21 | ! tit-----imput-A15- Comment added in PRINT (CHARACTER*15) |
---|
22 | ! iprt----input-I- PRINT level ( <=1 : no PRINT) |
---|
23 | ! idiag---input-I- indice dans lequel sera range les nouveaux |
---|
24 | ! bilans d' entalpie et de masse |
---|
25 | ! idiag2--input-I-les nouveaux bilans d'entalpie et de masse |
---|
26 | ! sont compare au bilan de d'enthalpie de masse de |
---|
27 | ! l'indice numero idiag2 |
---|
28 | ! Cas parriculier : si idiag2=0, pas de comparaison, on |
---|
29 | ! sort directement les bilans d'enthalpie et de masse |
---|
30 | ! dtime----input-R- time step (s) |
---|
31 | ! uconv, vconv-input-R- vents covariants (m/s) |
---|
32 | ! ps-------input-R- Surface pressure (Pa) |
---|
33 | ! p--------input-R- pressure at the interfaces |
---|
34 | ! pk-------input-R- pk= (p/Pref)**kappa |
---|
35 | ! teta-----input-R- potential temperature (K) |
---|
36 | ! q--------input-R- vapeur d'eau (kg/kg) |
---|
37 | ! ql-------input-R- liquid watter (kg/kg) |
---|
38 | ! aire-----input-R- mesh surafce (m2) |
---|
39 | ! |
---|
40 | ! the following total value are computed by UNIT of earth surface |
---|
41 | ! |
---|
42 | ! d_h_vcol--output-R- Heat flux (W/m2) define as the Enthalpy |
---|
43 | ! change (J/m2) during one time step (dtime) for the whole |
---|
44 | ! atmosphere (air, watter vapour, liquid and solid) |
---|
45 | ! d_qt------output-R- total water mass flux (kg/m2/s) defined as the |
---|
46 | ! total watter (kg/m2) change during one time step (dtime), |
---|
47 | ! d_qw------output-R- same, for the watter vapour only (kg/m2/s) |
---|
48 | ! d_ql------output-R- same, for the liquid watter only (kg/m2/s) |
---|
49 | ! d_ec------output-R- Cinetic Energy Budget (W/m2) for vertical air column |
---|
50 | ! |
---|
51 | ! |
---|
52 | ! J.L. Dufresne, July 2002 |
---|
53 | !====================================================================== |
---|
54 | |
---|
55 | USE iniprint_mod_h |
---|
56 | USE comgeom_mod_h |
---|
57 | USE control_mod, ONLY : planet_type |
---|
58 | |
---|
59 | USE dimensions_mod, ONLY: iim, jjm, llm, ndm |
---|
60 | USE paramet_mod_h |
---|
61 | IMPLICIT NONE |
---|
62 | ! |
---|
63 | |
---|
64 | |
---|
65 | |
---|
66 | ! Ehouarn: for now set these parameters to what is in Earth physics... |
---|
67 | ! (cf ../phylmd/suphel.h) |
---|
68 | ! this should be generalized... |
---|
69 | REAL,PARAMETER :: RCPD= & |
---|
70 | 3.5*(1000.*(6.0221367E+23*1.380658E-23)/28.9644) |
---|
71 | REAL,PARAMETER :: RCPV= & |
---|
72 | 4.*(1000.*(6.0221367E+23*1.380658E-23)/18.0153) |
---|
73 | REAL,PARAMETER :: RCS=RCPV |
---|
74 | REAL,PARAMETER :: RCW=RCPV |
---|
75 | REAL,PARAMETER :: RLSTT=2.8345E+6 |
---|
76 | REAL,PARAMETER :: RLVTT=2.5008E+6 |
---|
77 | ! |
---|
78 | ! |
---|
79 | INTEGER :: imjmp1 |
---|
80 | PARAMETER( imjmp1=iim*jjp1) |
---|
81 | ! Input variables |
---|
82 | CHARACTER(len=15) :: tit |
---|
83 | INTEGER :: iprt,idiag, idiag2 |
---|
84 | REAL :: dtime |
---|
85 | REAL :: vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants |
---|
86 | REAL :: ps(ip1jmp1) ! pression au sol |
---|
87 | REAL :: p (ip1jmp1,llmp1 ) ! pression aux interfac.des couches |
---|
88 | REAL :: pk (ip1jmp1,llm ) ! = (p/Pref)**kappa |
---|
89 | REAL :: teta(ip1jmp1,llm) ! temperature potentielle |
---|
90 | REAL :: q(ip1jmp1,llm) ! champs eau vapeur |
---|
91 | REAL :: ql(ip1jmp1,llm) ! champs eau liquide |
---|
92 | |
---|
93 | |
---|
94 | ! Output variables |
---|
95 | REAL :: d_h_vcol, d_qt, d_qw, d_ql, d_qs, d_ec |
---|
96 | ! |
---|
97 | ! Local variables |
---|
98 | ! |
---|
99 | REAL :: h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot & |
---|
100 | , h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot |
---|
101 | ! h_vcol_tot-- total enthalpy of vertical air column |
---|
102 | ! (air with watter vapour, liquid and solid) (J/m2) |
---|
103 | ! h_dair_tot-- total enthalpy of dry air (J/m2) |
---|
104 | ! h_qw_tot---- total enthalpy of watter vapour (J/m2) |
---|
105 | ! h_ql_tot---- total enthalpy of liquid watter (J/m2) |
---|
106 | ! h_qs_tot---- total enthalpy of solid watter (J/m2) |
---|
107 | ! qw_tot------ total mass of watter vapour (kg/m2) |
---|
108 | ! ql_tot------ total mass of liquid watter (kg/m2) |
---|
109 | ! qs_tot------ total mass of solid watter (kg/m2) |
---|
110 | ! ec_tot------ total cinetic energy (kg/m2) |
---|
111 | ! |
---|
112 | REAL :: masse(ip1jmp1,llm) ! masse d'air |
---|
113 | REAL :: vcont(ip1jm,llm),ucont(ip1jmp1,llm) |
---|
114 | REAL :: ecin(ip1jmp1,llm) |
---|
115 | |
---|
116 | REAL :: zaire(imjmp1) |
---|
117 | REAL :: zps(imjmp1) |
---|
118 | REAL :: zairm(imjmp1,llm) |
---|
119 | REAL :: zecin(imjmp1,llm) |
---|
120 | REAL :: zpaprs(imjmp1,llm) |
---|
121 | REAL :: zpk(imjmp1,llm) |
---|
122 | REAL :: zt(imjmp1,llm) |
---|
123 | REAL :: zh(imjmp1,llm) |
---|
124 | REAL :: zqw(imjmp1,llm) |
---|
125 | REAL :: zql(imjmp1,llm) |
---|
126 | REAL :: zqs(imjmp1,llm) |
---|
127 | |
---|
128 | REAL :: zqw_col(imjmp1) |
---|
129 | REAL :: zql_col(imjmp1) |
---|
130 | REAL :: zqs_col(imjmp1) |
---|
131 | REAL :: zec_col(imjmp1) |
---|
132 | REAL :: zh_dair_col(imjmp1) |
---|
133 | REAL :: zh_qw_col(imjmp1), zh_ql_col(imjmp1), zh_qs_col(imjmp1) |
---|
134 | ! |
---|
135 | REAL :: d_h_dair, d_h_qw, d_h_ql, d_h_qs |
---|
136 | ! |
---|
137 | REAL :: airetot, zcpvap, zcwat, zcice |
---|
138 | ! |
---|
139 | INTEGER :: i, k, jj, ij , l ,ip1jjm1 |
---|
140 | ! |
---|
141 | INTEGER :: ndiag ! max number of diagnostic in parallel |
---|
142 | PARAMETER (ndiag=10) |
---|
143 | integer :: pas(ndiag) |
---|
144 | save pas |
---|
145 | data pas/ndiag*0/ |
---|
146 | ! |
---|
147 | REAL :: h_vcol_pre(ndiag), h_dair_pre(ndiag), h_qw_pre(ndiag) & |
---|
148 | , h_ql_pre(ndiag), h_qs_pre(ndiag), qw_pre(ndiag) & |
---|
149 | , ql_pre(ndiag), qs_pre(ndiag) , ec_pre(ndiag) |
---|
150 | SAVE h_vcol_pre, h_dair_pre, h_qw_pre, h_ql_pre & |
---|
151 | , h_qs_pre, qw_pre, ql_pre, qs_pre , ec_pre |
---|
152 | |
---|
153 | |
---|
154 | !#ifdef CPP_EARTH |
---|
155 | IF (planet_type=="earth") THEN |
---|
156 | |
---|
157 | !====================================================================== |
---|
158 | ! Compute Kinetic enrgy |
---|
159 | CALL covcont ( llm , ucov , vcov , ucont, vcont ) |
---|
160 | CALL enercin ( vcov , ucov , vcont , ucont , ecin ) |
---|
161 | CALL massdair( p, masse ) |
---|
162 | !====================================================================== |
---|
163 | ! |
---|
164 | ! |
---|
165 | print*,'MAIS POURQUOI DONC DIAGEDYN NE MARCHE PAS ?' |
---|
166 | return |
---|
167 | ! On ne garde les donnees que dans les colonnes i=1,iim |
---|
168 | DO jj = 1,jjp1 |
---|
169 | ip1jjm1=iip1*(jj-1) |
---|
170 | DO ij = 1,iim |
---|
171 | i=iim*(jj-1)+ij |
---|
172 | zaire(i)=aire(ij+ip1jjm1) |
---|
173 | zps(i)=ps(ij+ip1jjm1) |
---|
174 | ENDDO |
---|
175 | ENDDO |
---|
176 | ! 3D arrays |
---|
177 | DO l = 1, llm |
---|
178 | DO jj = 1,jjp1 |
---|
179 | ip1jjm1=iip1*(jj-1) |
---|
180 | DO ij = 1,iim |
---|
181 | i=iim*(jj-1)+ij |
---|
182 | zairm(i,l) = masse(ij+ip1jjm1,l) |
---|
183 | zecin(i,l) = ecin(ij+ip1jjm1,l) |
---|
184 | zpaprs(i,l) = p(ij+ip1jjm1,l) |
---|
185 | zpk(i,l) = pk(ij+ip1jjm1,l) |
---|
186 | zh(i,l) = teta(ij+ip1jjm1,l) |
---|
187 | zqw(i,l) = q(ij+ip1jjm1,l) |
---|
188 | zql(i,l) = ql(ij+ip1jjm1,l) |
---|
189 | zqs(i,l) = 0. |
---|
190 | ENDDO |
---|
191 | ENDDO |
---|
192 | ENDDO |
---|
193 | ! |
---|
194 | ! Reset variables |
---|
195 | DO i = 1, imjmp1 |
---|
196 | zqw_col(i)=0. |
---|
197 | zql_col(i)=0. |
---|
198 | zqs_col(i)=0. |
---|
199 | zec_col(i) = 0. |
---|
200 | zh_dair_col(i) = 0. |
---|
201 | zh_qw_col(i) = 0. |
---|
202 | zh_ql_col(i) = 0. |
---|
203 | zh_qs_col(i) = 0. |
---|
204 | ENDDO |
---|
205 | ! |
---|
206 | zcpvap=RCPV |
---|
207 | zcwat=RCW |
---|
208 | zcice=RCS |
---|
209 | ! |
---|
210 | ! Compute vertical sum for each atmospheric column |
---|
211 | ! ================================================ |
---|
212 | DO k = 1, llm |
---|
213 | DO i = 1, imjmp1 |
---|
214 | ! Watter mass |
---|
215 | zqw_col(i) = zqw_col(i) + zqw(i,k)*zairm(i,k) |
---|
216 | zql_col(i) = zql_col(i) + zql(i,k)*zairm(i,k) |
---|
217 | zqs_col(i) = zqs_col(i) + zqs(i,k)*zairm(i,k) |
---|
218 | ! Cinetic Energy |
---|
219 | zec_col(i) = zec_col(i) & |
---|
220 | +zecin(i,k)*zairm(i,k) |
---|
221 | ! Air enthalpy |
---|
222 | zt(i,k)= zh(i,k) * zpk(i,k) / RCPD |
---|
223 | zh_dair_col(i) = zh_dair_col(i) & |
---|
224 | + RCPD*(1.-zqw(i,k)-zql(i,k)-zqs(i,k))*zairm(i,k)*zt(i,k) |
---|
225 | zh_qw_col(i) = zh_qw_col(i) & |
---|
226 | + zcpvap*zqw(i,k)*zairm(i,k)*zt(i,k) |
---|
227 | zh_ql_col(i) = zh_ql_col(i) & |
---|
228 | + zcwat*zql(i,k)*zairm(i,k)*zt(i,k) & |
---|
229 | - RLVTT*zql(i,k)*zairm(i,k) |
---|
230 | zh_qs_col(i) = zh_qs_col(i) & |
---|
231 | + zcice*zqs(i,k)*zairm(i,k)*zt(i,k) & |
---|
232 | - RLSTT*zqs(i,k)*zairm(i,k) |
---|
233 | |
---|
234 | END DO |
---|
235 | ENDDO |
---|
236 | ! |
---|
237 | ! Mean over the planete surface |
---|
238 | ! ============================= |
---|
239 | qw_tot = 0. |
---|
240 | ql_tot = 0. |
---|
241 | qs_tot = 0. |
---|
242 | ec_tot = 0. |
---|
243 | h_vcol_tot = 0. |
---|
244 | h_dair_tot = 0. |
---|
245 | h_qw_tot = 0. |
---|
246 | h_ql_tot = 0. |
---|
247 | h_qs_tot = 0. |
---|
248 | airetot=0. |
---|
249 | ! |
---|
250 | do i=1,imjmp1 |
---|
251 | qw_tot = qw_tot + zqw_col(i) |
---|
252 | ql_tot = ql_tot + zql_col(i) |
---|
253 | qs_tot = qs_tot + zqs_col(i) |
---|
254 | ec_tot = ec_tot + zec_col(i) |
---|
255 | h_dair_tot = h_dair_tot + zh_dair_col(i) |
---|
256 | h_qw_tot = h_qw_tot + zh_qw_col(i) |
---|
257 | h_ql_tot = h_ql_tot + zh_ql_col(i) |
---|
258 | h_qs_tot = h_qs_tot + zh_qs_col(i) |
---|
259 | airetot=airetot+zaire(i) |
---|
260 | END DO |
---|
261 | ! |
---|
262 | qw_tot = qw_tot/airetot |
---|
263 | ql_tot = ql_tot/airetot |
---|
264 | qs_tot = qs_tot/airetot |
---|
265 | ec_tot = ec_tot/airetot |
---|
266 | h_dair_tot = h_dair_tot/airetot |
---|
267 | h_qw_tot = h_qw_tot/airetot |
---|
268 | h_ql_tot = h_ql_tot/airetot |
---|
269 | h_qs_tot = h_qs_tot/airetot |
---|
270 | ! |
---|
271 | h_vcol_tot = h_dair_tot+h_qw_tot+h_ql_tot+h_qs_tot |
---|
272 | ! |
---|
273 | ! Compute the change of the atmospheric state compare to the one |
---|
274 | ! stored in "idiag2", and convert it in flux. THis computation |
---|
275 | ! is performed IF idiag2 /= 0 and IF it is not the first CALL |
---|
276 | ! for "idiag" |
---|
277 | ! =================================== |
---|
278 | ! |
---|
279 | IF ( (idiag2.gt.0) .and. (pas(idiag2) .ne. 0) ) THEN |
---|
280 | d_h_vcol = (h_vcol_tot - h_vcol_pre(idiag2) )/dtime |
---|
281 | d_h_dair = (h_dair_tot- h_dair_pre(idiag2))/dtime |
---|
282 | d_h_qw = (h_qw_tot - h_qw_pre(idiag2) )/dtime |
---|
283 | d_h_ql = (h_ql_tot - h_ql_pre(idiag2) )/dtime |
---|
284 | d_h_qs = (h_qs_tot - h_qs_pre(idiag2) )/dtime |
---|
285 | d_qw = (qw_tot - qw_pre(idiag2) )/dtime |
---|
286 | d_ql = (ql_tot - ql_pre(idiag2) )/dtime |
---|
287 | d_qs = (qs_tot - qs_pre(idiag2) )/dtime |
---|
288 | d_ec = (ec_tot - ec_pre(idiag2) )/dtime |
---|
289 | d_qt = d_qw + d_ql + d_qs |
---|
290 | ELSE |
---|
291 | d_h_vcol = 0. |
---|
292 | d_h_dair = 0. |
---|
293 | d_h_qw = 0. |
---|
294 | d_h_ql = 0. |
---|
295 | d_h_qs = 0. |
---|
296 | d_qw = 0. |
---|
297 | d_ql = 0. |
---|
298 | d_qs = 0. |
---|
299 | d_ec = 0. |
---|
300 | d_qt = 0. |
---|
301 | ENDIF |
---|
302 | ! |
---|
303 | IF (iprt.ge.2) THEN |
---|
304 | WRITE(6,9000) tit,pas(idiag),d_qt,d_qw,d_ql,d_qs |
---|
305 | 9000 format('Dyn3d. Watter Mass Budget (kg/m2/s)',A15 & |
---|
306 | ,1i6,10(1pE14.6)) |
---|
307 | WRITE(6,9001) tit,pas(idiag), d_h_vcol |
---|
308 | 9001 format('Dyn3d. Enthalpy Budget (W/m2) ',A15,1i6,10(F8.2)) |
---|
309 | WRITE(6,9002) tit,pas(idiag), d_ec |
---|
310 | 9002 format('Dyn3d. Cinetic Energy Budget (W/m2) ',A15,1i6,10(F8.2)) |
---|
311 | ! WRITE(6,9003) tit,pas(idiag), ec_tot |
---|
312 | 9003 format('Dyn3d. Cinetic Energy (W/m2) ',A15,1i6,10(E15.6)) |
---|
313 | WRITE(6,9004) tit,pas(idiag), d_h_vcol+d_ec |
---|
314 | 9004 format('Dyn3d. Total Energy Budget (W/m2) ',A15,1i6,10(F8.2)) |
---|
315 | END IF |
---|
316 | ! |
---|
317 | ! Store the new atmospheric state in "idiag" |
---|
318 | ! |
---|
319 | pas(idiag)=pas(idiag)+1 |
---|
320 | h_vcol_pre(idiag) = h_vcol_tot |
---|
321 | h_dair_pre(idiag) = h_dair_tot |
---|
322 | h_qw_pre(idiag) = h_qw_tot |
---|
323 | h_ql_pre(idiag) = h_ql_tot |
---|
324 | h_qs_pre(idiag) = h_qs_tot |
---|
325 | qw_pre(idiag) = qw_tot |
---|
326 | ql_pre(idiag) = ql_tot |
---|
327 | qs_pre(idiag) = qs_tot |
---|
328 | ec_pre (idiag) = ec_tot |
---|
329 | ! |
---|
330 | !#else |
---|
331 | ELSE |
---|
332 | write(lunout,*)'diagedyn: set to function with Earth parameters' |
---|
333 | ENDIF ! of if (planet_type=="earth") |
---|
334 | !#endif |
---|
335 | ! #endif of #ifdef CPP_EARTH |
---|
336 | RETURN |
---|
337 | END SUBROUTINE diagedyn |
---|