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