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