1 | !> @file sum_up_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 |
---|
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-2019 Leibniz Universitaet Hannover |
---|
18 | !------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: sum_up_3d_data.f90 3655 2019-01-07 16:51:22Z maronga $ |
---|
27 | ! Implementation of the PALM module interface |
---|
28 | ! |
---|
29 | ! 3597 2018-12-04 08:40:18Z maronga |
---|
30 | ! Added output of theta_2m |
---|
31 | ! |
---|
32 | ! 3589 2018-11-30 15:09:51Z suehring |
---|
33 | ! Move the control parameter "salsa" from salsa_mod to control_parameters |
---|
34 | ! (M. Kurppa) |
---|
35 | ! |
---|
36 | ! 3582 2018-11-29 19:16:36Z suehring |
---|
37 | ! dom_dwd_user, Schrempf: |
---|
38 | ! Remove CALLs to uv exposure model, this is now part of biometeorology_mod |
---|
39 | ! |
---|
40 | ! 3553 2018-11-22 10:30:48Z suehring |
---|
41 | ! variables documented |
---|
42 | ! |
---|
43 | ! 3552 2018-11-22 10:28:35Z suehring |
---|
44 | ! Changes related to clean-up of biometeorology (dom_dwd_user) |
---|
45 | ! |
---|
46 | ! 3467 2018-10-30 19:05:21Z suehring |
---|
47 | ! Implementation of a new aerosol module salsa. |
---|
48 | ! |
---|
49 | ! 3448 2018-10-29 18:14:31Z kanani |
---|
50 | ! Adjustment of biometeorology calls |
---|
51 | ! |
---|
52 | ! 3421 2018-10-24 18:39:32Z gronemeier |
---|
53 | ! Renamed output variables |
---|
54 | ! |
---|
55 | ! 3337 2018-10-12 15:17:09Z kanani |
---|
56 | ! (from branch resler) |
---|
57 | ! Add biometeorology, |
---|
58 | ! fix chemistry output call, |
---|
59 | ! move usm calls |
---|
60 | ! |
---|
61 | ! 3294 2018-10-01 02:37:10Z raasch |
---|
62 | ! changes concerning modularization of ocean option |
---|
63 | ! |
---|
64 | ! 3291 2018-09-28 11:33:03Z scharf |
---|
65 | ! corrected previous commit for 3D topography |
---|
66 | ! |
---|
67 | ! 3285 2018-09-27 17:16:52Z scharf |
---|
68 | ! bugfix for shf_av and qsws_av |
---|
69 | ! |
---|
70 | ! 3274 2018-09-24 15:42:55Z knoop |
---|
71 | ! Modularization of all bulk cloud physics code components |
---|
72 | ! |
---|
73 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
74 | ! unused variables removed |
---|
75 | ! |
---|
76 | ! 3176 2018-07-26 17:12:48Z suehring |
---|
77 | ! Remove output of latent heat flux at urban-surfaces and set fill values |
---|
78 | ! instead |
---|
79 | ! |
---|
80 | ! 3173 2018-07-26 12:55:23Z suehring |
---|
81 | ! Bugfix for last commit |
---|
82 | ! |
---|
83 | ! 3170 2018-07-25 15:19:37Z suehring |
---|
84 | ! Revise output of surface quantities in case of overhanging structures |
---|
85 | ! |
---|
86 | ! 3151 2018-07-19 08:45:38Z raasch |
---|
87 | ! Remaining preprocessor directive __chem removed |
---|
88 | ! |
---|
89 | ! 3004 2018-04-27 12:33:25Z Giersch |
---|
90 | ! prr field added to ONLY-list, prr* case/pr* case/precipitation_rate_av |
---|
91 | ! removed, further allocation checks implemented |
---|
92 | ! |
---|
93 | ! 2963 2018-04-12 14:47:44Z suehring |
---|
94 | ! Introduce index for vegetation/wall, pavement/green-wall and water/window |
---|
95 | ! surfaces, for clearer access of surface fraction, albedo, emissivity, etc. . |
---|
96 | ! |
---|
97 | ! 2894 2018-03-15 09:17:58Z Giersch |
---|
98 | ! Changed comment |
---|
99 | ! |
---|
100 | ! 2817 2018-02-19 16:32:21Z suehring |
---|
101 | ! Preliminary gust module interface implemented |
---|
102 | ! |
---|
103 | ! 2798 2018-02-09 17:16:39Z suehring |
---|
104 | ! Consider also default-type surfaces for surface temperature output. |
---|
105 | ! |
---|
106 | ! 2797 2018-02-08 13:24:35Z suehring |
---|
107 | ! Enable output of ground-heat flux also at urban surfaces. |
---|
108 | ! |
---|
109 | ! 2790 2018-02-06 11:57:19Z suehring |
---|
110 | ! Bugfix in summation of surface sensible and latent heat flux |
---|
111 | ! |
---|
112 | ! 2766 2018-01-22 17:17:47Z kanani |
---|
113 | ! Removed preprocessor directive __chem |
---|
114 | ! |
---|
115 | ! 2743 2018-01-12 16:03:39Z suehring |
---|
116 | ! In case of natural- and urban-type surfaces output surfaces fluxes in W/m2. |
---|
117 | ! |
---|
118 | ! 2742 2018-01-12 14:59:47Z suehring |
---|
119 | ! Enable output of surface temperature |
---|
120 | ! |
---|
121 | ! 2735 2018-01-11 12:01:27Z suehring |
---|
122 | ! output of r_a moved from land-surface to consider also urban-type surfaces |
---|
123 | ! |
---|
124 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
125 | ! Corrected "Former revisions" section |
---|
126 | ! |
---|
127 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
128 | ! - Change in file header (GPL part) |
---|
129 | ! - Implementation of uv exposure model (FK) |
---|
130 | ! - output of diss_av, kh_av, km_av (turbulence_closure_mod) (TG) |
---|
131 | ! - Implementation of chemistry module (FK) |
---|
132 | ! - Workaround for sum-up usm arrays in case of restart runs, to avoid program |
---|
133 | ! crash (MS) |
---|
134 | ! |
---|
135 | ! 2292 2017-06-20 09:51:42Z schwenkel |
---|
136 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
137 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
138 | ! and cloud water content (qc). |
---|
139 | ! |
---|
140 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
141 | ! |
---|
142 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
143 | ! Adjustments to new surface concept |
---|
144 | ! |
---|
145 | ! 2031 2016-10-21 15:11:58Z knoop |
---|
146 | ! renamed variable rho to rho_ocean and rho_av to rho_ocean_av |
---|
147 | ! |
---|
148 | ! 2024 2016-10-12 16:42:37Z kanani |
---|
149 | ! Added missing CASE for ssws* |
---|
150 | ! |
---|
151 | ! 2011 2016-09-19 17:29:57Z kanani |
---|
152 | ! Flag urban_surface is now defined in module control_parameters, |
---|
153 | ! changed prefix for urban surface model output to "usm_", |
---|
154 | ! introduced control parameter varnamelength for LEN of trimvar. |
---|
155 | ! |
---|
156 | ! 2007 2016-08-24 15:47:17Z kanani |
---|
157 | ! Added support for new urban surface model (temporary modifications of |
---|
158 | ! SELECT CASE ( ) necessary, see variable trimvar), |
---|
159 | ! added comments in variable declaration section |
---|
160 | ! |
---|
161 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
162 | ! Forced header and separation lines into 80 columns |
---|
163 | ! |
---|
164 | ! 1992 2016-08-12 15:14:59Z suehring |
---|
165 | ! Bugfix in summation of passive scalar |
---|
166 | ! |
---|
167 | ! 1976 2016-07-27 13:28:04Z maronga |
---|
168 | ! Radiation actions are now done directly in the respective module |
---|
169 | ! |
---|
170 | ! 1972 2016-07-26 07:52:02Z maronga |
---|
171 | ! Land surface actions are now done directly in the respective module |
---|
172 | ! |
---|
173 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
174 | ! Scalar surface flux added |
---|
175 | ! |
---|
176 | ! 1949 2016-06-17 07:19:16Z maronga |
---|
177 | ! Bugfix: calculation of lai_av, c_veg_av and c_liq_av. |
---|
178 | ! |
---|
179 | ! 1849 2016-04-08 11:33:18Z hoffmann |
---|
180 | ! precipitation_rate moved to arrays_3d |
---|
181 | ! |
---|
182 | ! 1788 2016-03-10 11:01:04Z maronga |
---|
183 | ! Added z0q and z0q_av |
---|
184 | ! |
---|
185 | ! 1693 2015-10-27 08:35:45Z maronga |
---|
186 | ! Last revision text corrected |
---|
187 | ! |
---|
188 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
189 | ! Added output of Obukhov length and radiative heating rates for RRTMG. |
---|
190 | ! Corrected output of liquid water path. |
---|
191 | ! |
---|
192 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
193 | ! Code annotations made doxygen readable |
---|
194 | ! |
---|
195 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
196 | ! Adapted for RRTMG |
---|
197 | ! |
---|
198 | ! 1555 2015-03-04 17:44:27Z maronga |
---|
199 | ! Added output of r_a and r_s |
---|
200 | ! |
---|
201 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
202 | ! Added support for land surface model and radiation model data. |
---|
203 | ! |
---|
204 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
205 | ! New particle structure integrated. |
---|
206 | ! |
---|
207 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
208 | ! REAL constants provided with KIND-attribute |
---|
209 | ! |
---|
210 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
211 | ! ONLY-attribute added to USE-statements, |
---|
212 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
213 | ! kinds are defined in new module kinds, |
---|
214 | ! old module precision_kind is removed, |
---|
215 | ! revision history before 2012 removed, |
---|
216 | ! comment fields (!:) to be used for variable explanations added to |
---|
217 | ! all variable declaration statements |
---|
218 | ! |
---|
219 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
220 | ! barrier argument removed from cpu_log, |
---|
221 | ! module interfaces removed |
---|
222 | ! |
---|
223 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
224 | ! ql is calculated by calc_liquid_water_content |
---|
225 | ! |
---|
226 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
227 | ! +nr, prr, qr |
---|
228 | ! |
---|
229 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
230 | ! code put under GPL (PALM 3.9) |
---|
231 | ! |
---|
232 | ! 1007 2012-09-19 14:30:36Z franke |
---|
233 | ! Bugfix in calculation of ql_vp |
---|
234 | ! |
---|
235 | ! 978 2012-08-09 08:28:32Z fricke |
---|
236 | ! +z0h* |
---|
237 | ! |
---|
238 | ! Revision 1.1 2006/02/23 12:55:23 raasch |
---|
239 | ! Initial revision |
---|
240 | ! |
---|
241 | ! |
---|
242 | ! Description: |
---|
243 | ! ------------ |
---|
244 | !> Sum-up the values of 3d-arrays. The real averaging is later done in routine |
---|
245 | !> average_3d_data. |
---|
246 | !------------------------------------------------------------------------------! |
---|
247 | SUBROUTINE sum_up_3d_data |
---|
248 | |
---|
249 | |
---|
250 | USE arrays_3d, & |
---|
251 | ONLY: dzw, d_exner, e, heatflux_output_conversion, nc, nr, p, prr, & |
---|
252 | pt, q, qc, ql, ql_c, ql_v, qr, s, u, v, vpt, w, & |
---|
253 | waterflux_output_conversion |
---|
254 | |
---|
255 | USE averaging, & |
---|
256 | ONLY: e_av, ghf_av, lpt_av, lwp_av, ol_av, p_av, pc_av, pr_av, pt_av, & |
---|
257 | pt_2m_av, q_av, ql_av, ql_c_av, ql_v_av, ql_vp_av, qsws_av, & |
---|
258 | qv_av, r_a_av, s_av, shf_av, ssws_av, ts_av, tsurf_av, u_av, & |
---|
259 | us_av, v_av, vpt_av, w_av, z0_av, z0h_av, z0q_av |
---|
260 | |
---|
261 | USE basic_constants_and_equations_mod, & |
---|
262 | ONLY: c_p, lv_d_cp, l_v |
---|
263 | |
---|
264 | USE bulk_cloud_model_mod, & |
---|
265 | ONLY: bulk_cloud_model |
---|
266 | |
---|
267 | USE control_parameters, & |
---|
268 | ONLY: average_count_3d, doav, doav_n, rho_surface, urban_surface, & |
---|
269 | varnamelength |
---|
270 | |
---|
271 | USE cpulog, & |
---|
272 | ONLY: cpu_log, log_point |
---|
273 | |
---|
274 | USE indices, & |
---|
275 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt |
---|
276 | |
---|
277 | USE kinds |
---|
278 | |
---|
279 | USE module_interface, & |
---|
280 | ONLY: module_interface_3d_data_averaging |
---|
281 | |
---|
282 | USE particle_attributes, & |
---|
283 | ONLY: grid_particles, number_of_particles, particles, prt_count |
---|
284 | |
---|
285 | USE surface_mod, & |
---|
286 | ONLY: ind_pav_green, ind_veg_wall, ind_wat_win, & |
---|
287 | surf_def_h, surf_lsm_h, surf_usm_h |
---|
288 | |
---|
289 | USE turbulence_closure_mod, & |
---|
290 | ONLY: tcm_3d_data_averaging |
---|
291 | |
---|
292 | USE urban_surface_mod, & |
---|
293 | ONLY: usm_3d_data_averaging |
---|
294 | |
---|
295 | |
---|
296 | IMPLICIT NONE |
---|
297 | |
---|
298 | LOGICAL :: match_def !< flag indicating default-type surface |
---|
299 | LOGICAL :: match_lsm !< flag indicating natural-type surface |
---|
300 | LOGICAL :: match_usm !< flag indicating urban-type surface |
---|
301 | |
---|
302 | INTEGER(iwp) :: i !< grid index x direction |
---|
303 | INTEGER(iwp) :: ii !< running index |
---|
304 | INTEGER(iwp) :: j !< grid index y direction |
---|
305 | INTEGER(iwp) :: k !< grid index x direction |
---|
306 | INTEGER(iwp) :: m !< running index over surfacle elements |
---|
307 | INTEGER(iwp) :: n !< running index over number of particles per grid box |
---|
308 | |
---|
309 | REAL(wp) :: mean_r !< mean-particle radius witin grid box |
---|
310 | REAL(wp) :: s_r2 !< mean-particle radius witin grid box to the power of two |
---|
311 | REAL(wp) :: s_r3 !< mean-particle radius witin grid box to the power of three |
---|
312 | |
---|
313 | CHARACTER (LEN=varnamelength) :: trimvar !< TRIM of output-variable string |
---|
314 | |
---|
315 | |
---|
316 | CALL cpu_log (log_point(34),'sum_up_3d_data','start') |
---|
317 | |
---|
318 | ! |
---|
319 | !-- Allocate and initialize the summation arrays if called for the very first |
---|
320 | !-- time or the first time after average_3d_data has been called |
---|
321 | !-- (some or all of the arrays may have been already allocated |
---|
322 | !-- in rrd_local) |
---|
323 | IF ( average_count_3d == 0 ) THEN |
---|
324 | |
---|
325 | DO ii = 1, doav_n |
---|
326 | |
---|
327 | trimvar = TRIM( doav(ii) ) |
---|
328 | |
---|
329 | SELECT CASE ( trimvar ) |
---|
330 | |
---|
331 | CASE ( 'ghf*' ) |
---|
332 | IF ( .NOT. ALLOCATED( ghf_av ) ) THEN |
---|
333 | ALLOCATE( ghf_av(nysg:nyng,nxlg:nxrg) ) |
---|
334 | ENDIF |
---|
335 | ghf_av = 0.0_wp |
---|
336 | |
---|
337 | CASE ( 'e' ) |
---|
338 | IF ( .NOT. ALLOCATED( e_av ) ) THEN |
---|
339 | ALLOCATE( e_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
340 | ENDIF |
---|
341 | e_av = 0.0_wp |
---|
342 | |
---|
343 | CASE ( 'thetal' ) |
---|
344 | IF ( .NOT. ALLOCATED( lpt_av ) ) THEN |
---|
345 | ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
346 | ENDIF |
---|
347 | lpt_av = 0.0_wp |
---|
348 | |
---|
349 | CASE ( 'lwp*' ) |
---|
350 | IF ( .NOT. ALLOCATED( lwp_av ) ) THEN |
---|
351 | ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) ) |
---|
352 | ENDIF |
---|
353 | lwp_av = 0.0_wp |
---|
354 | |
---|
355 | CASE ( 'ol*' ) |
---|
356 | IF ( .NOT. ALLOCATED( ol_av ) ) THEN |
---|
357 | ALLOCATE( ol_av(nysg:nyng,nxlg:nxrg) ) |
---|
358 | ENDIF |
---|
359 | ol_av = 0.0_wp |
---|
360 | |
---|
361 | CASE ( 'p' ) |
---|
362 | IF ( .NOT. ALLOCATED( p_av ) ) THEN |
---|
363 | ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
364 | ENDIF |
---|
365 | p_av = 0.0_wp |
---|
366 | |
---|
367 | CASE ( 'pc' ) |
---|
368 | IF ( .NOT. ALLOCATED( pc_av ) ) THEN |
---|
369 | ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
370 | ENDIF |
---|
371 | pc_av = 0.0_wp |
---|
372 | |
---|
373 | CASE ( 'pr' ) |
---|
374 | IF ( .NOT. ALLOCATED( pr_av ) ) THEN |
---|
375 | ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
376 | ENDIF |
---|
377 | pr_av = 0.0_wp |
---|
378 | |
---|
379 | CASE ( 'theta' ) |
---|
380 | IF ( .NOT. ALLOCATED( pt_av ) ) THEN |
---|
381 | ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
382 | ENDIF |
---|
383 | pt_av = 0.0_wp |
---|
384 | |
---|
385 | CASE ( 'q' ) |
---|
386 | IF ( .NOT. ALLOCATED( q_av ) ) THEN |
---|
387 | ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
388 | ENDIF |
---|
389 | q_av = 0.0_wp |
---|
390 | |
---|
391 | CASE ( 'ql' ) |
---|
392 | IF ( .NOT. ALLOCATED( ql_av ) ) THEN |
---|
393 | ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
394 | ENDIF |
---|
395 | ql_av = 0.0_wp |
---|
396 | |
---|
397 | CASE ( 'ql_c' ) |
---|
398 | IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN |
---|
399 | ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
400 | ENDIF |
---|
401 | ql_c_av = 0.0_wp |
---|
402 | |
---|
403 | CASE ( 'ql_v' ) |
---|
404 | IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN |
---|
405 | ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
406 | ENDIF |
---|
407 | ql_v_av = 0.0_wp |
---|
408 | |
---|
409 | CASE ( 'ql_vp' ) |
---|
410 | IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN |
---|
411 | ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
412 | ENDIF |
---|
413 | ql_vp_av = 0.0_wp |
---|
414 | |
---|
415 | CASE ( 'qsws*' ) |
---|
416 | IF ( .NOT. ALLOCATED( qsws_av ) ) THEN |
---|
417 | ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) ) |
---|
418 | ENDIF |
---|
419 | qsws_av = 0.0_wp |
---|
420 | |
---|
421 | CASE ( 'qv' ) |
---|
422 | IF ( .NOT. ALLOCATED( qv_av ) ) THEN |
---|
423 | ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
424 | ENDIF |
---|
425 | qv_av = 0.0_wp |
---|
426 | |
---|
427 | CASE ( 'r_a*' ) |
---|
428 | IF ( .NOT. ALLOCATED( r_a_av ) ) THEN |
---|
429 | ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) ) |
---|
430 | ENDIF |
---|
431 | r_a_av = 0.0_wp |
---|
432 | |
---|
433 | CASE ( 's' ) |
---|
434 | IF ( .NOT. ALLOCATED( s_av ) ) THEN |
---|
435 | ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
436 | ENDIF |
---|
437 | s_av = 0.0_wp |
---|
438 | |
---|
439 | CASE ( 'shf*' ) |
---|
440 | IF ( .NOT. ALLOCATED( shf_av ) ) THEN |
---|
441 | ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) ) |
---|
442 | ENDIF |
---|
443 | shf_av = 0.0_wp |
---|
444 | |
---|
445 | CASE ( 'ssws*' ) |
---|
446 | IF ( .NOT. ALLOCATED( ssws_av ) ) THEN |
---|
447 | ALLOCATE( ssws_av(nysg:nyng,nxlg:nxrg) ) |
---|
448 | ENDIF |
---|
449 | ssws_av = 0.0_wp |
---|
450 | |
---|
451 | CASE ( 't*' ) |
---|
452 | IF ( .NOT. ALLOCATED( ts_av ) ) THEN |
---|
453 | ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) ) |
---|
454 | ENDIF |
---|
455 | ts_av = 0.0_wp |
---|
456 | |
---|
457 | CASE ( 'tsurf*' ) |
---|
458 | IF ( .NOT. ALLOCATED( tsurf_av ) ) THEN |
---|
459 | ALLOCATE( tsurf_av(nysg:nyng,nxlg:nxrg) ) |
---|
460 | ENDIF |
---|
461 | tsurf_av = 0.0_wp |
---|
462 | |
---|
463 | CASE ( 'u' ) |
---|
464 | IF ( .NOT. ALLOCATED( u_av ) ) THEN |
---|
465 | ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
466 | ENDIF |
---|
467 | u_av = 0.0_wp |
---|
468 | |
---|
469 | CASE ( 'us*' ) |
---|
470 | IF ( .NOT. ALLOCATED( us_av ) ) THEN |
---|
471 | ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) ) |
---|
472 | ENDIF |
---|
473 | us_av = 0.0_wp |
---|
474 | |
---|
475 | CASE ( 'v' ) |
---|
476 | IF ( .NOT. ALLOCATED( v_av ) ) THEN |
---|
477 | ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
478 | ENDIF |
---|
479 | v_av = 0.0_wp |
---|
480 | |
---|
481 | CASE ( 'thetav' ) |
---|
482 | IF ( .NOT. ALLOCATED( vpt_av ) ) THEN |
---|
483 | ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
484 | ENDIF |
---|
485 | vpt_av = 0.0_wp |
---|
486 | |
---|
487 | CASE ( 'theta_2m*' ) |
---|
488 | IF ( .NOT. ALLOCATED( pt_2m_av ) ) THEN |
---|
489 | ALLOCATE( pt_2m_av(nysg:nyng,nxlg:nxrg) ) |
---|
490 | ENDIF |
---|
491 | pt_2m_av = 0.0_wp |
---|
492 | |
---|
493 | CASE ( 'w' ) |
---|
494 | IF ( .NOT. ALLOCATED( w_av ) ) THEN |
---|
495 | ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
496 | ENDIF |
---|
497 | w_av = 0.0_wp |
---|
498 | |
---|
499 | CASE ( 'z0*' ) |
---|
500 | IF ( .NOT. ALLOCATED( z0_av ) ) THEN |
---|
501 | ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) ) |
---|
502 | ENDIF |
---|
503 | z0_av = 0.0_wp |
---|
504 | |
---|
505 | CASE ( 'z0h*' ) |
---|
506 | IF ( .NOT. ALLOCATED( z0h_av ) ) THEN |
---|
507 | ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) ) |
---|
508 | ENDIF |
---|
509 | z0h_av = 0.0_wp |
---|
510 | |
---|
511 | CASE ( 'z0q*' ) |
---|
512 | IF ( .NOT. ALLOCATED( z0q_av ) ) THEN |
---|
513 | ALLOCATE( z0q_av(nysg:nyng,nxlg:nxrg) ) |
---|
514 | ENDIF |
---|
515 | z0q_av = 0.0_wp |
---|
516 | |
---|
517 | |
---|
518 | CASE DEFAULT |
---|
519 | |
---|
520 | ! |
---|
521 | !-- Allocating and initializing data arrays for turbulence closure module |
---|
522 | CALL tcm_3d_data_averaging( 'allocate', trimvar ) |
---|
523 | |
---|
524 | ! |
---|
525 | !-- Allocating and initializing data arrays for all other modules |
---|
526 | CALL module_interface_3d_data_averaging( 'allocate', trimvar ) |
---|
527 | |
---|
528 | |
---|
529 | END SELECT |
---|
530 | |
---|
531 | ENDDO |
---|
532 | |
---|
533 | ENDIF |
---|
534 | |
---|
535 | ! |
---|
536 | !-- Loop of all variables to be averaged. |
---|
537 | DO ii = 1, doav_n |
---|
538 | |
---|
539 | trimvar = TRIM( doav(ii) ) |
---|
540 | ! |
---|
541 | !-- Store the array chosen on the temporary array. |
---|
542 | SELECT CASE ( trimvar ) |
---|
543 | |
---|
544 | CASE ( 'ghf*' ) |
---|
545 | IF ( ALLOCATED( ghf_av ) ) THEN |
---|
546 | DO i = nxl, nxr |
---|
547 | DO j = nys, nyn |
---|
548 | ! |
---|
549 | !-- Check whether grid point is a natural- or urban-type |
---|
550 | !-- surface. |
---|
551 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
552 | surf_lsm_h%end_index(j,i) |
---|
553 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
554 | surf_usm_h%end_index(j,i) |
---|
555 | ! |
---|
556 | !-- In order to avoid double-counting of surface properties, |
---|
557 | !-- always assume that natural-type surfaces are below urban- |
---|
558 | !-- type surfaces, e.g. in case of bridges. |
---|
559 | !-- Further, take only the last suface element, i.e. the |
---|
560 | !-- uppermost surface which would be visible from above |
---|
561 | IF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
562 | m = surf_lsm_h%end_index(j,i) |
---|
563 | ghf_av(j,i) = ghf_av(j,i) + & |
---|
564 | surf_lsm_h%ghf(m) |
---|
565 | ELSEIF ( match_usm ) THEN |
---|
566 | m = surf_usm_h%end_index(j,i) |
---|
567 | ghf_av(j,i) = ghf_av(j,i) + & |
---|
568 | surf_usm_h%frac(ind_veg_wall,m) * & |
---|
569 | surf_usm_h%wghf_eb(m) + & |
---|
570 | surf_usm_h%frac(ind_pav_green,m) * & |
---|
571 | surf_usm_h%wghf_eb_green(m) + & |
---|
572 | surf_usm_h%frac(ind_wat_win,m) * & |
---|
573 | surf_usm_h%wghf_eb_window(m) |
---|
574 | ENDIF |
---|
575 | ENDDO |
---|
576 | ENDDO |
---|
577 | ENDIF |
---|
578 | |
---|
579 | CASE ( 'e' ) |
---|
580 | IF ( ALLOCATED( e_av ) ) THEN |
---|
581 | DO i = nxlg, nxrg |
---|
582 | DO j = nysg, nyng |
---|
583 | DO k = nzb, nzt+1 |
---|
584 | e_av(k,j,i) = e_av(k,j,i) + e(k,j,i) |
---|
585 | ENDDO |
---|
586 | ENDDO |
---|
587 | ENDDO |
---|
588 | ENDIF |
---|
589 | |
---|
590 | CASE ( 'thetal' ) |
---|
591 | IF ( ALLOCATED( lpt_av ) ) THEN |
---|
592 | DO i = nxlg, nxrg |
---|
593 | DO j = nysg, nyng |
---|
594 | DO k = nzb, nzt+1 |
---|
595 | lpt_av(k,j,i) = lpt_av(k,j,i) + pt(k,j,i) |
---|
596 | ENDDO |
---|
597 | ENDDO |
---|
598 | ENDDO |
---|
599 | ENDIF |
---|
600 | |
---|
601 | CASE ( 'lwp*' ) |
---|
602 | IF ( ALLOCATED( lwp_av ) ) THEN |
---|
603 | DO i = nxlg, nxrg |
---|
604 | DO j = nysg, nyng |
---|
605 | lwp_av(j,i) = lwp_av(j,i) + SUM( ql(nzb:nzt,j,i) & |
---|
606 | * dzw(1:nzt+1) ) * rho_surface |
---|
607 | ENDDO |
---|
608 | ENDDO |
---|
609 | ENDIF |
---|
610 | |
---|
611 | CASE ( 'ol*' ) |
---|
612 | IF ( ALLOCATED( ol_av ) ) THEN |
---|
613 | DO i = nxl, nxr |
---|
614 | DO j = nys, nyn |
---|
615 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
616 | surf_def_h(0)%end_index(j,i) |
---|
617 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
618 | surf_lsm_h%end_index(j,i) |
---|
619 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
620 | surf_usm_h%end_index(j,i) |
---|
621 | |
---|
622 | IF ( match_def ) THEN |
---|
623 | m = surf_def_h(0)%end_index(j,i) |
---|
624 | ol_av(j,i) = ol_av(j,i) + & |
---|
625 | surf_def_h(0)%ol(m) |
---|
626 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
627 | m = surf_lsm_h%end_index(j,i) |
---|
628 | ol_av(j,i) = ol_av(j,i) + & |
---|
629 | surf_lsm_h%ol(m) |
---|
630 | ELSEIF ( match_usm ) THEN |
---|
631 | m = surf_usm_h%end_index(j,i) |
---|
632 | ol_av(j,i) = ol_av(j,i) + & |
---|
633 | surf_usm_h%ol(m) |
---|
634 | ENDIF |
---|
635 | ENDDO |
---|
636 | ENDDO |
---|
637 | ENDIF |
---|
638 | |
---|
639 | CASE ( 'p' ) |
---|
640 | IF ( ALLOCATED( p_av ) ) THEN |
---|
641 | DO i = nxlg, nxrg |
---|
642 | DO j = nysg, nyng |
---|
643 | DO k = nzb, nzt+1 |
---|
644 | p_av(k,j,i) = p_av(k,j,i) + p(k,j,i) |
---|
645 | ENDDO |
---|
646 | ENDDO |
---|
647 | ENDDO |
---|
648 | ENDIF |
---|
649 | |
---|
650 | CASE ( 'pc' ) |
---|
651 | IF ( ALLOCATED( pc_av ) ) THEN |
---|
652 | DO i = nxl, nxr |
---|
653 | DO j = nys, nyn |
---|
654 | DO k = nzb, nzt+1 |
---|
655 | pc_av(k,j,i) = pc_av(k,j,i) + prt_count(k,j,i) |
---|
656 | ENDDO |
---|
657 | ENDDO |
---|
658 | ENDDO |
---|
659 | ENDIF |
---|
660 | |
---|
661 | CASE ( 'pr' ) |
---|
662 | IF ( ALLOCATED( pr_av ) ) THEN |
---|
663 | DO i = nxl, nxr |
---|
664 | DO j = nys, nyn |
---|
665 | DO k = nzb, nzt+1 |
---|
666 | number_of_particles = prt_count(k,j,i) |
---|
667 | IF ( number_of_particles <= 0 ) CYCLE |
---|
668 | particles => & |
---|
669 | grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
670 | s_r2 = 0.0_wp |
---|
671 | s_r3 = 0.0_wp |
---|
672 | |
---|
673 | DO n = 1, number_of_particles |
---|
674 | IF ( particles(n)%particle_mask ) THEN |
---|
675 | s_r2 = s_r2 + particles(n)%radius**2 * & |
---|
676 | particles(n)%weight_factor |
---|
677 | s_r3 = s_r3 + particles(n)%radius**3 * & |
---|
678 | particles(n)%weight_factor |
---|
679 | ENDIF |
---|
680 | ENDDO |
---|
681 | |
---|
682 | IF ( s_r2 > 0.0_wp ) THEN |
---|
683 | mean_r = s_r3 / s_r2 |
---|
684 | ELSE |
---|
685 | mean_r = 0.0_wp |
---|
686 | ENDIF |
---|
687 | pr_av(k,j,i) = pr_av(k,j,i) + mean_r |
---|
688 | ENDDO |
---|
689 | ENDDO |
---|
690 | ENDDO |
---|
691 | ENDIF |
---|
692 | |
---|
693 | CASE ( 'theta' ) |
---|
694 | IF ( ALLOCATED( pt_av ) ) THEN |
---|
695 | IF ( .NOT. bulk_cloud_model ) THEN |
---|
696 | DO i = nxlg, nxrg |
---|
697 | DO j = nysg, nyng |
---|
698 | DO k = nzb, nzt+1 |
---|
699 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) |
---|
700 | ENDDO |
---|
701 | ENDDO |
---|
702 | ENDDO |
---|
703 | ELSE |
---|
704 | DO i = nxlg, nxrg |
---|
705 | DO j = nysg, nyng |
---|
706 | DO k = nzb, nzt+1 |
---|
707 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) + lv_d_cp * & |
---|
708 | d_exner(k) * ql(k,j,i) |
---|
709 | ENDDO |
---|
710 | ENDDO |
---|
711 | ENDDO |
---|
712 | ENDIF |
---|
713 | ENDIF |
---|
714 | |
---|
715 | CASE ( 'q' ) |
---|
716 | IF ( ALLOCATED( q_av ) ) THEN |
---|
717 | DO i = nxlg, nxrg |
---|
718 | DO j = nysg, nyng |
---|
719 | DO k = nzb, nzt+1 |
---|
720 | q_av(k,j,i) = q_av(k,j,i) + q(k,j,i) |
---|
721 | ENDDO |
---|
722 | ENDDO |
---|
723 | ENDDO |
---|
724 | ENDIF |
---|
725 | |
---|
726 | CASE ( 'ql' ) |
---|
727 | IF ( ALLOCATED( ql_av ) ) THEN |
---|
728 | DO i = nxlg, nxrg |
---|
729 | DO j = nysg, nyng |
---|
730 | DO k = nzb, nzt+1 |
---|
731 | ql_av(k,j,i) = ql_av(k,j,i) + ql(k,j,i) |
---|
732 | ENDDO |
---|
733 | ENDDO |
---|
734 | ENDDO |
---|
735 | ENDIF |
---|
736 | |
---|
737 | CASE ( 'ql_c' ) |
---|
738 | IF ( ALLOCATED( ql_c_av ) ) THEN |
---|
739 | DO i = nxlg, nxrg |
---|
740 | DO j = nysg, nyng |
---|
741 | DO k = nzb, nzt+1 |
---|
742 | ql_c_av(k,j,i) = ql_c_av(k,j,i) + ql_c(k,j,i) |
---|
743 | ENDDO |
---|
744 | ENDDO |
---|
745 | ENDDO |
---|
746 | ENDIF |
---|
747 | |
---|
748 | CASE ( 'ql_v' ) |
---|
749 | IF ( ALLOCATED( ql_v_av ) ) THEN |
---|
750 | DO i = nxlg, nxrg |
---|
751 | DO j = nysg, nyng |
---|
752 | DO k = nzb, nzt+1 |
---|
753 | ql_v_av(k,j,i) = ql_v_av(k,j,i) + ql_v(k,j,i) |
---|
754 | ENDDO |
---|
755 | ENDDO |
---|
756 | ENDDO |
---|
757 | ENDIF |
---|
758 | |
---|
759 | CASE ( 'ql_vp' ) |
---|
760 | IF ( ALLOCATED( ql_vp_av ) ) THEN |
---|
761 | DO i = nxl, nxr |
---|
762 | DO j = nys, nyn |
---|
763 | DO k = nzb, nzt+1 |
---|
764 | number_of_particles = prt_count(k,j,i) |
---|
765 | IF ( number_of_particles <= 0 ) CYCLE |
---|
766 | particles => & |
---|
767 | grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
768 | DO n = 1, number_of_particles |
---|
769 | IF ( particles(n)%particle_mask ) THEN |
---|
770 | ql_vp_av(k,j,i) = ql_vp_av(k,j,i) + & |
---|
771 | particles(n)%weight_factor / & |
---|
772 | number_of_particles |
---|
773 | ENDIF |
---|
774 | ENDDO |
---|
775 | ENDDO |
---|
776 | ENDDO |
---|
777 | ENDDO |
---|
778 | ENDIF |
---|
779 | |
---|
780 | CASE ( 'qsws*' ) |
---|
781 | ! |
---|
782 | !-- In case of default surfaces, clean-up flux by density. |
---|
783 | !-- In case of land- and urban-surfaces, convert fluxes into |
---|
784 | !-- dynamic units. |
---|
785 | IF ( ALLOCATED( qsws_av ) ) THEN |
---|
786 | DO i = nxl, nxr |
---|
787 | DO j = nys, nyn |
---|
788 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
789 | surf_def_h(0)%end_index(j,i) |
---|
790 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
791 | surf_lsm_h%end_index(j,i) |
---|
792 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
793 | surf_usm_h%end_index(j,i) |
---|
794 | |
---|
795 | IF ( match_def ) THEN |
---|
796 | m = surf_def_h(0)%end_index(j,i) |
---|
797 | qsws_av(j,i) = qsws_av(j,i) + & |
---|
798 | surf_def_h(0)%qsws(m) * & |
---|
799 | waterflux_output_conversion(nzb) |
---|
800 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
801 | m = surf_lsm_h%end_index(j,i) |
---|
802 | qsws_av(j,i) = qsws_av(j,i) + & |
---|
803 | surf_lsm_h%qsws(m) * l_v |
---|
804 | ENDIF |
---|
805 | ENDDO |
---|
806 | ENDDO |
---|
807 | ENDIF |
---|
808 | |
---|
809 | CASE ( 'qv' ) |
---|
810 | IF ( ALLOCATED( qv_av ) ) THEN |
---|
811 | DO i = nxlg, nxrg |
---|
812 | DO j = nysg, nyng |
---|
813 | DO k = nzb, nzt+1 |
---|
814 | qv_av(k,j,i) = qv_av(k,j,i) + q(k,j,i) - ql(k,j,i) |
---|
815 | ENDDO |
---|
816 | ENDDO |
---|
817 | ENDDO |
---|
818 | ENDIF |
---|
819 | |
---|
820 | CASE ( 'r_a*' ) |
---|
821 | IF ( ALLOCATED( r_a_av ) ) THEN |
---|
822 | DO i = nxl, nxr |
---|
823 | DO j = nys, nyn |
---|
824 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
825 | surf_lsm_h%end_index(j,i) |
---|
826 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
827 | surf_usm_h%end_index(j,i) |
---|
828 | |
---|
829 | IF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
830 | m = surf_lsm_h%end_index(j,i) |
---|
831 | r_a_av(j,i) = r_a_av(j,i) + & |
---|
832 | surf_lsm_h%r_a(m) |
---|
833 | ELSEIF ( match_usm ) THEN |
---|
834 | m = surf_usm_h%end_index(j,i) |
---|
835 | r_a_av(j,i) = r_a_av(j,i) + & |
---|
836 | surf_usm_h%frac(ind_veg_wall,m) * & |
---|
837 | surf_usm_h%r_a(m) + & |
---|
838 | surf_usm_h%frac(ind_pav_green,m) * & |
---|
839 | surf_usm_h%r_a_green(m) + & |
---|
840 | surf_usm_h%frac(ind_wat_win,m) * & |
---|
841 | surf_usm_h%r_a_window(m) |
---|
842 | ENDIF |
---|
843 | ENDDO |
---|
844 | ENDDO |
---|
845 | ENDIF |
---|
846 | |
---|
847 | CASE ( 's' ) |
---|
848 | IF ( ALLOCATED( s_av ) ) THEN |
---|
849 | DO i = nxlg, nxrg |
---|
850 | DO j = nysg, nyng |
---|
851 | DO k = nzb, nzt+1 |
---|
852 | s_av(k,j,i) = s_av(k,j,i) + s(k,j,i) |
---|
853 | ENDDO |
---|
854 | ENDDO |
---|
855 | ENDDO |
---|
856 | ENDIF |
---|
857 | |
---|
858 | CASE ( 'shf*' ) |
---|
859 | ! |
---|
860 | !-- In case of default surfaces, clean-up flux by density. |
---|
861 | !-- In case of land- and urban-surfaces, convert fluxes into |
---|
862 | !-- dynamic units. |
---|
863 | IF ( ALLOCATED( shf_av ) ) THEN |
---|
864 | DO i = nxl, nxr |
---|
865 | DO j = nys, nyn |
---|
866 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
867 | surf_def_h(0)%end_index(j,i) |
---|
868 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
869 | surf_lsm_h%end_index(j,i) |
---|
870 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
871 | surf_usm_h%end_index(j,i) |
---|
872 | |
---|
873 | IF ( match_def ) THEN |
---|
874 | m = surf_def_h(0)%end_index(j,i) |
---|
875 | shf_av(j,i) = shf_av(j,i) + & |
---|
876 | surf_def_h(0)%shf(m) * & |
---|
877 | heatflux_output_conversion(nzb) |
---|
878 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
879 | m = surf_lsm_h%end_index(j,i) |
---|
880 | shf_av(j,i) = shf_av(j,i) + & |
---|
881 | surf_lsm_h%shf(m) * c_p |
---|
882 | ELSEIF ( match_usm ) THEN |
---|
883 | m = surf_usm_h%end_index(j,i) |
---|
884 | shf_av(j,i) = shf_av(j,i) + & |
---|
885 | surf_usm_h%shf(m) * c_p |
---|
886 | ENDIF |
---|
887 | ENDDO |
---|
888 | ENDDO |
---|
889 | ENDIF |
---|
890 | |
---|
891 | CASE ( 'ssws*' ) |
---|
892 | IF ( ALLOCATED( ssws_av ) ) THEN |
---|
893 | DO i = nxl, nxr |
---|
894 | DO j = nys, nyn |
---|
895 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
896 | surf_def_h(0)%end_index(j,i) |
---|
897 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
898 | surf_lsm_h%end_index(j,i) |
---|
899 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
900 | surf_usm_h%end_index(j,i) |
---|
901 | |
---|
902 | IF ( match_def ) THEN |
---|
903 | m = surf_def_h(0)%end_index(j,i) |
---|
904 | ssws_av(j,i) = ssws_av(j,i) + & |
---|
905 | surf_def_h(0)%ssws(m) |
---|
906 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
907 | m = surf_lsm_h%end_index(j,i) |
---|
908 | ssws_av(j,i) = ssws_av(j,i) + & |
---|
909 | surf_lsm_h%ssws(m) |
---|
910 | ELSEIF ( match_usm ) THEN |
---|
911 | m = surf_usm_h%end_index(j,i) |
---|
912 | ssws_av(j,i) = ssws_av(j,i) + & |
---|
913 | surf_usm_h%ssws(m) |
---|
914 | ENDIF |
---|
915 | ENDDO |
---|
916 | ENDDO |
---|
917 | ENDIF |
---|
918 | |
---|
919 | CASE ( 't*' ) |
---|
920 | IF ( ALLOCATED( ts_av ) ) THEN |
---|
921 | DO i = nxl, nxr |
---|
922 | DO j = nys, nyn |
---|
923 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
924 | surf_def_h(0)%end_index(j,i) |
---|
925 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
926 | surf_lsm_h%end_index(j,i) |
---|
927 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
928 | surf_usm_h%end_index(j,i) |
---|
929 | |
---|
930 | IF ( match_def ) THEN |
---|
931 | m = surf_def_h(0)%end_index(j,i) |
---|
932 | ts_av(j,i) = ts_av(j,i) + & |
---|
933 | surf_def_h(0)%ts(m) |
---|
934 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
935 | m = surf_lsm_h%end_index(j,i) |
---|
936 | ts_av(j,i) = ts_av(j,i) + & |
---|
937 | surf_lsm_h%ts(m) |
---|
938 | ELSEIF ( match_usm ) THEN |
---|
939 | m = surf_usm_h%end_index(j,i) |
---|
940 | ts_av(j,i) = ts_av(j,i) + & |
---|
941 | surf_usm_h%ts(m) |
---|
942 | ENDIF |
---|
943 | ENDDO |
---|
944 | ENDDO |
---|
945 | ENDIF |
---|
946 | |
---|
947 | CASE ( 'tsurf*' ) |
---|
948 | IF ( ALLOCATED( tsurf_av ) ) THEN |
---|
949 | DO i = nxl, nxr |
---|
950 | DO j = nys, nyn |
---|
951 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
952 | surf_def_h(0)%end_index(j,i) |
---|
953 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
954 | surf_lsm_h%end_index(j,i) |
---|
955 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
956 | surf_usm_h%end_index(j,i) |
---|
957 | |
---|
958 | IF ( match_def ) THEN |
---|
959 | m = surf_def_h(0)%end_index(j,i) |
---|
960 | tsurf_av(j,i) = tsurf_av(j,i) + & |
---|
961 | surf_def_h(0)%pt_surface(m) |
---|
962 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
963 | m = surf_lsm_h%end_index(j,i) |
---|
964 | tsurf_av(j,i) = tsurf_av(j,i) + & |
---|
965 | surf_lsm_h%pt_surface(m) |
---|
966 | ELSEIF ( match_usm ) THEN |
---|
967 | m = surf_usm_h%end_index(j,i) |
---|
968 | tsurf_av(j,i) = tsurf_av(j,i) + & |
---|
969 | surf_usm_h%pt_surface(m) |
---|
970 | ENDIF |
---|
971 | ENDDO |
---|
972 | ENDDO |
---|
973 | ENDIF |
---|
974 | |
---|
975 | CASE ( 'u' ) |
---|
976 | IF ( ALLOCATED( u_av ) ) THEN |
---|
977 | DO i = nxlg, nxrg |
---|
978 | DO j = nysg, nyng |
---|
979 | DO k = nzb, nzt+1 |
---|
980 | u_av(k,j,i) = u_av(k,j,i) + u(k,j,i) |
---|
981 | ENDDO |
---|
982 | ENDDO |
---|
983 | ENDDO |
---|
984 | ENDIF |
---|
985 | |
---|
986 | CASE ( 'us*' ) |
---|
987 | IF ( ALLOCATED( us_av ) ) THEN |
---|
988 | DO i = nxl, nxr |
---|
989 | DO j = nys, nyn |
---|
990 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
991 | surf_def_h(0)%end_index(j,i) |
---|
992 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
993 | surf_lsm_h%end_index(j,i) |
---|
994 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
995 | surf_usm_h%end_index(j,i) |
---|
996 | |
---|
997 | IF ( match_def ) THEN |
---|
998 | m = surf_def_h(0)%end_index(j,i) |
---|
999 | us_av(j,i) = us_av(j,i) + & |
---|
1000 | surf_def_h(0)%us(m) |
---|
1001 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
1002 | m = surf_lsm_h%end_index(j,i) |
---|
1003 | us_av(j,i) = us_av(j,i) + & |
---|
1004 | surf_lsm_h%us(m) |
---|
1005 | ELSEIF ( match_usm ) THEN |
---|
1006 | m = surf_usm_h%end_index(j,i) |
---|
1007 | us_av(j,i) = us_av(j,i) + & |
---|
1008 | surf_usm_h%us(m) |
---|
1009 | ENDIF |
---|
1010 | ENDDO |
---|
1011 | ENDDO |
---|
1012 | ENDIF |
---|
1013 | |
---|
1014 | CASE ( 'v' ) |
---|
1015 | IF ( ALLOCATED( v_av ) ) THEN |
---|
1016 | DO i = nxlg, nxrg |
---|
1017 | DO j = nysg, nyng |
---|
1018 | DO k = nzb, nzt+1 |
---|
1019 | v_av(k,j,i) = v_av(k,j,i) + v(k,j,i) |
---|
1020 | ENDDO |
---|
1021 | ENDDO |
---|
1022 | ENDDO |
---|
1023 | ENDIF |
---|
1024 | |
---|
1025 | CASE ( 'thetav' ) |
---|
1026 | IF ( ALLOCATED( vpt_av ) ) THEN |
---|
1027 | DO i = nxlg, nxrg |
---|
1028 | DO j = nysg, nyng |
---|
1029 | DO k = nzb, nzt+1 |
---|
1030 | vpt_av(k,j,i) = vpt_av(k,j,i) + vpt(k,j,i) |
---|
1031 | ENDDO |
---|
1032 | ENDDO |
---|
1033 | ENDDO |
---|
1034 | ENDIF |
---|
1035 | |
---|
1036 | CASE ( 'w' ) |
---|
1037 | IF ( ALLOCATED( w_av ) ) THEN |
---|
1038 | DO i = nxlg, nxrg |
---|
1039 | DO j = nysg, nyng |
---|
1040 | DO k = nzb, nzt+1 |
---|
1041 | w_av(k,j,i) = w_av(k,j,i) + w(k,j,i) |
---|
1042 | ENDDO |
---|
1043 | ENDDO |
---|
1044 | ENDDO |
---|
1045 | ENDIF |
---|
1046 | |
---|
1047 | CASE ( 'z0*' ) |
---|
1048 | IF ( ALLOCATED( z0_av ) ) THEN |
---|
1049 | DO i = nxl, nxr |
---|
1050 | DO j = nys, nyn |
---|
1051 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
1052 | surf_def_h(0)%end_index(j,i) |
---|
1053 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
1054 | surf_lsm_h%end_index(j,i) |
---|
1055 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
1056 | surf_usm_h%end_index(j,i) |
---|
1057 | |
---|
1058 | IF ( match_def ) THEN |
---|
1059 | m = surf_def_h(0)%end_index(j,i) |
---|
1060 | z0_av(j,i) = z0_av(j,i) + & |
---|
1061 | surf_def_h(0)%z0(m) |
---|
1062 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
1063 | m = surf_lsm_h%end_index(j,i) |
---|
1064 | z0_av(j,i) = z0_av(j,i) + & |
---|
1065 | surf_lsm_h%z0(m) |
---|
1066 | ELSEIF ( match_usm ) THEN |
---|
1067 | m = surf_usm_h%end_index(j,i) |
---|
1068 | z0_av(j,i) = z0_av(j,i) + & |
---|
1069 | surf_usm_h%z0(m) |
---|
1070 | ENDIF |
---|
1071 | ENDDO |
---|
1072 | ENDDO |
---|
1073 | ENDIF |
---|
1074 | |
---|
1075 | CASE ( 'z0h*' ) |
---|
1076 | IF ( ALLOCATED( z0h_av ) ) THEN |
---|
1077 | DO i = nxl, nxr |
---|
1078 | DO j = nys, nyn |
---|
1079 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
1080 | surf_def_h(0)%end_index(j,i) |
---|
1081 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
1082 | surf_lsm_h%end_index(j,i) |
---|
1083 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
1084 | surf_usm_h%end_index(j,i) |
---|
1085 | |
---|
1086 | IF ( match_def ) THEN |
---|
1087 | m = surf_def_h(0)%end_index(j,i) |
---|
1088 | z0h_av(j,i) = z0h_av(j,i) + & |
---|
1089 | surf_def_h(0)%z0h(m) |
---|
1090 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
1091 | m = surf_lsm_h%end_index(j,i) |
---|
1092 | z0h_av(j,i) = z0h_av(j,i) + & |
---|
1093 | surf_lsm_h%z0h(m) |
---|
1094 | ELSEIF ( match_usm ) THEN |
---|
1095 | m = surf_usm_h%end_index(j,i) |
---|
1096 | z0h_av(j,i) = z0h_av(j,i) + & |
---|
1097 | surf_usm_h%z0h(m) |
---|
1098 | ENDIF |
---|
1099 | ENDDO |
---|
1100 | ENDDO |
---|
1101 | ENDIF |
---|
1102 | |
---|
1103 | CASE ( 'z0q*' ) |
---|
1104 | IF ( ALLOCATED( z0q_av ) ) THEN |
---|
1105 | DO i = nxl, nxr |
---|
1106 | DO j = nys, nyn |
---|
1107 | match_def = surf_def_h(0)%start_index(j,i) <= & |
---|
1108 | surf_def_h(0)%end_index(j,i) |
---|
1109 | match_lsm = surf_lsm_h%start_index(j,i) <= & |
---|
1110 | surf_lsm_h%end_index(j,i) |
---|
1111 | match_usm = surf_usm_h%start_index(j,i) <= & |
---|
1112 | surf_usm_h%end_index(j,i) |
---|
1113 | |
---|
1114 | IF ( match_def ) THEN |
---|
1115 | m = surf_def_h(0)%end_index(j,i) |
---|
1116 | z0q_av(j,i) = z0q_av(j,i) + & |
---|
1117 | surf_def_h(0)%z0q(m) |
---|
1118 | ELSEIF ( match_lsm .AND. .NOT. match_usm ) THEN |
---|
1119 | m = surf_lsm_h%end_index(j,i) |
---|
1120 | z0q_av(j,i) = z0q_av(j,i) + & |
---|
1121 | surf_lsm_h%z0q(m) |
---|
1122 | ELSEIF ( match_usm ) THEN |
---|
1123 | m = surf_usm_h%end_index(j,i) |
---|
1124 | z0q_av(j,i) = z0q_av(j,i) + & |
---|
1125 | surf_usm_h%z0q(m) |
---|
1126 | ENDIF |
---|
1127 | ENDDO |
---|
1128 | ENDDO |
---|
1129 | ENDIF |
---|
1130 | |
---|
1131 | CASE DEFAULT |
---|
1132 | |
---|
1133 | !-- In case of urban surface variables it should be always checked |
---|
1134 | !-- if respective arrays are allocated, at least in case of a restart |
---|
1135 | !-- run, as averaged usm arrays are not read from file at the moment. |
---|
1136 | IF ( urban_surface ) THEN |
---|
1137 | CALL usm_3d_data_averaging( 'allocate', trimvar ) |
---|
1138 | ENDIF |
---|
1139 | |
---|
1140 | ! |
---|
1141 | !-- Summing up data from turbulence closure module |
---|
1142 | CALL tcm_3d_data_averaging( 'sum', trimvar ) |
---|
1143 | |
---|
1144 | ! |
---|
1145 | !-- Summing up data from all other modules |
---|
1146 | CALL module_interface_3d_data_averaging( 'sum', trimvar ) |
---|
1147 | |
---|
1148 | |
---|
1149 | END SELECT |
---|
1150 | |
---|
1151 | ENDDO |
---|
1152 | |
---|
1153 | CALL cpu_log( log_point(34), 'sum_up_3d_data', 'stop' ) |
---|
1154 | |
---|
1155 | |
---|
1156 | END SUBROUTINE sum_up_3d_data |
---|