1 | !> @file average_3d_data.f90 |
---|
2 | !------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
6 | ! terms of the GNU General Public License as published by the Free Software |
---|
7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
8 | ! version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ----------------- |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: average_3d_data.f90 2233 2017-05-30 18:08:54Z sward $ |
---|
27 | ! |
---|
28 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
29 | ! Adjustments to new surface concept - additional ghost point exchange |
---|
30 | ! of surface variable required |
---|
31 | ! |
---|
32 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
33 | ! renamed variable rho to rho_ocean and rho_av to rho_ocean_av |
---|
34 | ! |
---|
35 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
36 | ! Flag urban_surface is now defined in module control_parameters, |
---|
37 | ! changed prefix for urban surface model output to "usm_", |
---|
38 | ! introduced control parameter varnamelength for LEN of trimvar. |
---|
39 | ! |
---|
40 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
41 | ! Added support for new urban surface model (temporary modifications of |
---|
42 | ! SELECT CASE ( ) necessary, see variable trimvar), |
---|
43 | ! added comments in variable declaration section |
---|
44 | ! |
---|
45 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
46 | ! Forced header and separation lines into 80 columns |
---|
47 | ! |
---|
48 | ! 1972 2016-07-26 07:52:02Z maronga |
---|
49 | ! Output of land surface quantities is now done directly in the respective module |
---|
50 | ! |
---|
51 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
52 | ! Treat humidity and passive scalar separately |
---|
53 | ! |
---|
54 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
55 | ! Added output of Obukhov length and radiative heating rates for RRTMG. |
---|
56 | ! |
---|
57 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
58 | ! Code annotations made doxygen readable |
---|
59 | ! |
---|
60 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
61 | ! Adapted for RRTMG |
---|
62 | ! |
---|
63 | ! 1555 2015-03-04 17:44:27Z maronga |
---|
64 | ! Added output of r_a and r_s |
---|
65 | ! |
---|
66 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
67 | ! Added support for land surface and radiation model parameters. |
---|
68 | ! |
---|
69 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
70 | ! REAL functions provided with KIND-attribute |
---|
71 | ! |
---|
72 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
73 | ! ONLY-attribute added to USE-statements, |
---|
74 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
75 | ! kinds are defined in new module kinds, |
---|
76 | ! revision history before 2012 removed, |
---|
77 | ! comment fields (!:) to be used for variable explanations added to |
---|
78 | ! all variable declaration statements |
---|
79 | ! |
---|
80 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
81 | ! barrier argument removed from cpu_log, |
---|
82 | ! module interfaces removed |
---|
83 | ! |
---|
84 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
85 | ! +qc |
---|
86 | ! |
---|
87 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
88 | ! averaging of nr, qr added |
---|
89 | ! |
---|
90 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
91 | ! code put under GPL (PALM 3.9) |
---|
92 | ! |
---|
93 | ! 978 2012-08-09 08:28:32Z fricke |
---|
94 | ! +z0h_av |
---|
95 | ! |
---|
96 | ! Revision 1.1 2006/02/23 09:48:58 raasch |
---|
97 | ! Initial revision |
---|
98 | ! |
---|
99 | ! |
---|
100 | ! Description: |
---|
101 | ! ------------ |
---|
102 | !> Time-averaging of 3d-data-arrays. |
---|
103 | !------------------------------------------------------------------------------! |
---|
104 | SUBROUTINE average_3d_data |
---|
105 | |
---|
106 | |
---|
107 | USE averaging |
---|
108 | |
---|
109 | USE control_parameters, & |
---|
110 | ONLY: average_count_3d, doav, doav_n, land_surface, urban_surface, & |
---|
111 | varnamelength |
---|
112 | |
---|
113 | USE cpulog, & |
---|
114 | ONLY: cpu_log, log_point |
---|
115 | |
---|
116 | USE indices, & |
---|
117 | ONLY: nbgp, nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt |
---|
118 | |
---|
119 | USE kinds |
---|
120 | |
---|
121 | USE land_surface_model_mod, & |
---|
122 | ONLY: lsm_3d_data_averaging |
---|
123 | |
---|
124 | USE radiation_model_mod, & |
---|
125 | ONLY: radiation, radiation_3d_data_averaging |
---|
126 | |
---|
127 | USE urban_surface_mod, & |
---|
128 | ONLY: usm_average_3d_data |
---|
129 | |
---|
130 | |
---|
131 | IMPLICIT NONE |
---|
132 | |
---|
133 | INTEGER(iwp) :: i !< running index |
---|
134 | INTEGER(iwp) :: ii !< running index |
---|
135 | INTEGER(iwp) :: j !< running index |
---|
136 | INTEGER(iwp) :: k !< running index |
---|
137 | |
---|
138 | CHARACTER (LEN=varnamelength) :: trimvar !< TRIM of output-variable string |
---|
139 | |
---|
140 | |
---|
141 | CALL cpu_log (log_point(35),'average_3d_data','start') |
---|
142 | |
---|
143 | ! |
---|
144 | !-- Check, if averaging is necessary |
---|
145 | IF ( average_count_3d <= 1 ) RETURN |
---|
146 | |
---|
147 | ! |
---|
148 | !-- Loop of all variables to be averaged. |
---|
149 | DO ii = 1, doav_n |
---|
150 | |
---|
151 | ! |
---|
152 | !-- Temporary solution to account for data output within the new urban |
---|
153 | !-- surface model (urban_surface_mod.f90), see also SELECT CASE ( trimvar ) |
---|
154 | trimvar = TRIM( doav(ii) ) |
---|
155 | IF ( urban_surface .AND. trimvar(1:4) == 'usm_' ) THEN |
---|
156 | trimvar = 'usm_output' |
---|
157 | ENDIF |
---|
158 | |
---|
159 | ! |
---|
160 | !-- Store the array chosen on the temporary array. |
---|
161 | SELECT CASE ( trimvar ) |
---|
162 | |
---|
163 | CASE ( 'e' ) |
---|
164 | DO i = nxlg, nxrg |
---|
165 | DO j = nysg, nyng |
---|
166 | DO k = nzb, nzt+1 |
---|
167 | e_av(k,j,i) = e_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
168 | ENDDO |
---|
169 | ENDDO |
---|
170 | ENDDO |
---|
171 | |
---|
172 | CASE ( 'qsws*' ) |
---|
173 | DO i = nxlg, nxrg |
---|
174 | DO j = nysg, nyng |
---|
175 | qsws_av(j,i) = qsws_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
176 | ENDDO |
---|
177 | ENDDO |
---|
178 | CALL exchange_horiz_2d( qsws_av, nbgp ) |
---|
179 | |
---|
180 | CASE ( 'lpt' ) |
---|
181 | DO i = nxlg, nxrg |
---|
182 | DO j = nysg, nyng |
---|
183 | DO k = nzb, nzt+1 |
---|
184 | lpt_av(k,j,i) = lpt_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
185 | ENDDO |
---|
186 | ENDDO |
---|
187 | ENDDO |
---|
188 | |
---|
189 | CASE ( 'lwp*' ) |
---|
190 | DO i = nxlg, nxrg |
---|
191 | DO j = nysg, nyng |
---|
192 | lwp_av(j,i) = lwp_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
193 | ENDDO |
---|
194 | ENDDO |
---|
195 | |
---|
196 | CASE ( 'nr' ) |
---|
197 | DO i = nxlg, nxrg |
---|
198 | DO j = nysg, nyng |
---|
199 | DO k = nzb, nzt+1 |
---|
200 | nr_av(k,j,i) = nr_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
201 | ENDDO |
---|
202 | ENDDO |
---|
203 | ENDDO |
---|
204 | |
---|
205 | CASE ( 'ol*' ) |
---|
206 | DO i = nxlg, nxrg |
---|
207 | DO j = nysg, nyng |
---|
208 | ol_av(j,i) = ol_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
209 | ENDDO |
---|
210 | ENDDO |
---|
211 | CALL exchange_horiz_2d( ol_av, nbgp ) |
---|
212 | |
---|
213 | CASE ( 'p' ) |
---|
214 | DO i = nxlg, nxrg |
---|
215 | DO j = nysg, nyng |
---|
216 | DO k = nzb, nzt+1 |
---|
217 | p_av(k,j,i) = p_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
218 | ENDDO |
---|
219 | ENDDO |
---|
220 | ENDDO |
---|
221 | |
---|
222 | CASE ( 'pc' ) |
---|
223 | DO i = nxl, nxr |
---|
224 | DO j = nys, nyn |
---|
225 | DO k = nzb, nzt+1 |
---|
226 | pc_av(k,j,i) = pc_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
227 | ENDDO |
---|
228 | ENDDO |
---|
229 | ENDDO |
---|
230 | |
---|
231 | CASE ( 'pr' ) |
---|
232 | DO i = nxl, nxr |
---|
233 | DO j = nys, nyn |
---|
234 | DO k = nzb, nzt+1 |
---|
235 | pr_av(k,j,i) = pr_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
236 | ENDDO |
---|
237 | ENDDO |
---|
238 | ENDDO |
---|
239 | |
---|
240 | CASE ( 'prr*' ) |
---|
241 | DO i = nxlg, nxrg |
---|
242 | DO j = nysg, nyng |
---|
243 | precipitation_rate_av(j,i) = precipitation_rate_av(j,i) / & |
---|
244 | REAL( average_count_3d, KIND=wp ) |
---|
245 | ENDDO |
---|
246 | ENDDO |
---|
247 | |
---|
248 | CASE ( 'pt' ) |
---|
249 | DO i = nxlg, nxrg |
---|
250 | DO j = nysg, nyng |
---|
251 | DO k = nzb, nzt+1 |
---|
252 | pt_av(k,j,i) = pt_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
253 | ENDDO |
---|
254 | ENDDO |
---|
255 | ENDDO |
---|
256 | |
---|
257 | CASE ( 'q' ) |
---|
258 | DO i = nxlg, nxrg |
---|
259 | DO j = nysg, nyng |
---|
260 | DO k = nzb, nzt+1 |
---|
261 | q_av(k,j,i) = q_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
262 | ENDDO |
---|
263 | ENDDO |
---|
264 | ENDDO |
---|
265 | |
---|
266 | CASE ( 'qc' ) |
---|
267 | DO i = nxlg, nxrg |
---|
268 | DO j = nysg, nyng |
---|
269 | DO k = nzb, nzt+1 |
---|
270 | qc_av(k,j,i) = qc_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
271 | ENDDO |
---|
272 | ENDDO |
---|
273 | ENDDO |
---|
274 | |
---|
275 | CASE ( 'ql' ) |
---|
276 | DO i = nxlg, nxrg |
---|
277 | DO j = nysg, nyng |
---|
278 | DO k = nzb, nzt+1 |
---|
279 | ql_av(k,j,i) = ql_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
280 | ENDDO |
---|
281 | ENDDO |
---|
282 | ENDDO |
---|
283 | |
---|
284 | CASE ( 'ql_c' ) |
---|
285 | DO i = nxlg, nxrg |
---|
286 | DO j = nysg, nyng |
---|
287 | DO k = nzb, nzt+1 |
---|
288 | ql_c_av(k,j,i) = ql_c_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
289 | ENDDO |
---|
290 | ENDDO |
---|
291 | ENDDO |
---|
292 | |
---|
293 | CASE ( 'ql_v' ) |
---|
294 | DO i = nxlg, nxrg |
---|
295 | DO j = nysg, nyng |
---|
296 | DO k = nzb, nzt+1 |
---|
297 | ql_v_av(k,j,i) = ql_v_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
298 | ENDDO |
---|
299 | ENDDO |
---|
300 | ENDDO |
---|
301 | |
---|
302 | CASE ( 'ql_vp' ) |
---|
303 | DO i = nxlg, nxrg |
---|
304 | DO j = nysg, nyng |
---|
305 | DO k = nzb, nzt+1 |
---|
306 | ql_vp_av(k,j,i) = ql_vp_av(k,j,i) / & |
---|
307 | REAL( average_count_3d, KIND=wp ) |
---|
308 | ENDDO |
---|
309 | ENDDO |
---|
310 | ENDDO |
---|
311 | |
---|
312 | CASE ( 'qr' ) |
---|
313 | DO i = nxlg, nxrg |
---|
314 | DO j = nysg, nyng |
---|
315 | DO k = nzb, nzt+1 |
---|
316 | qr_av(k,j,i) = qr_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
317 | ENDDO |
---|
318 | ENDDO |
---|
319 | ENDDO |
---|
320 | |
---|
321 | CASE ( 'qv' ) |
---|
322 | DO i = nxlg, nxrg |
---|
323 | DO j = nysg, nyng |
---|
324 | DO k = nzb, nzt+1 |
---|
325 | qv_av(k,j,i) = qv_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
326 | ENDDO |
---|
327 | ENDDO |
---|
328 | ENDDO |
---|
329 | |
---|
330 | CASE ( 'rho_ocean' ) |
---|
331 | DO i = nxlg, nxrg |
---|
332 | DO j = nysg, nyng |
---|
333 | DO k = nzb, nzt+1 |
---|
334 | rho_ocean_av(k,j,i) = rho_ocean_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
335 | ENDDO |
---|
336 | ENDDO |
---|
337 | ENDDO |
---|
338 | |
---|
339 | CASE ( 's' ) |
---|
340 | DO i = nxlg, nxrg |
---|
341 | DO j = nysg, nyng |
---|
342 | DO k = nzb, nzt+1 |
---|
343 | s_av(k,j,i) = s_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
344 | ENDDO |
---|
345 | ENDDO |
---|
346 | ENDDO |
---|
347 | |
---|
348 | CASE ( 'sa' ) |
---|
349 | DO i = nxlg, nxrg |
---|
350 | DO j = nysg, nyng |
---|
351 | DO k = nzb, nzt+1 |
---|
352 | sa_av(k,j,i) = sa_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
353 | ENDDO |
---|
354 | ENDDO |
---|
355 | ENDDO |
---|
356 | |
---|
357 | CASE ( 'shf*' ) |
---|
358 | DO i = nxlg, nxrg |
---|
359 | DO j = nysg, nyng |
---|
360 | shf_av(j,i) = shf_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
361 | ENDDO |
---|
362 | ENDDO |
---|
363 | CALL exchange_horiz_2d( shf_av, nbgp ) |
---|
364 | |
---|
365 | CASE ( 'ssws*' ) |
---|
366 | DO i = nxlg, nxrg |
---|
367 | DO j = nysg, nyng |
---|
368 | ssws_av(j,i) = ssws_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
369 | ENDDO |
---|
370 | ENDDO |
---|
371 | CALL exchange_horiz_2d( ssws_av, nbgp ) |
---|
372 | |
---|
373 | CASE ( 't*' ) |
---|
374 | DO i = nxlg, nxrg |
---|
375 | DO j = nysg, nyng |
---|
376 | ts_av(j,i) = ts_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
377 | ENDDO |
---|
378 | ENDDO |
---|
379 | CALL exchange_horiz_2d( ts_av, nbgp ) |
---|
380 | |
---|
381 | CASE ( 'u' ) |
---|
382 | DO i = nxlg, nxrg |
---|
383 | DO j = nysg, nyng |
---|
384 | DO k = nzb, nzt+1 |
---|
385 | u_av(k,j,i) = u_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
386 | ENDDO |
---|
387 | ENDDO |
---|
388 | ENDDO |
---|
389 | |
---|
390 | CASE ( 'u*' ) |
---|
391 | DO i = nxlg, nxrg |
---|
392 | DO j = nysg, nyng |
---|
393 | us_av(j,i) = us_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
394 | ENDDO |
---|
395 | ENDDO |
---|
396 | CALL exchange_horiz_2d( us_av, nbgp ) |
---|
397 | |
---|
398 | CASE ( 'v' ) |
---|
399 | DO i = nxlg, nxrg |
---|
400 | DO j = nysg, nyng |
---|
401 | DO k = nzb, nzt+1 |
---|
402 | v_av(k,j,i) = v_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
403 | ENDDO |
---|
404 | ENDDO |
---|
405 | ENDDO |
---|
406 | |
---|
407 | CASE ( 'vpt' ) |
---|
408 | DO i = nxlg, nxrg |
---|
409 | DO j = nysg, nyng |
---|
410 | DO k = nzb, nzt+1 |
---|
411 | vpt_av(k,j,i) = vpt_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
412 | ENDDO |
---|
413 | ENDDO |
---|
414 | ENDDO |
---|
415 | |
---|
416 | CASE ( 'w' ) |
---|
417 | DO i = nxlg, nxrg |
---|
418 | DO j = nysg, nyng |
---|
419 | DO k = nzb, nzt+1 |
---|
420 | w_av(k,j,i) = w_av(k,j,i) / REAL( average_count_3d, KIND=wp ) |
---|
421 | ENDDO |
---|
422 | ENDDO |
---|
423 | ENDDO |
---|
424 | |
---|
425 | CASE ( 'z0*' ) |
---|
426 | DO i = nxlg, nxrg |
---|
427 | DO j = nysg, nyng |
---|
428 | z0_av(j,i) = z0_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
429 | ENDDO |
---|
430 | ENDDO |
---|
431 | CALL exchange_horiz_2d( z0_av, nbgp ) |
---|
432 | |
---|
433 | CASE ( 'z0h*' ) |
---|
434 | DO i = nxlg, nxrg |
---|
435 | DO j = nysg, nyng |
---|
436 | z0h_av(j,i) = z0h_av(j,i) / REAL( average_count_3d, KIND=wp ) |
---|
437 | ENDDO |
---|
438 | ENDDO |
---|
439 | CALL exchange_horiz_2d( z0h_av, nbgp ) |
---|
440 | ! |
---|
441 | !-- Block of urban surface model outputs |
---|
442 | CASE ( 'usm_output' ) |
---|
443 | CALL usm_average_3d_data( 'average', doav(ii) ) |
---|
444 | |
---|
445 | CASE DEFAULT |
---|
446 | ! |
---|
447 | !-- Land surface quantity |
---|
448 | IF ( land_surface ) THEN |
---|
449 | CALL lsm_3d_data_averaging( 'average', doav(ii) ) |
---|
450 | ENDIF |
---|
451 | |
---|
452 | ! |
---|
453 | !-- Radiation quantity |
---|
454 | IF ( radiation ) THEN |
---|
455 | CALL radiation_3d_data_averaging( 'average', doav(ii) ) |
---|
456 | ENDIF |
---|
457 | |
---|
458 | ! |
---|
459 | !-- User-defined quantity |
---|
460 | CALL user_3d_data_averaging( 'average', doav(ii) ) |
---|
461 | |
---|
462 | END SELECT |
---|
463 | |
---|
464 | ENDDO |
---|
465 | |
---|
466 | ! |
---|
467 | !-- Reset the counter |
---|
468 | average_count_3d = 0.0 |
---|
469 | |
---|
470 | CALL cpu_log( log_point(35), 'average_3d_data', 'stop' ) |
---|
471 | |
---|
472 | |
---|
473 | END SUBROUTINE average_3d_data |
---|