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