1 | SUBROUTINE sum_up_3d_data |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: sum_up_3d_data.f90 98 2007-06-21 09:36:33Z weinreis $ |
---|
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 ( 'qv' ) |
---|
132 | IF ( .NOT. ALLOCATED( qv_av ) ) THEN |
---|
133 | ALLOCATE( qv_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
134 | ENDIF |
---|
135 | qv_av = 0.0 |
---|
136 | |
---|
137 | CASE ( 'rho' ) |
---|
138 | IF ( .NOT. ALLOCATED( rho_av ) ) THEN |
---|
139 | ALLOCATE( rho_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
140 | ENDIF |
---|
141 | rho_av = 0.0 |
---|
142 | |
---|
143 | CASE ( 's' ) |
---|
144 | IF ( .NOT. ALLOCATED( s_av ) ) THEN |
---|
145 | ALLOCATE( s_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
146 | ENDIF |
---|
147 | s_av = 0.0 |
---|
148 | |
---|
149 | CASE ( 'sa' ) |
---|
150 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
151 | ALLOCATE( sa_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
152 | ENDIF |
---|
153 | sa_av = 0.0 |
---|
154 | |
---|
155 | CASE ( 't*' ) |
---|
156 | IF ( .NOT. ALLOCATED( ts_av ) ) THEN |
---|
157 | ALLOCATE( ts_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
158 | ENDIF |
---|
159 | ts_av = 0.0 |
---|
160 | |
---|
161 | CASE ( 'u' ) |
---|
162 | IF ( .NOT. ALLOCATED( u_av ) ) THEN |
---|
163 | ALLOCATE( u_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
164 | ENDIF |
---|
165 | u_av = 0.0 |
---|
166 | |
---|
167 | CASE ( 'u*' ) |
---|
168 | IF ( .NOT. ALLOCATED( us_av ) ) THEN |
---|
169 | ALLOCATE( us_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
170 | ENDIF |
---|
171 | us_av = 0.0 |
---|
172 | |
---|
173 | CASE ( 'v' ) |
---|
174 | IF ( .NOT. ALLOCATED( v_av ) ) THEN |
---|
175 | ALLOCATE( v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
176 | ENDIF |
---|
177 | v_av = 0.0 |
---|
178 | |
---|
179 | CASE ( 'vpt' ) |
---|
180 | IF ( .NOT. ALLOCATED( vpt_av ) ) THEN |
---|
181 | ALLOCATE( vpt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
182 | ENDIF |
---|
183 | vpt_av = 0.0 |
---|
184 | |
---|
185 | CASE ( 'w' ) |
---|
186 | IF ( .NOT. ALLOCATED( w_av ) ) THEN |
---|
187 | ALLOCATE( w_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
188 | ENDIF |
---|
189 | w_av = 0.0 |
---|
190 | |
---|
191 | CASE ( 'z0*' ) |
---|
192 | IF ( .NOT. ALLOCATED( z0_av ) ) THEN |
---|
193 | ALLOCATE( z0_av(nys-1:nyn+1,nxl-1:nxr+1) ) |
---|
194 | ENDIF |
---|
195 | z0_av = 0.0 |
---|
196 | |
---|
197 | CASE DEFAULT |
---|
198 | ! |
---|
199 | !-- User-defined quantity |
---|
200 | CALL user_3d_data_averaging( 'allocate', doav(ii) ) |
---|
201 | |
---|
202 | END SELECT |
---|
203 | |
---|
204 | ENDDO |
---|
205 | |
---|
206 | ENDIF |
---|
207 | |
---|
208 | ! |
---|
209 | !-- Loop of all variables to be averaged. |
---|
210 | DO ii = 1, doav_n |
---|
211 | |
---|
212 | ! |
---|
213 | !-- Store the array chosen on the temporary array. |
---|
214 | SELECT CASE ( TRIM( doav(ii) ) ) |
---|
215 | |
---|
216 | CASE ( 'e' ) |
---|
217 | DO i = nxl-1, nxr+1 |
---|
218 | DO j = nys-1, nyn+1 |
---|
219 | DO k = nzb, nzt+1 |
---|
220 | e_av(k,j,i) = e_av(k,j,i) + e(k,j,i) |
---|
221 | ENDDO |
---|
222 | ENDDO |
---|
223 | ENDDO |
---|
224 | |
---|
225 | CASE ( 'lwp*' ) |
---|
226 | DO i = nxl-1, nxr+1 |
---|
227 | DO j = nys-1, nyn+1 |
---|
228 | lwp_av(j,i) = lwp_av(j,i) + SUM( ql(nzb:nzt,j,i) * & |
---|
229 | dzw(1:nzt+1) ) |
---|
230 | ENDDO |
---|
231 | ENDDO |
---|
232 | |
---|
233 | CASE ( 'p' ) |
---|
234 | DO i = nxl-1, nxr+1 |
---|
235 | DO j = nys-1, nyn+1 |
---|
236 | DO k = nzb, nzt+1 |
---|
237 | p_av(k,j,i) = p_av(k,j,i) + p(k,j,i) |
---|
238 | ENDDO |
---|
239 | ENDDO |
---|
240 | ENDDO |
---|
241 | |
---|
242 | CASE ( 'pc' ) |
---|
243 | DO i = nxl, nxr |
---|
244 | DO j = nys, nyn |
---|
245 | DO k = nzb, nzt+1 |
---|
246 | pc_av(k,j,i) = pc_av(k,j,i) + prt_count(k,j,i) |
---|
247 | ENDDO |
---|
248 | ENDDO |
---|
249 | ENDDO |
---|
250 | |
---|
251 | CASE ( 'pr' ) |
---|
252 | DO i = nxl, nxr |
---|
253 | DO j = nys, nyn |
---|
254 | DO k = nzb, nzt+1 |
---|
255 | psi = prt_start_index(k,j,i) |
---|
256 | s_r3 = 0.0 |
---|
257 | s_r4 = 0.0 |
---|
258 | DO n = psi, psi+prt_count(k,j,i)-1 |
---|
259 | s_r3 = s_r3 + particles(n)%radius**3 |
---|
260 | s_r4 = s_r4 + particles(n)%radius**4 |
---|
261 | ENDDO |
---|
262 | IF ( s_r3 /= 0.0 ) THEN |
---|
263 | mean_r = s_r4 / s_r3 |
---|
264 | ELSE |
---|
265 | mean_r = 0.0 |
---|
266 | ENDIF |
---|
267 | pr_av(k,j,i) = pr_av(k,j,i) + mean_r |
---|
268 | ENDDO |
---|
269 | ENDDO |
---|
270 | ENDDO |
---|
271 | |
---|
272 | CASE ( 'pr*' ) |
---|
273 | DO i = nxl-1, nxr+1 |
---|
274 | DO j = nys-1, nyn+1 |
---|
275 | precipitation_rate_av(j,i) = precipitation_rate_av(j,i) + & |
---|
276 | precipitation_rate(j,i) |
---|
277 | ENDDO |
---|
278 | ENDDO |
---|
279 | |
---|
280 | CASE ( 'pt' ) |
---|
281 | IF ( .NOT. cloud_physics ) THEN |
---|
282 | DO i = nxl-1, nxr+1 |
---|
283 | DO j = nys-1, nyn+1 |
---|
284 | DO k = nzb, nzt+1 |
---|
285 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) |
---|
286 | ENDDO |
---|
287 | ENDDO |
---|
288 | ENDDO |
---|
289 | ELSE |
---|
290 | DO i = nxl-1, nxr+1 |
---|
291 | DO j = nys-1, nyn+1 |
---|
292 | DO k = nzb, nzt+1 |
---|
293 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) + l_d_cp * & |
---|
294 | pt_d_t(k) * ql(k,j,i) |
---|
295 | ENDDO |
---|
296 | ENDDO |
---|
297 | ENDDO |
---|
298 | ENDIF |
---|
299 | |
---|
300 | CASE ( 'q' ) |
---|
301 | DO i = nxl-1, nxr+1 |
---|
302 | DO j = nys-1, nyn+1 |
---|
303 | DO k = nzb, nzt+1 |
---|
304 | q_av(k,j,i) = q_av(k,j,i) + q(k,j,i) |
---|
305 | ENDDO |
---|
306 | ENDDO |
---|
307 | ENDDO |
---|
308 | |
---|
309 | CASE ( 'ql' ) |
---|
310 | DO i = nxl-1, nxr+1 |
---|
311 | DO j = nys-1, nyn+1 |
---|
312 | DO k = nzb, nzt+1 |
---|
313 | ql_av(k,j,i) = ql_av(k,j,i) + ql(k,j,i) |
---|
314 | ENDDO |
---|
315 | ENDDO |
---|
316 | ENDDO |
---|
317 | |
---|
318 | CASE ( 'ql_c' ) |
---|
319 | DO i = nxl-1, nxr+1 |
---|
320 | DO j = nys-1, nyn+1 |
---|
321 | DO k = nzb, nzt+1 |
---|
322 | ql_c_av(k,j,i) = ql_c_av(k,j,i) + ql_c(k,j,i) |
---|
323 | ENDDO |
---|
324 | ENDDO |
---|
325 | ENDDO |
---|
326 | |
---|
327 | CASE ( 'ql_v' ) |
---|
328 | DO i = nxl-1, nxr+1 |
---|
329 | DO j = nys-1, nyn+1 |
---|
330 | DO k = nzb, nzt+1 |
---|
331 | ql_v_av(k,j,i) = ql_v_av(k,j,i) + ql_v(k,j,i) |
---|
332 | ENDDO |
---|
333 | ENDDO |
---|
334 | ENDDO |
---|
335 | |
---|
336 | CASE ( 'ql_vp' ) |
---|
337 | DO i = nxl-1, nxr+1 |
---|
338 | DO j = nys-1, nyn+1 |
---|
339 | DO k = nzb, nzt+1 |
---|
340 | ql_vp_av(k,j,i) = ql_vp_av(k,j,i) + ql_vp(k,j,i) |
---|
341 | ENDDO |
---|
342 | ENDDO |
---|
343 | ENDDO |
---|
344 | |
---|
345 | CASE ( 'qv' ) |
---|
346 | DO i = nxl-1, nxr+1 |
---|
347 | DO j = nys-1, nyn+1 |
---|
348 | DO k = nzb, nzt+1 |
---|
349 | qv_av(k,j,i) = qv_av(k,j,i) + q(k,j,i) - ql(k,j,i) |
---|
350 | ENDDO |
---|
351 | ENDDO |
---|
352 | ENDDO |
---|
353 | |
---|
354 | CASE ( 'rho' ) |
---|
355 | DO i = nxl-1, nxr+1 |
---|
356 | DO j = nys-1, nyn+1 |
---|
357 | DO k = nzb, nzt+1 |
---|
358 | rho_av(k,j,i) = rho_av(k,j,i) + rho(k,j,i) |
---|
359 | ENDDO |
---|
360 | ENDDO |
---|
361 | ENDDO |
---|
362 | |
---|
363 | CASE ( 's' ) |
---|
364 | DO i = nxl-1, nxr+1 |
---|
365 | DO j = nys-1, nyn+1 |
---|
366 | DO k = nzb, nzt+1 |
---|
367 | s_av(k,j,i) = s_av(k,j,i) + q(k,j,i) |
---|
368 | ENDDO |
---|
369 | ENDDO |
---|
370 | ENDDO |
---|
371 | |
---|
372 | CASE ( 'sa' ) |
---|
373 | DO i = nxl-1, nxr+1 |
---|
374 | DO j = nys-1, nyn+1 |
---|
375 | DO k = nzb, nzt+1 |
---|
376 | sa_av(k,j,i) = sa_av(k,j,i) + sa(k,j,i) |
---|
377 | ENDDO |
---|
378 | ENDDO |
---|
379 | ENDDO |
---|
380 | |
---|
381 | CASE ( 't*' ) |
---|
382 | DO i = nxl-1, nxr+1 |
---|
383 | DO j = nys-1, nyn+1 |
---|
384 | ts_av(j,i) = ts_av(j,i) + ts(j,i) |
---|
385 | ENDDO |
---|
386 | ENDDO |
---|
387 | |
---|
388 | CASE ( 'u' ) |
---|
389 | DO i = nxl-1, nxr+1 |
---|
390 | DO j = nys-1, nyn+1 |
---|
391 | DO k = nzb, nzt+1 |
---|
392 | u_av(k,j,i) = u_av(k,j,i) + u(k,j,i) |
---|
393 | ENDDO |
---|
394 | ENDDO |
---|
395 | ENDDO |
---|
396 | |
---|
397 | CASE ( 'u*' ) |
---|
398 | DO i = nxl-1, nxr+1 |
---|
399 | DO j = nys-1, nyn+1 |
---|
400 | us_av(j,i) = us_av(j,i) + us(j,i) |
---|
401 | ENDDO |
---|
402 | ENDDO |
---|
403 | |
---|
404 | CASE ( 'v' ) |
---|
405 | DO i = nxl-1, nxr+1 |
---|
406 | DO j = nys-1, nyn+1 |
---|
407 | DO k = nzb, nzt+1 |
---|
408 | v_av(k,j,i) = v_av(k,j,i) + v(k,j,i) |
---|
409 | ENDDO |
---|
410 | ENDDO |
---|
411 | ENDDO |
---|
412 | |
---|
413 | CASE ( 'vpt' ) |
---|
414 | DO i = nxl-1, nxr+1 |
---|
415 | DO j = nys-1, nyn+1 |
---|
416 | DO k = nzb, nzt+1 |
---|
417 | vpt_av(k,j,i) = vpt_av(k,j,i) + vpt(k,j,i) |
---|
418 | ENDDO |
---|
419 | ENDDO |
---|
420 | ENDDO |
---|
421 | |
---|
422 | CASE ( 'w' ) |
---|
423 | DO i = nxl-1, nxr+1 |
---|
424 | DO j = nys-1, nyn+1 |
---|
425 | DO k = nzb, nzt+1 |
---|
426 | w_av(k,j,i) = w_av(k,j,i) + w(k,j,i) |
---|
427 | ENDDO |
---|
428 | ENDDO |
---|
429 | ENDDO |
---|
430 | |
---|
431 | CASE ( 'z0*' ) |
---|
432 | DO i = nxl-1, nxr+1 |
---|
433 | DO j = nys-1, nyn+1 |
---|
434 | z0_av(j,i) = z0_av(j,i) + z0(j,i) |
---|
435 | ENDDO |
---|
436 | ENDDO |
---|
437 | |
---|
438 | CASE DEFAULT |
---|
439 | ! |
---|
440 | !-- User-defined quantity |
---|
441 | CALL user_3d_data_averaging( 'sum', doav(ii) ) |
---|
442 | |
---|
443 | END SELECT |
---|
444 | |
---|
445 | ENDDO |
---|
446 | |
---|
447 | CALL cpu_log (log_point(34),'sum_up_3d_data','stop','nobarrier') |
---|
448 | |
---|
449 | |
---|
450 | END SUBROUTINE sum_up_3d_data |
---|