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