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