1 | SUBROUTINE sum_up_3d_data |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! +shf*, qsws* |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: sum_up_3d_data.f90 367 2009-08-25 08:35:52Z raasch $ |
---|
11 | ! |
---|
12 | ! 96 2007-06-04 08:07:41Z raasch |
---|
13 | ! +sum-up of density and salinity |
---|
14 | ! |
---|
15 | ! 72 2007-03-19 08:20:46Z raasch |
---|
16 | ! +sum-up of precipitation rate and roughness length (prr*, z0*) |
---|
17 | ! |
---|
18 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
19 | ! |
---|
20 | ! Revision 1.1 2006/02/23 12:55:23 raasch |
---|
21 | ! Initial revision |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Description: |
---|
25 | ! ------------ |
---|
26 | ! Sum-up the values of 3d-arrays. The real averaging is later done in routine |
---|
27 | ! average_3d_data. |
---|
28 | !------------------------------------------------------------------------------! |
---|
29 | |
---|
30 | USE arrays_3d |
---|
31 | USE averaging |
---|
32 | USE cloud_parameters |
---|
33 | USE control_parameters |
---|
34 | USE cpulog |
---|
35 | USE indices |
---|
36 | USE interfaces |
---|
37 | USE particle_attributes |
---|
38 | |
---|
39 | IMPLICIT NONE |
---|
40 | |
---|
41 | INTEGER :: i, ii, j, k, n, psi |
---|
42 | |
---|
43 | REAL :: mean_r, s_r3, s_r4 |
---|
44 | |
---|
45 | |
---|
46 | CALL cpu_log (log_point(34),'sum_up_3d_data','start') |
---|
47 | |
---|
48 | ! |
---|
49 | !-- Allocate and initialize the summation arrays if called for the very first |
---|
50 | !-- time or the first time after average_3d_data has been called |
---|
51 | !-- (some or all of the arrays may have been already allocated |
---|
52 | !-- in read_3d_binary) |
---|
53 | IF ( average_count_3d == 0 ) THEN |
---|
54 | |
---|
55 | DO ii = 1, doav_n |
---|
56 | |
---|
57 | SELECT CASE ( TRIM( doav(ii) ) ) |
---|
58 | |
---|
59 | CASE ( 'e' ) |
---|
60 | IF ( .NOT. ALLOCATED( e_av ) ) THEN |
---|
61 | ALLOCATE( e_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
62 | ENDIF |
---|
63 | e_av = 0.0 |
---|
64 | |
---|
65 | CASE ( 'lwp*' ) |
---|
66 | IF ( .NOT. ALLOCATED( lwp_av ) ) THEN |
---|
67 | ALLOCATE( lwp_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
68 | ENDIF |
---|
69 | lwp_av = 0.0 |
---|
70 | |
---|
71 | CASE ( 'p' ) |
---|
72 | IF ( .NOT. ALLOCATED( p_av ) ) THEN |
---|
73 | ALLOCATE( p_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
74 | ENDIF |
---|
75 | p_av = 0.0 |
---|
76 | |
---|
77 | CASE ( 'pc' ) |
---|
78 | IF ( .NOT. ALLOCATED( pc_av ) ) THEN |
---|
79 | ALLOCATE( pc_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
80 | ENDIF |
---|
81 | pc_av = 0.0 |
---|
82 | |
---|
83 | CASE ( 'pr' ) |
---|
84 | IF ( .NOT. ALLOCATED( pr_av ) ) THEN |
---|
85 | ALLOCATE( pr_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
86 | ENDIF |
---|
87 | pr_av = 0.0 |
---|
88 | |
---|
89 | CASE ( 'prr*' ) |
---|
90 | IF ( .NOT. ALLOCATED( precipitation_rate_av ) ) THEN |
---|
91 | ALLOCATE( precipitation_rate_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
92 | ENDIF |
---|
93 | precipitation_rate_av = 0.0 |
---|
94 | |
---|
95 | CASE ( 'pt' ) |
---|
96 | IF ( .NOT. ALLOCATED( pt_av ) ) THEN |
---|
97 | ALLOCATE( pt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
98 | ENDIF |
---|
99 | pt_av = 0.0 |
---|
100 | |
---|
101 | CASE ( 'q' ) |
---|
102 | IF ( .NOT. ALLOCATED( q_av ) ) THEN |
---|
103 | ALLOCATE( q_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
104 | ENDIF |
---|
105 | q_av = 0.0 |
---|
106 | |
---|
107 | CASE ( 'ql' ) |
---|
108 | IF ( .NOT. ALLOCATED( ql_av ) ) THEN |
---|
109 | ALLOCATE( ql_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
110 | ENDIF |
---|
111 | ql_av = 0.0 |
---|
112 | |
---|
113 | CASE ( 'ql_c' ) |
---|
114 | IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN |
---|
115 | ALLOCATE( ql_c_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
116 | ENDIF |
---|
117 | ql_c_av = 0.0 |
---|
118 | |
---|
119 | CASE ( 'ql_v' ) |
---|
120 | IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN |
---|
121 | ALLOCATE( ql_v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
122 | ENDIF |
---|
123 | ql_v_av = 0.0 |
---|
124 | |
---|
125 | CASE ( 'ql_vp' ) |
---|
126 | IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN |
---|
127 | ALLOCATE( ql_vp_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
128 | ENDIF |
---|
129 | ql_vp_av = 0.0 |
---|
130 | |
---|
131 | CASE ( 'qsws*' ) |
---|
132 | IF ( .NOT. ALLOCATED( qsws_av ) ) THEN |
---|
133 | ALLOCATE( qsws_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
134 | ENDIF |
---|
135 | qsws_av = 0.0 |
---|
136 | |
---|
137 | CASE ( 'qv' ) |
---|
138 | IF ( .NOT. ALLOCATED( qv_av ) ) THEN |
---|
139 | ALLOCATE( qv_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
140 | ENDIF |
---|
141 | qv_av = 0.0 |
---|
142 | |
---|
143 | CASE ( 'rho' ) |
---|
144 | IF ( .NOT. ALLOCATED( rho_av ) ) THEN |
---|
145 | ALLOCATE( rho_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
146 | ENDIF |
---|
147 | rho_av = 0.0 |
---|
148 | |
---|
149 | CASE ( 's' ) |
---|
150 | IF ( .NOT. ALLOCATED( s_av ) ) THEN |
---|
151 | ALLOCATE( s_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
152 | ENDIF |
---|
153 | s_av = 0.0 |
---|
154 | |
---|
155 | CASE ( 'sa' ) |
---|
156 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
157 | ALLOCATE( sa_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
158 | ENDIF |
---|
159 | sa_av = 0.0 |
---|
160 | |
---|
161 | CASE ( 'shf*' ) |
---|
162 | IF ( .NOT. ALLOCATED( shf_av ) ) THEN |
---|
163 | ALLOCATE( shf_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
164 | ENDIF |
---|
165 | shf_av = 0.0 |
---|
166 | |
---|
167 | CASE ( 't*' ) |
---|
168 | IF ( .NOT. ALLOCATED( ts_av ) ) THEN |
---|
169 | ALLOCATE( ts_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
170 | ENDIF |
---|
171 | ts_av = 0.0 |
---|
172 | |
---|
173 | CASE ( 'u' ) |
---|
174 | IF ( .NOT. ALLOCATED( u_av ) ) THEN |
---|
175 | ALLOCATE( u_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
176 | ENDIF |
---|
177 | u_av = 0.0 |
---|
178 | |
---|
179 | CASE ( 'u*' ) |
---|
180 | IF ( .NOT. ALLOCATED( us_av ) ) THEN |
---|
181 | ALLOCATE( us_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
182 | ENDIF |
---|
183 | us_av = 0.0 |
---|
184 | |
---|
185 | CASE ( 'v' ) |
---|
186 | IF ( .NOT. ALLOCATED( v_av ) ) THEN |
---|
187 | ALLOCATE( v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
188 | ENDIF |
---|
189 | v_av = 0.0 |
---|
190 | |
---|
191 | CASE ( 'vpt' ) |
---|
192 | IF ( .NOT. ALLOCATED( vpt_av ) ) THEN |
---|
193 | ALLOCATE( vpt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
194 | ENDIF |
---|
195 | vpt_av = 0.0 |
---|
196 | |
---|
197 | CASE ( 'w' ) |
---|
198 | IF ( .NOT. ALLOCATED( w_av ) ) THEN |
---|
199 | ALLOCATE( w_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
200 | ENDIF |
---|
201 | w_av = 0.0 |
---|
202 | |
---|
203 | CASE ( 'z0*' ) |
---|
204 | IF ( .NOT. ALLOCATED( z0_av ) ) THEN |
---|
205 | ALLOCATE( z0_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
206 | ENDIF |
---|
207 | z0_av = 0.0 |
---|
208 | |
---|
209 | CASE DEFAULT |
---|
210 | ! |
---|
211 | !-- User-defined quantity |
---|
212 | CALL user_3d_data_averaging( 'allocate', doav(ii) ) |
---|
213 | |
---|
214 | END SELECT |
---|
215 | |
---|
216 | ENDDO |
---|
217 | |
---|
218 | ENDIF |
---|
219 | |
---|
220 | ! |
---|
221 | !-- Loop of all variables to be averaged. |
---|
222 | DO ii = 1, doav_n |
---|
223 | |
---|
224 | ! |
---|
225 | !-- Store the array chosen on the temporary array. |
---|
226 | SELECT CASE ( TRIM( doav(ii) ) ) |
---|
227 | |
---|
228 | CASE ( 'e' ) |
---|
229 | DO i = nxl-1, nxr+1 |
---|
230 | DO j = nys-1, nyn+1 |
---|
231 | DO k = nzb, nzt+1 |
---|
232 | e_av(k,j,i) = e_av(k,j,i) + e(k,j,i) |
---|
233 | ENDDO |
---|
234 | ENDDO |
---|
235 | ENDDO |
---|
236 | |
---|
237 | CASE ( 'lwp*' ) |
---|
238 | DO i = nxl-1, nxr+1 |
---|
239 | DO j = nys-1, nyn+1 |
---|
240 | lwp_av(j,i) = lwp_av(j,i) + SUM( ql(nzb:nzt,j,i) * & |
---|
241 | dzw(1:nzt+1) ) |
---|
242 | ENDDO |
---|
243 | ENDDO |
---|
244 | |
---|
245 | CASE ( 'p' ) |
---|
246 | DO i = nxl-1, nxr+1 |
---|
247 | DO j = nys-1, nyn+1 |
---|
248 | DO k = nzb, nzt+1 |
---|
249 | p_av(k,j,i) = p_av(k,j,i) + p(k,j,i) |
---|
250 | ENDDO |
---|
251 | ENDDO |
---|
252 | ENDDO |
---|
253 | |
---|
254 | CASE ( 'pc' ) |
---|
255 | DO i = nxl, nxr |
---|
256 | DO j = nys, nyn |
---|
257 | DO k = nzb, nzt+1 |
---|
258 | pc_av(k,j,i) = pc_av(k,j,i) + prt_count(k,j,i) |
---|
259 | ENDDO |
---|
260 | ENDDO |
---|
261 | ENDDO |
---|
262 | |
---|
263 | CASE ( 'pr' ) |
---|
264 | DO i = nxl, nxr |
---|
265 | DO j = nys, nyn |
---|
266 | DO k = nzb, nzt+1 |
---|
267 | psi = prt_start_index(k,j,i) |
---|
268 | s_r3 = 0.0 |
---|
269 | s_r4 = 0.0 |
---|
270 | DO n = psi, psi+prt_count(k,j,i)-1 |
---|
271 | s_r3 = s_r3 + particles(n)%radius**3 |
---|
272 | s_r4 = s_r4 + particles(n)%radius**4 |
---|
273 | ENDDO |
---|
274 | IF ( s_r3 /= 0.0 ) THEN |
---|
275 | mean_r = s_r4 / s_r3 |
---|
276 | ELSE |
---|
277 | mean_r = 0.0 |
---|
278 | ENDIF |
---|
279 | pr_av(k,j,i) = pr_av(k,j,i) + mean_r |
---|
280 | ENDDO |
---|
281 | ENDDO |
---|
282 | ENDDO |
---|
283 | |
---|
284 | CASE ( 'pr*' ) |
---|
285 | DO i = nxl-1, nxr+1 |
---|
286 | DO j = nys-1, nyn+1 |
---|
287 | precipitation_rate_av(j,i) = precipitation_rate_av(j,i) + & |
---|
288 | precipitation_rate(j,i) |
---|
289 | ENDDO |
---|
290 | ENDDO |
---|
291 | |
---|
292 | CASE ( 'pt' ) |
---|
293 | IF ( .NOT. cloud_physics ) THEN |
---|
294 | DO i = nxl-1, nxr+1 |
---|
295 | DO j = nys-1, nyn+1 |
---|
296 | DO k = nzb, nzt+1 |
---|
297 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) |
---|
298 | ENDDO |
---|
299 | ENDDO |
---|
300 | ENDDO |
---|
301 | ELSE |
---|
302 | DO i = nxl-1, nxr+1 |
---|
303 | DO j = nys-1, nyn+1 |
---|
304 | DO k = nzb, nzt+1 |
---|
305 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) + l_d_cp * & |
---|
306 | pt_d_t(k) * ql(k,j,i) |
---|
307 | ENDDO |
---|
308 | ENDDO |
---|
309 | ENDDO |
---|
310 | ENDIF |
---|
311 | |
---|
312 | CASE ( 'q' ) |
---|
313 | DO i = nxl-1, nxr+1 |
---|
314 | DO j = nys-1, nyn+1 |
---|
315 | DO k = nzb, nzt+1 |
---|
316 | q_av(k,j,i) = q_av(k,j,i) + q(k,j,i) |
---|
317 | ENDDO |
---|
318 | ENDDO |
---|
319 | ENDDO |
---|
320 | |
---|
321 | CASE ( 'ql' ) |
---|
322 | DO i = nxl-1, nxr+1 |
---|
323 | DO j = nys-1, nyn+1 |
---|
324 | DO k = nzb, nzt+1 |
---|
325 | ql_av(k,j,i) = ql_av(k,j,i) + ql(k,j,i) |
---|
326 | ENDDO |
---|
327 | ENDDO |
---|
328 | ENDDO |
---|
329 | |
---|
330 | CASE ( 'ql_c' ) |
---|
331 | DO i = nxl-1, nxr+1 |
---|
332 | DO j = nys-1, nyn+1 |
---|
333 | DO k = nzb, nzt+1 |
---|
334 | ql_c_av(k,j,i) = ql_c_av(k,j,i) + ql_c(k,j,i) |
---|
335 | ENDDO |
---|
336 | ENDDO |
---|
337 | ENDDO |
---|
338 | |
---|
339 | CASE ( 'ql_v' ) |
---|
340 | DO i = nxl-1, nxr+1 |
---|
341 | DO j = nys-1, nyn+1 |
---|
342 | DO k = nzb, nzt+1 |
---|
343 | ql_v_av(k,j,i) = ql_v_av(k,j,i) + ql_v(k,j,i) |
---|
344 | ENDDO |
---|
345 | ENDDO |
---|
346 | ENDDO |
---|
347 | |
---|
348 | CASE ( 'ql_vp' ) |
---|
349 | DO i = nxl-1, nxr+1 |
---|
350 | DO j = nys-1, nyn+1 |
---|
351 | DO k = nzb, nzt+1 |
---|
352 | ql_vp_av(k,j,i) = ql_vp_av(k,j,i) + ql_vp(k,j,i) |
---|
353 | ENDDO |
---|
354 | ENDDO |
---|
355 | ENDDO |
---|
356 | |
---|
357 | CASE ( 'qv' ) |
---|
358 | DO i = nxl-1, nxr+1 |
---|
359 | DO j = nys-1, nyn+1 |
---|
360 | DO k = nzb, nzt+1 |
---|
361 | qv_av(k,j,i) = qv_av(k,j,i) + q(k,j,i) - ql(k,j,i) |
---|
362 | ENDDO |
---|
363 | ENDDO |
---|
364 | ENDDO |
---|
365 | |
---|
366 | CASE ( 'rho' ) |
---|
367 | DO i = nxl-1, nxr+1 |
---|
368 | DO j = nys-1, nyn+1 |
---|
369 | DO k = nzb, nzt+1 |
---|
370 | rho_av(k,j,i) = rho_av(k,j,i) + rho(k,j,i) |
---|
371 | ENDDO |
---|
372 | ENDDO |
---|
373 | ENDDO |
---|
374 | |
---|
375 | CASE ( 's' ) |
---|
376 | DO i = nxl-1, nxr+1 |
---|
377 | DO j = nys-1, nyn+1 |
---|
378 | DO k = nzb, nzt+1 |
---|
379 | s_av(k,j,i) = s_av(k,j,i) + q(k,j,i) |
---|
380 | ENDDO |
---|
381 | ENDDO |
---|
382 | ENDDO |
---|
383 | |
---|
384 | CASE ( 'sa' ) |
---|
385 | DO i = nxl-1, nxr+1 |
---|
386 | DO j = nys-1, nyn+1 |
---|
387 | DO k = nzb, nzt+1 |
---|
388 | sa_av(k,j,i) = sa_av(k,j,i) + sa(k,j,i) |
---|
389 | ENDDO |
---|
390 | ENDDO |
---|
391 | ENDDO |
---|
392 | |
---|
393 | CASE ( 't*' ) |
---|
394 | DO i = nxl-1, nxr+1 |
---|
395 | DO j = nys-1, nyn+1 |
---|
396 | ts_av(j,i) = ts_av(j,i) + ts(j,i) |
---|
397 | ENDDO |
---|
398 | ENDDO |
---|
399 | |
---|
400 | CASE ( 'u' ) |
---|
401 | DO i = nxl-1, nxr+1 |
---|
402 | DO j = nys-1, nyn+1 |
---|
403 | DO k = nzb, nzt+1 |
---|
404 | u_av(k,j,i) = u_av(k,j,i) + u(k,j,i) |
---|
405 | ENDDO |
---|
406 | ENDDO |
---|
407 | ENDDO |
---|
408 | |
---|
409 | CASE ( 'u*' ) |
---|
410 | DO i = nxl-1, nxr+1 |
---|
411 | DO j = nys-1, nyn+1 |
---|
412 | us_av(j,i) = us_av(j,i) + us(j,i) |
---|
413 | ENDDO |
---|
414 | ENDDO |
---|
415 | |
---|
416 | CASE ( 'v' ) |
---|
417 | DO i = nxl-1, nxr+1 |
---|
418 | DO j = nys-1, nyn+1 |
---|
419 | DO k = nzb, nzt+1 |
---|
420 | v_av(k,j,i) = v_av(k,j,i) + v(k,j,i) |
---|
421 | ENDDO |
---|
422 | ENDDO |
---|
423 | ENDDO |
---|
424 | |
---|
425 | CASE ( 'vpt' ) |
---|
426 | DO i = nxl-1, nxr+1 |
---|
427 | DO j = nys-1, nyn+1 |
---|
428 | DO k = nzb, nzt+1 |
---|
429 | vpt_av(k,j,i) = vpt_av(k,j,i) + vpt(k,j,i) |
---|
430 | ENDDO |
---|
431 | ENDDO |
---|
432 | ENDDO |
---|
433 | |
---|
434 | CASE ( 'w' ) |
---|
435 | DO i = nxl-1, nxr+1 |
---|
436 | DO j = nys-1, nyn+1 |
---|
437 | DO k = nzb, nzt+1 |
---|
438 | w_av(k,j,i) = w_av(k,j,i) + w(k,j,i) |
---|
439 | ENDDO |
---|
440 | ENDDO |
---|
441 | ENDDO |
---|
442 | |
---|
443 | CASE ( 'z0*' ) |
---|
444 | DO i = nxl-1, nxr+1 |
---|
445 | DO j = nys-1, nyn+1 |
---|
446 | z0_av(j,i) = z0_av(j,i) + z0(j,i) |
---|
447 | ENDDO |
---|
448 | ENDDO |
---|
449 | |
---|
450 | CASE DEFAULT |
---|
451 | ! |
---|
452 | !-- User-defined quantity |
---|
453 | CALL user_3d_data_averaging( 'sum', doav(ii) ) |
---|
454 | |
---|
455 | END SELECT |
---|
456 | |
---|
457 | ENDDO |
---|
458 | |
---|
459 | CALL cpu_log (log_point(34),'sum_up_3d_data','stop','nobarrier') |
---|
460 | |
---|
461 | |
---|
462 | END SUBROUTINE sum_up_3d_data |
---|