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