1 | !> @file average_3d_data.f90 |
---|
2 | !--------------------------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General |
---|
6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
7 | ! (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
11 | ! Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
14 | ! <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: average_3d_data.f90 4828 2021-01-05 11:21:41Z suehring $ |
---|
26 | ! bugfix: average_count_3d is set to integer 0 |
---|
27 | ! |
---|
28 | ! 4514 2020-04-30 16:29:59Z suehring |
---|
29 | ! Enable output of qsurf and ssurf |
---|
30 | ! |
---|
31 | ! 4509 2020-04-26 15:57:55Z raasch |
---|
32 | ! file re-formatted to follow the PALM coding standard |
---|
33 | ! |
---|
34 | ! 4457 2020-03-11 14:20:43Z raasch |
---|
35 | ! use statement for exchange horiz added, |
---|
36 | ! bugfix for call of exchange horiz 2d |
---|
37 | ! |
---|
38 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
39 | ! Move 2-m potential temperature output to diagnostic_output_quantities |
---|
40 | ! |
---|
41 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
42 | ! Corrected "Former revisions" section |
---|
43 | ! |
---|
44 | ! 4048 2019-06-21 21:00:21Z knoop |
---|
45 | ! Moved tcm_3d_data_averaging to module_interface |
---|
46 | ! |
---|
47 | ! 4039 2019-06-18 10:32:41Z suehring |
---|
48 | ! Modularize diagnostic output |
---|
49 | ! |
---|
50 | ! 3994 2019-05-22 18:08:09Z suehring |
---|
51 | ! output of turbulence intensity added |
---|
52 | ! |
---|
53 | ! 3933 2019-04-25 12:33:20Z kanani |
---|
54 | ! Bugfix in CASE theta_2m*, removal of redundant code |
---|
55 | ! |
---|
56 | ! 3773 2019-03-01 08:56:57Z maronga |
---|
57 | ! Added output of theta_2m*_xy_av |
---|
58 | ! |
---|
59 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
60 | ! Implementation of the PALM module interface |
---|
61 | ! |
---|
62 | ! Revision 1.1 2006/02/23 09:48:58 raasch |
---|
63 | ! Initial revision |
---|
64 | ! |
---|
65 | ! |
---|
66 | ! Description: |
---|
67 | ! ------------ |
---|
68 | !> Time-averaging of 3d-data-arrays. |
---|
69 | !--------------------------------------------------------------------------------------------------! |
---|
70 | SUBROUTINE average_3d_data |
---|
71 | |
---|
72 | |
---|
73 | USE averaging |
---|
74 | |
---|
75 | USE control_parameters, & |
---|
76 | ONLY: average_count_3d, doav, doav_n, varnamelength |
---|
77 | |
---|
78 | USE cpulog, & |
---|
79 | ONLY: cpu_log, log_point |
---|
80 | |
---|
81 | USE exchange_horiz_mod, & |
---|
82 | ONLY: exchange_horiz_2d |
---|
83 | |
---|
84 | USE indices, & |
---|
85 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt |
---|
86 | |
---|
87 | USE kinds |
---|
88 | |
---|
89 | USE module_interface, & |
---|
90 | ONLY: module_interface_3d_data_averaging |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | IMPLICIT NONE |
---|
96 | |
---|
97 | INTEGER(iwp) :: i !< loop index |
---|
98 | INTEGER(iwp) :: ii !< loop index |
---|
99 | INTEGER(iwp) :: j !< loop index |
---|
100 | INTEGER(iwp) :: k !< loop index |
---|
101 | |
---|
102 | CHARACTER (LEN=varnamelength) :: trimvar !< TRIM of output-variable string |
---|
103 | |
---|
104 | |
---|
105 | CALL cpu_log (log_point(35),'average_3d_data','start') |
---|
106 | |
---|
107 | ! |
---|
108 | !-- Check, if averaging is necessary |
---|
109 | IF ( average_count_3d <= 1 ) RETURN |
---|
110 | |
---|
111 | ! |
---|
112 | !-- Loop of all variables to be averaged. |
---|
113 | DO ii = 1, doav_n |
---|
114 | |
---|
115 | trimvar = TRIM( doav(ii) ) |
---|
116 | |
---|
117 | ! |
---|
118 | !-- Store the array chosen on the temporary array. |
---|
119 | SELECT CASE ( trimvar ) |
---|
120 | |
---|
121 | CASE ( 'e' ) |
---|
122 | IF ( ALLOCATED( e_av ) ) THEN |
---|
123 | DO i = nxlg, nxrg |
---|
124 | DO j = nysg, nyng |
---|
125 | DO k = nzb, nzt+1 |
---|
126 | e_av(k,j,i) = e_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
127 | ENDDO |
---|
128 | ENDDO |
---|
129 | ENDDO |
---|
130 | ENDIF |
---|
131 | |
---|
132 | CASE ( 'ghf*' ) |
---|
133 | IF ( ALLOCATED( ghf_av ) ) THEN |
---|
134 | DO i = nxl, nxr |
---|
135 | DO j = nys, nyn |
---|
136 | ghf_av(j,i) = ghf_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
137 | ENDDO |
---|
138 | ENDDO |
---|
139 | CALL exchange_horiz_2d( ghf_av ) |
---|
140 | ENDIF |
---|
141 | |
---|
142 | CASE ( 'qsws*' ) |
---|
143 | IF ( ALLOCATED( qsws_av ) ) THEN |
---|
144 | DO i = nxlg, nxrg |
---|
145 | DO j = nysg, nyng |
---|
146 | qsws_av(j,i) = qsws_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
147 | ENDDO |
---|
148 | ENDDO |
---|
149 | CALL exchange_horiz_2d( qsws_av ) |
---|
150 | ENDIF |
---|
151 | |
---|
152 | CASE ( 'thetal' ) |
---|
153 | IF ( ALLOCATED( lpt_av ) ) THEN |
---|
154 | DO i = nxlg, nxrg |
---|
155 | DO j = nysg, nyng |
---|
156 | DO k = nzb, nzt+1 |
---|
157 | lpt_av(k,j,i) = lpt_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
158 | ENDDO |
---|
159 | ENDDO |
---|
160 | ENDDO |
---|
161 | ENDIF |
---|
162 | |
---|
163 | CASE ( 'lwp*' ) |
---|
164 | IF ( ALLOCATED( lwp_av ) ) THEN |
---|
165 | DO i = nxlg, nxrg |
---|
166 | DO j = nysg, nyng |
---|
167 | lwp_av(j,i) = lwp_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
168 | ENDDO |
---|
169 | ENDDO |
---|
170 | ENDIF |
---|
171 | |
---|
172 | CASE ( 'ol*' ) |
---|
173 | IF ( ALLOCATED( ol_av ) ) THEN |
---|
174 | DO i = nxlg, nxrg |
---|
175 | DO j = nysg, nyng |
---|
176 | ol_av(j,i) = ol_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
177 | ENDDO |
---|
178 | ENDDO |
---|
179 | CALL exchange_horiz_2d( ol_av ) |
---|
180 | ENDIF |
---|
181 | |
---|
182 | CASE ( 'p' ) |
---|
183 | IF ( ALLOCATED( p_av ) ) THEN |
---|
184 | DO i = nxlg, nxrg |
---|
185 | DO j = nysg, nyng |
---|
186 | DO k = nzb, nzt+1 |
---|
187 | p_av(k,j,i) = p_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
188 | ENDDO |
---|
189 | ENDDO |
---|
190 | ENDDO |
---|
191 | ENDIF |
---|
192 | |
---|
193 | CASE ( 'pc' ) |
---|
194 | IF ( ALLOCATED( pc_av ) ) THEN |
---|
195 | DO i = nxl, nxr |
---|
196 | DO j = nys, nyn |
---|
197 | DO k = nzb, nzt+1 |
---|
198 | pc_av(k,j,i) = pc_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
199 | ENDDO |
---|
200 | ENDDO |
---|
201 | ENDDO |
---|
202 | ENDIF |
---|
203 | |
---|
204 | CASE ( 'pr' ) |
---|
205 | IF ( ALLOCATED( pr_av ) ) THEN |
---|
206 | DO i = nxl, nxr |
---|
207 | DO j = nys, nyn |
---|
208 | DO k = nzb, nzt+1 |
---|
209 | pr_av(k,j,i) = pr_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
210 | ENDDO |
---|
211 | ENDDO |
---|
212 | ENDDO |
---|
213 | ENDIF |
---|
214 | |
---|
215 | CASE ( 'theta' ) |
---|
216 | IF ( ALLOCATED( pt_av ) ) THEN |
---|
217 | DO i = nxlg, nxrg |
---|
218 | DO j = nysg, nyng |
---|
219 | DO k = nzb, nzt+1 |
---|
220 | pt_av(k,j,i) = pt_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
221 | ENDDO |
---|
222 | ENDDO |
---|
223 | ENDDO |
---|
224 | ENDIF |
---|
225 | |
---|
226 | CASE ( 'q' ) |
---|
227 | IF ( ALLOCATED( q_av ) ) THEN |
---|
228 | DO i = nxlg, nxrg |
---|
229 | DO j = nysg, nyng |
---|
230 | DO k = nzb, nzt+1 |
---|
231 | q_av(k,j,i) = q_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
232 | ENDDO |
---|
233 | ENDDO |
---|
234 | ENDDO |
---|
235 | ENDIF |
---|
236 | |
---|
237 | CASE ( 'ql' ) |
---|
238 | IF ( ALLOCATED( ql_av ) ) THEN |
---|
239 | DO i = nxlg, nxrg |
---|
240 | DO j = nysg, nyng |
---|
241 | DO k = nzb, nzt+1 |
---|
242 | ql_av(k,j,i) = ql_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
243 | ENDDO |
---|
244 | ENDDO |
---|
245 | ENDDO |
---|
246 | ENDIF |
---|
247 | |
---|
248 | CASE ( 'ql_c' ) |
---|
249 | IF ( ALLOCATED( ql_c_av ) ) THEN |
---|
250 | DO i = nxlg, nxrg |
---|
251 | DO j = nysg, nyng |
---|
252 | DO k = nzb, nzt+1 |
---|
253 | ql_c_av(k,j,i) = ql_c_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
254 | ENDDO |
---|
255 | ENDDO |
---|
256 | ENDDO |
---|
257 | ENDIF |
---|
258 | |
---|
259 | CASE ( 'ql_v' ) |
---|
260 | IF ( ALLOCATED( ql_v_av ) ) THEN |
---|
261 | DO i = nxlg, nxrg |
---|
262 | DO j = nysg, nyng |
---|
263 | DO k = nzb, nzt+1 |
---|
264 | ql_v_av(k,j,i) = ql_v_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
265 | ENDDO |
---|
266 | ENDDO |
---|
267 | ENDDO |
---|
268 | ENDIF |
---|
269 | |
---|
270 | CASE ( 'ql_vp' ) |
---|
271 | IF ( ALLOCATED( ql_vp_av ) ) THEN |
---|
272 | DO i = nxlg, nxrg |
---|
273 | DO j = nysg, nyng |
---|
274 | DO k = nzb, nzt+1 |
---|
275 | ql_vp_av(k,j,i) = ql_vp_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
276 | ENDDO |
---|
277 | ENDDO |
---|
278 | ENDDO |
---|
279 | ENDIF |
---|
280 | |
---|
281 | CASE ( 'qv' ) |
---|
282 | IF ( ALLOCATED( qv_av ) ) THEN |
---|
283 | DO i = nxlg, nxrg |
---|
284 | DO j = nysg, nyng |
---|
285 | DO k = nzb, nzt+1 |
---|
286 | qv_av(k,j,i) = qv_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
287 | ENDDO |
---|
288 | ENDDO |
---|
289 | ENDDO |
---|
290 | ENDIF |
---|
291 | |
---|
292 | CASE ( 'qsurf*' ) |
---|
293 | IF ( ALLOCATED( qsurf_av ) ) THEN |
---|
294 | DO i = nxlg, nxrg |
---|
295 | DO j = nysg, nyng |
---|
296 | qsurf_av(j,i) = qsurf_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
297 | ENDDO |
---|
298 | ENDDO |
---|
299 | CALL exchange_horiz_2d( qsurf_av ) |
---|
300 | ENDIF |
---|
301 | |
---|
302 | CASE ( 'r_a*' ) |
---|
303 | IF ( ALLOCATED( r_a_av ) ) THEN |
---|
304 | DO i = nxlg, nxrg |
---|
305 | DO j = nysg, nyng |
---|
306 | r_a_av(j,i) = r_a_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
307 | ENDDO |
---|
308 | ENDDO |
---|
309 | CALL exchange_horiz_2d( r_a_av ) |
---|
310 | ENDIF |
---|
311 | |
---|
312 | CASE ( 's' ) |
---|
313 | IF ( ALLOCATED( s_av ) ) THEN |
---|
314 | DO i = nxlg, nxrg |
---|
315 | DO j = nysg, nyng |
---|
316 | DO k = nzb, nzt+1 |
---|
317 | s_av(k,j,i) = s_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
318 | ENDDO |
---|
319 | ENDDO |
---|
320 | ENDDO |
---|
321 | ENDIF |
---|
322 | |
---|
323 | CASE ( 'shf*' ) |
---|
324 | IF ( ALLOCATED( shf_av ) ) THEN |
---|
325 | DO i = nxlg, nxrg |
---|
326 | DO j = nysg, nyng |
---|
327 | shf_av(j,i) = shf_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
328 | ENDDO |
---|
329 | ENDDO |
---|
330 | CALL exchange_horiz_2d( shf_av ) |
---|
331 | ENDIF |
---|
332 | |
---|
333 | CASE ( 'ssurf*' ) |
---|
334 | IF ( ALLOCATED( ssurf_av ) ) THEN |
---|
335 | DO i = nxlg, nxrg |
---|
336 | DO j = nysg, nyng |
---|
337 | ssurf_av(j,i) = ssurf_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
338 | ENDDO |
---|
339 | ENDDO |
---|
340 | CALL exchange_horiz_2d( ssurf_av ) |
---|
341 | ENDIF |
---|
342 | |
---|
343 | CASE ( 'ssws*' ) |
---|
344 | IF ( ALLOCATED( ssws_av ) ) THEN |
---|
345 | DO i = nxlg, nxrg |
---|
346 | DO j = nysg, nyng |
---|
347 | ssws_av(j,i) = ssws_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
348 | ENDDO |
---|
349 | ENDDO |
---|
350 | CALL exchange_horiz_2d( ssws_av ) |
---|
351 | ENDIF |
---|
352 | |
---|
353 | CASE ( 't*' ) |
---|
354 | IF ( ALLOCATED( ts_av ) ) THEN |
---|
355 | DO i = nxlg, nxrg |
---|
356 | DO j = nysg, nyng |
---|
357 | ts_av(j,i) = ts_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
358 | ENDDO |
---|
359 | ENDDO |
---|
360 | CALL exchange_horiz_2d( ts_av ) |
---|
361 | ENDIF |
---|
362 | |
---|
363 | CASE ( 'tsurf*' ) |
---|
364 | IF ( ALLOCATED( tsurf_av ) ) THEN |
---|
365 | DO i = nxlg, nxrg |
---|
366 | DO j = nysg, nyng |
---|
367 | tsurf_av(j,i) = tsurf_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
368 | ENDDO |
---|
369 | ENDDO |
---|
370 | CALL exchange_horiz_2d( tsurf_av ) |
---|
371 | ENDIF |
---|
372 | |
---|
373 | CASE ( 'u' ) |
---|
374 | IF ( ALLOCATED( u_av ) ) THEN |
---|
375 | DO i = nxlg, nxrg |
---|
376 | DO j = nysg, nyng |
---|
377 | DO k = nzb, nzt+1 |
---|
378 | u_av(k,j,i) = u_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
379 | ENDDO |
---|
380 | ENDDO |
---|
381 | ENDDO |
---|
382 | ENDIF |
---|
383 | |
---|
384 | CASE ( 'us*' ) |
---|
385 | IF ( ALLOCATED( us_av ) ) THEN |
---|
386 | DO i = nxlg, nxrg |
---|
387 | DO j = nysg, nyng |
---|
388 | us_av(j,i) = us_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
389 | ENDDO |
---|
390 | ENDDO |
---|
391 | CALL exchange_horiz_2d( us_av ) |
---|
392 | ENDIF |
---|
393 | |
---|
394 | CASE ( 'v' ) |
---|
395 | IF ( ALLOCATED( v_av ) ) THEN |
---|
396 | DO i = nxlg, nxrg |
---|
397 | DO j = nysg, nyng |
---|
398 | DO k = nzb, nzt+1 |
---|
399 | v_av(k,j,i) = v_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
400 | ENDDO |
---|
401 | ENDDO |
---|
402 | ENDDO |
---|
403 | ENDIF |
---|
404 | |
---|
405 | CASE ( 'thetav' ) |
---|
406 | IF ( ALLOCATED( vpt_av ) ) THEN |
---|
407 | DO i = nxlg, nxrg |
---|
408 | DO j = nysg, nyng |
---|
409 | DO k = nzb, nzt+1 |
---|
410 | vpt_av(k,j,i) = vpt_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
411 | ENDDO |
---|
412 | ENDDO |
---|
413 | ENDDO |
---|
414 | ENDIF |
---|
415 | |
---|
416 | CASE ( 'w' ) |
---|
417 | IF ( ALLOCATED( w_av ) ) THEN |
---|
418 | DO i = nxlg, nxrg |
---|
419 | DO j = nysg, nyng |
---|
420 | DO k = nzb, nzt+1 |
---|
421 | w_av(k,j,i) = w_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
422 | ENDDO |
---|
423 | ENDDO |
---|
424 | ENDDO |
---|
425 | ENDIF |
---|
426 | |
---|
427 | CASE ( 'z0*' ) |
---|
428 | IF ( ALLOCATED( z0_av ) ) THEN |
---|
429 | DO i = nxlg, nxrg |
---|
430 | DO j = nysg, nyng |
---|
431 | z0_av(j,i) = z0_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
432 | ENDDO |
---|
433 | ENDDO |
---|
434 | CALL exchange_horiz_2d( z0_av ) |
---|
435 | ENDIF |
---|
436 | |
---|
437 | CASE ( 'z0h*' ) |
---|
438 | IF ( ALLOCATED( z0h_av ) ) THEN |
---|
439 | DO i = nxlg, nxrg |
---|
440 | DO j = nysg, nyng |
---|
441 | z0h_av(j,i) = z0h_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
442 | ENDDO |
---|
443 | ENDDO |
---|
444 | CALL exchange_horiz_2d( z0h_av ) |
---|
445 | ENDIF |
---|
446 | |
---|
447 | CASE ( 'z0q*' ) |
---|
448 | IF ( ALLOCATED( z0q_av ) ) THEN |
---|
449 | DO i = nxlg, nxrg |
---|
450 | DO j = nysg, nyng |
---|
451 | z0q_av(j,i) = z0q_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
452 | ENDDO |
---|
453 | ENDDO |
---|
454 | CALL exchange_horiz_2d( z0q_av ) |
---|
455 | ENDIF |
---|
456 | |
---|
457 | CASE DEFAULT |
---|
458 | ! |
---|
459 | !-- Averaging of data from all other modules |
---|
460 | CALL module_interface_3d_data_averaging( 'average', trimvar ) |
---|
461 | |
---|
462 | END SELECT |
---|
463 | |
---|
464 | ENDDO |
---|
465 | |
---|
466 | ! |
---|
467 | !-- Reset the counter |
---|
468 | average_count_3d = 0_iwp |
---|
469 | |
---|
470 | CALL cpu_log( log_point(35), 'average_3d_data', 'stop' ) |
---|
471 | |
---|
472 | |
---|
473 | END SUBROUTINE average_3d_data |
---|