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