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