1 | !> @file sum_up_3d_data.f90 |
---|
2 | !--------------------------------------------------------------------------------! |
---|
3 | ! This file is part of PALM. |
---|
4 | ! |
---|
5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
7 | ! either version 3 of the License, or (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with |
---|
14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! Code annotations made doxygen readable |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: sum_up_3d_data.f90 1682 2015-10-07 23:56:08Z knoop $ |
---|
26 | ! |
---|
27 | ! 1585 2015-04-30 07:05:52Z maronga |
---|
28 | ! Adapted for RRTMG |
---|
29 | ! |
---|
30 | ! 1555 2015-03-04 17:44:27Z maronga |
---|
31 | ! Added output of r_a and r_s |
---|
32 | ! |
---|
33 | ! 1551 2015-03-03 14:18:16Z maronga |
---|
34 | ! Added support for land surface model and radiation model data. |
---|
35 | ! |
---|
36 | ! 1359 2014-04-11 17:15:14Z hoffmann |
---|
37 | ! New particle structure integrated. |
---|
38 | ! |
---|
39 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
40 | ! REAL constants provided with KIND-attribute |
---|
41 | ! |
---|
42 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
43 | ! ONLY-attribute added to USE-statements, |
---|
44 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
45 | ! kinds are defined in new module kinds, |
---|
46 | ! old module precision_kind is removed, |
---|
47 | ! revision history before 2012 removed, |
---|
48 | ! comment fields (!:) to be used for variable explanations added to |
---|
49 | ! all variable declaration statements |
---|
50 | ! |
---|
51 | ! 1318 2014-03-17 13:35:16Z raasch |
---|
52 | ! barrier argument removed from cpu_log, |
---|
53 | ! module interfaces removed |
---|
54 | ! |
---|
55 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
56 | ! ql is calculated by calc_liquid_water_content |
---|
57 | ! |
---|
58 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
59 | ! +nr, prr, qr |
---|
60 | ! |
---|
61 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
62 | ! code put under GPL (PALM 3.9) |
---|
63 | ! |
---|
64 | ! 1007 2012-09-19 14:30:36Z franke |
---|
65 | ! Bugfix in calculation of ql_vp |
---|
66 | ! |
---|
67 | ! 978 2012-08-09 08:28:32Z fricke |
---|
68 | ! +z0h* |
---|
69 | ! |
---|
70 | ! Revision 1.1 2006/02/23 12:55:23 raasch |
---|
71 | ! Initial revision |
---|
72 | ! |
---|
73 | ! |
---|
74 | ! Description: |
---|
75 | ! ------------ |
---|
76 | !> Sum-up the values of 3d-arrays. The real averaging is later done in routine |
---|
77 | !> average_3d_data. |
---|
78 | !------------------------------------------------------------------------------! |
---|
79 | SUBROUTINE sum_up_3d_data |
---|
80 | |
---|
81 | |
---|
82 | USE arrays_3d, & |
---|
83 | ONLY: dzw, e, nr, p, pt, q, qc, ql, ql_c, ql_v, qr, qsws, rho, sa, & |
---|
84 | shf, ts, u, us, v, vpt, w, z0, z0h |
---|
85 | |
---|
86 | USE averaging, & |
---|
87 | ONLY: e_av, lpt_av, lwp_av, nr_av, p_av, pc_av, pr_av, prr_av, & |
---|
88 | precipitation_rate_av, pt_av, q_av, qc_av, ql_av, ql_c_av, & |
---|
89 | ql_v_av, ql_vp_av, qr_av, qsws_av, qv_av, rho_av, s_av, sa_av, & |
---|
90 | shf_av, ts_av, u_av, us_av, v_av, vpt_av, w_av, z0_av, z0h_av |
---|
91 | |
---|
92 | USE cloud_parameters, & |
---|
93 | ONLY: l_d_cp, precipitation_rate, pt_d_t |
---|
94 | |
---|
95 | USE control_parameters, & |
---|
96 | ONLY: average_count_3d, cloud_physics, doav, doav_n |
---|
97 | |
---|
98 | USE cpulog, & |
---|
99 | ONLY: cpu_log, log_point |
---|
100 | |
---|
101 | USE indices, & |
---|
102 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt |
---|
103 | |
---|
104 | USE kinds |
---|
105 | |
---|
106 | USE land_surface_model_mod, & |
---|
107 | ONLY: c_liq, c_liq_av, c_soil_av, c_veg, c_veg_av, ghf_eb, & |
---|
108 | ghf_eb_av, lai, lai_av, m_liq_eb, m_liq_eb_av, m_soil, & |
---|
109 | m_soil_av, nzb_soil, nzt_soil, qsws_eb, qsws_eb_av, & |
---|
110 | qsws_liq_eb, qsws_liq_eb_av, qsws_soil_eb, qsws_soil_eb_av, & |
---|
111 | qsws_veg_eb, qsws_veg_eb_av, shf_eb, shf_eb_av, r_a, r_a_av, & |
---|
112 | r_s, r_s_av, t_soil, t_soil_av |
---|
113 | |
---|
114 | USE particle_attributes, & |
---|
115 | ONLY: grid_particles, number_of_particles, particles, prt_count |
---|
116 | |
---|
117 | USE radiation_model_mod, & |
---|
118 | ONLY: rad_net, rad_net_av, rad_sw_in, rad_sw_in_av, rad_sw_out, & |
---|
119 | rad_sw_out_av, rad_lw_in, rad_lw_in_av, rad_lw_out, & |
---|
120 | rad_lw_out_av |
---|
121 | |
---|
122 | IMPLICIT NONE |
---|
123 | |
---|
124 | INTEGER(iwp) :: i !< |
---|
125 | INTEGER(iwp) :: ii !< |
---|
126 | INTEGER(iwp) :: j !< |
---|
127 | INTEGER(iwp) :: k !< |
---|
128 | INTEGER(iwp) :: n !< |
---|
129 | INTEGER(iwp) :: psi !< |
---|
130 | |
---|
131 | REAL(wp) :: mean_r !< |
---|
132 | REAL(wp) :: s_r2 !< |
---|
133 | REAL(wp) :: s_r3 !< |
---|
134 | |
---|
135 | CALL cpu_log (log_point(34),'sum_up_3d_data','start') |
---|
136 | |
---|
137 | ! |
---|
138 | !-- Allocate and initialize the summation arrays if called for the very first |
---|
139 | !-- time or the first time after average_3d_data has been called |
---|
140 | !-- (some or all of the arrays may have been already allocated |
---|
141 | !-- in read_3d_binary) |
---|
142 | IF ( average_count_3d == 0 ) THEN |
---|
143 | |
---|
144 | DO ii = 1, doav_n |
---|
145 | |
---|
146 | SELECT CASE ( TRIM( doav(ii) ) ) |
---|
147 | |
---|
148 | CASE ( 'c_liq*' ) |
---|
149 | IF ( .NOT. ALLOCATED( c_liq_av ) ) THEN |
---|
150 | ALLOCATE( c_liq_av(nysg:nyng,nxlg:nxrg) ) |
---|
151 | ENDIF |
---|
152 | c_liq_av = 0.0_wp |
---|
153 | |
---|
154 | CASE ( 'c_soil*' ) |
---|
155 | IF ( .NOT. ALLOCATED( c_soil_av ) ) THEN |
---|
156 | ALLOCATE( c_soil_av(nysg:nyng,nxlg:nxrg) ) |
---|
157 | ENDIF |
---|
158 | c_soil_av = 0.0_wp |
---|
159 | |
---|
160 | CASE ( 'c_veg*' ) |
---|
161 | IF ( .NOT. ALLOCATED( c_veg_av ) ) THEN |
---|
162 | ALLOCATE( c_veg_av(nysg:nyng,nxlg:nxrg) ) |
---|
163 | ENDIF |
---|
164 | c_veg_av = 0.0_wp |
---|
165 | |
---|
166 | CASE ( 'e' ) |
---|
167 | IF ( .NOT. ALLOCATED( e_av ) ) THEN |
---|
168 | ALLOCATE( e_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
169 | ENDIF |
---|
170 | e_av = 0.0_wp |
---|
171 | |
---|
172 | CASE ( 'ghf_eb*' ) |
---|
173 | IF ( .NOT. ALLOCATED( ghf_eb_av ) ) THEN |
---|
174 | ALLOCATE( ghf_eb_av(nysg:nyng,nxlg:nxrg) ) |
---|
175 | ENDIF |
---|
176 | ghf_eb_av = 0.0_wp |
---|
177 | |
---|
178 | CASE ( 'lai*' ) |
---|
179 | IF ( .NOT. ALLOCATED( lai_av ) ) THEN |
---|
180 | ALLOCATE( lai_av(nysg:nyng,nxlg:nxrg) ) |
---|
181 | ENDIF |
---|
182 | lai_av = 0.0_wp |
---|
183 | |
---|
184 | CASE ( 'lpt' ) |
---|
185 | IF ( .NOT. ALLOCATED( lpt_av ) ) THEN |
---|
186 | ALLOCATE( lpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
187 | ENDIF |
---|
188 | lpt_av = 0.0_wp |
---|
189 | |
---|
190 | CASE ( 'lwp*' ) |
---|
191 | IF ( .NOT. ALLOCATED( lwp_av ) ) THEN |
---|
192 | ALLOCATE( lwp_av(nysg:nyng,nxlg:nxrg) ) |
---|
193 | ENDIF |
---|
194 | lwp_av = 0.0_wp |
---|
195 | |
---|
196 | CASE ( 'm_liq_eb*' ) |
---|
197 | IF ( .NOT. ALLOCATED( m_liq_eb_av ) ) THEN |
---|
198 | ALLOCATE( m_liq_eb_av(nysg:nyng,nxlg:nxrg) ) |
---|
199 | ENDIF |
---|
200 | m_liq_eb_av = 0.0_wp |
---|
201 | |
---|
202 | CASE ( 'm_soil' ) |
---|
203 | IF ( .NOT. ALLOCATED( m_soil_av ) ) THEN |
---|
204 | ALLOCATE( m_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) ) |
---|
205 | ENDIF |
---|
206 | m_soil_av = 0.0_wp |
---|
207 | |
---|
208 | CASE ( 'nr' ) |
---|
209 | IF ( .NOT. ALLOCATED( nr_av ) ) THEN |
---|
210 | ALLOCATE( nr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
211 | ENDIF |
---|
212 | nr_av = 0.0_wp |
---|
213 | |
---|
214 | CASE ( 'p' ) |
---|
215 | IF ( .NOT. ALLOCATED( p_av ) ) THEN |
---|
216 | ALLOCATE( p_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
217 | ENDIF |
---|
218 | p_av = 0.0_wp |
---|
219 | |
---|
220 | CASE ( 'pc' ) |
---|
221 | IF ( .NOT. ALLOCATED( pc_av ) ) THEN |
---|
222 | ALLOCATE( pc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
223 | ENDIF |
---|
224 | pc_av = 0.0_wp |
---|
225 | |
---|
226 | CASE ( 'pr' ) |
---|
227 | IF ( .NOT. ALLOCATED( pr_av ) ) THEN |
---|
228 | ALLOCATE( pr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
229 | ENDIF |
---|
230 | pr_av = 0.0_wp |
---|
231 | |
---|
232 | CASE ( 'prr' ) |
---|
233 | IF ( .NOT. ALLOCATED( prr_av ) ) THEN |
---|
234 | ALLOCATE( prr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
235 | ENDIF |
---|
236 | prr_av = 0.0_wp |
---|
237 | |
---|
238 | CASE ( 'prr*' ) |
---|
239 | IF ( .NOT. ALLOCATED( precipitation_rate_av ) ) THEN |
---|
240 | ALLOCATE( precipitation_rate_av(nysg:nyng,nxlg:nxrg) ) |
---|
241 | ENDIF |
---|
242 | precipitation_rate_av = 0.0_wp |
---|
243 | |
---|
244 | CASE ( 'pt' ) |
---|
245 | IF ( .NOT. ALLOCATED( pt_av ) ) THEN |
---|
246 | ALLOCATE( pt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
247 | ENDIF |
---|
248 | pt_av = 0.0_wp |
---|
249 | |
---|
250 | CASE ( 'q' ) |
---|
251 | IF ( .NOT. ALLOCATED( q_av ) ) THEN |
---|
252 | ALLOCATE( q_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
253 | ENDIF |
---|
254 | q_av = 0.0_wp |
---|
255 | |
---|
256 | CASE ( 'qc' ) |
---|
257 | IF ( .NOT. ALLOCATED( qc_av ) ) THEN |
---|
258 | ALLOCATE( qc_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
259 | ENDIF |
---|
260 | qc_av = 0.0_wp |
---|
261 | |
---|
262 | CASE ( 'ql' ) |
---|
263 | IF ( .NOT. ALLOCATED( ql_av ) ) THEN |
---|
264 | ALLOCATE( ql_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
265 | ENDIF |
---|
266 | ql_av = 0.0_wp |
---|
267 | |
---|
268 | CASE ( 'ql_c' ) |
---|
269 | IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN |
---|
270 | ALLOCATE( ql_c_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
271 | ENDIF |
---|
272 | ql_c_av = 0.0_wp |
---|
273 | |
---|
274 | CASE ( 'ql_v' ) |
---|
275 | IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN |
---|
276 | ALLOCATE( ql_v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
277 | ENDIF |
---|
278 | ql_v_av = 0.0_wp |
---|
279 | |
---|
280 | CASE ( 'ql_vp' ) |
---|
281 | IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN |
---|
282 | ALLOCATE( ql_vp_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
283 | ENDIF |
---|
284 | ql_vp_av = 0.0_wp |
---|
285 | |
---|
286 | CASE ( 'qr' ) |
---|
287 | IF ( .NOT. ALLOCATED( qr_av ) ) THEN |
---|
288 | ALLOCATE( qr_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
289 | ENDIF |
---|
290 | qr_av = 0.0_wp |
---|
291 | |
---|
292 | CASE ( 'qsws*' ) |
---|
293 | IF ( .NOT. ALLOCATED( qsws_av ) ) THEN |
---|
294 | ALLOCATE( qsws_av(nysg:nyng,nxlg:nxrg) ) |
---|
295 | ENDIF |
---|
296 | qsws_av = 0.0_wp |
---|
297 | |
---|
298 | CASE ( 'qsws_eb*' ) |
---|
299 | IF ( .NOT. ALLOCATED( qsws_eb_av ) ) THEN |
---|
300 | ALLOCATE( qsws_eb_av(nysg:nyng,nxlg:nxrg) ) |
---|
301 | ENDIF |
---|
302 | qsws_eb_av = 0.0_wp |
---|
303 | |
---|
304 | CASE ( 'qsws_liq_eb*' ) |
---|
305 | IF ( .NOT. ALLOCATED( qsws_liq_eb_av ) ) THEN |
---|
306 | ALLOCATE( qsws_liq_eb_av(nysg:nyng,nxlg:nxrg) ) |
---|
307 | ENDIF |
---|
308 | qsws_liq_eb_av = 0.0_wp |
---|
309 | |
---|
310 | CASE ( 'qsws_soil_eb*' ) |
---|
311 | IF ( .NOT. ALLOCATED( qsws_soil_eb_av ) ) THEN |
---|
312 | ALLOCATE( qsws_soil_eb_av(nysg:nyng,nxlg:nxrg) ) |
---|
313 | ENDIF |
---|
314 | qsws_soil_eb_av = 0.0_wp |
---|
315 | |
---|
316 | CASE ( 'qsws_veg_eb*' ) |
---|
317 | IF ( .NOT. ALLOCATED( qsws_veg_eb_av ) ) THEN |
---|
318 | ALLOCATE( qsws_veg_eb_av(nysg:nyng,nxlg:nxrg) ) |
---|
319 | ENDIF |
---|
320 | qsws_veg_eb_av = 0.0_wp |
---|
321 | |
---|
322 | CASE ( 'qv' ) |
---|
323 | IF ( .NOT. ALLOCATED( qv_av ) ) THEN |
---|
324 | ALLOCATE( qv_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
325 | ENDIF |
---|
326 | qv_av = 0.0_wp |
---|
327 | |
---|
328 | CASE ( 'rad_net*' ) |
---|
329 | IF ( .NOT. ALLOCATED( rad_net_av ) ) THEN |
---|
330 | ALLOCATE( rad_net_av(nysg:nyng,nxlg:nxrg) ) |
---|
331 | ENDIF |
---|
332 | rad_net_av = 0.0_wp |
---|
333 | |
---|
334 | CASE ( 'rad_lw_in' ) |
---|
335 | IF ( .NOT. ALLOCATED( rad_lw_in_av ) ) THEN |
---|
336 | ALLOCATE( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
337 | ENDIF |
---|
338 | rad_lw_in_av = 0.0_wp |
---|
339 | |
---|
340 | CASE ( 'rad_lw_out' ) |
---|
341 | IF ( .NOT. ALLOCATED( rad_lw_out_av ) ) THEN |
---|
342 | ALLOCATE( rad_lw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
343 | ENDIF |
---|
344 | rad_lw_out_av = 0.0_wp |
---|
345 | |
---|
346 | CASE ( 'rad_sw_in' ) |
---|
347 | IF ( .NOT. ALLOCATED( rad_sw_in_av ) ) THEN |
---|
348 | ALLOCATE( rad_sw_in_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
349 | ENDIF |
---|
350 | rad_sw_in_av = 0.0_wp |
---|
351 | |
---|
352 | CASE ( 'rad_sw_out' ) |
---|
353 | IF ( .NOT. ALLOCATED( rad_sw_out_av ) ) THEN |
---|
354 | ALLOCATE( rad_sw_out_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
355 | ENDIF |
---|
356 | rad_sw_out_av = 0.0_wp |
---|
357 | |
---|
358 | CASE ( 'rho' ) |
---|
359 | IF ( .NOT. ALLOCATED( rho_av ) ) THEN |
---|
360 | ALLOCATE( rho_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
361 | ENDIF |
---|
362 | rho_av = 0.0_wp |
---|
363 | |
---|
364 | CASE ( 'r_a*' ) |
---|
365 | IF ( .NOT. ALLOCATED( r_a_av ) ) THEN |
---|
366 | ALLOCATE( r_a_av(nysg:nyng,nxlg:nxrg) ) |
---|
367 | ENDIF |
---|
368 | r_a_av = 0.0_wp |
---|
369 | |
---|
370 | CASE ( 'r_s*' ) |
---|
371 | IF ( .NOT. ALLOCATED( r_s_av ) ) THEN |
---|
372 | ALLOCATE( r_s_av(nysg:nyng,nxlg:nxrg) ) |
---|
373 | ENDIF |
---|
374 | r_s_av = 0.0_wp |
---|
375 | |
---|
376 | CASE ( 's' ) |
---|
377 | IF ( .NOT. ALLOCATED( s_av ) ) THEN |
---|
378 | ALLOCATE( s_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
379 | ENDIF |
---|
380 | s_av = 0.0_wp |
---|
381 | |
---|
382 | CASE ( 'sa' ) |
---|
383 | IF ( .NOT. ALLOCATED( sa_av ) ) THEN |
---|
384 | ALLOCATE( sa_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
385 | ENDIF |
---|
386 | sa_av = 0.0_wp |
---|
387 | |
---|
388 | CASE ( 'shf*' ) |
---|
389 | IF ( .NOT. ALLOCATED( shf_av ) ) THEN |
---|
390 | ALLOCATE( shf_av(nysg:nyng,nxlg:nxrg) ) |
---|
391 | ENDIF |
---|
392 | shf_av = 0.0_wp |
---|
393 | |
---|
394 | CASE ( 'shf_eb*' ) |
---|
395 | IF ( .NOT. ALLOCATED( shf_eb_av ) ) THEN |
---|
396 | ALLOCATE( shf_eb_av(nysg:nyng,nxlg:nxrg) ) |
---|
397 | ENDIF |
---|
398 | shf_eb_av = 0.0_wp |
---|
399 | |
---|
400 | CASE ( 't_soil' ) |
---|
401 | IF ( .NOT. ALLOCATED( t_soil_av ) ) THEN |
---|
402 | ALLOCATE( t_soil_av(nzb_soil:nzt_soil,nysg:nyng,nxlg:nxrg) ) |
---|
403 | ENDIF |
---|
404 | t_soil_av = 0.0_wp |
---|
405 | |
---|
406 | CASE ( 't*' ) |
---|
407 | IF ( .NOT. ALLOCATED( ts_av ) ) THEN |
---|
408 | ALLOCATE( ts_av(nysg:nyng,nxlg:nxrg) ) |
---|
409 | ENDIF |
---|
410 | ts_av = 0.0_wp |
---|
411 | |
---|
412 | CASE ( 'u' ) |
---|
413 | IF ( .NOT. ALLOCATED( u_av ) ) THEN |
---|
414 | ALLOCATE( u_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
415 | ENDIF |
---|
416 | u_av = 0.0_wp |
---|
417 | |
---|
418 | CASE ( 'u*' ) |
---|
419 | IF ( .NOT. ALLOCATED( us_av ) ) THEN |
---|
420 | ALLOCATE( us_av(nysg:nyng,nxlg:nxrg) ) |
---|
421 | ENDIF |
---|
422 | us_av = 0.0_wp |
---|
423 | |
---|
424 | CASE ( 'v' ) |
---|
425 | IF ( .NOT. ALLOCATED( v_av ) ) THEN |
---|
426 | ALLOCATE( v_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
427 | ENDIF |
---|
428 | v_av = 0.0_wp |
---|
429 | |
---|
430 | CASE ( 'vpt' ) |
---|
431 | IF ( .NOT. ALLOCATED( vpt_av ) ) THEN |
---|
432 | ALLOCATE( vpt_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
433 | ENDIF |
---|
434 | vpt_av = 0.0_wp |
---|
435 | |
---|
436 | CASE ( 'w' ) |
---|
437 | IF ( .NOT. ALLOCATED( w_av ) ) THEN |
---|
438 | ALLOCATE( w_av(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
439 | ENDIF |
---|
440 | w_av = 0.0_wp |
---|
441 | |
---|
442 | CASE ( 'z0*' ) |
---|
443 | IF ( .NOT. ALLOCATED( z0_av ) ) THEN |
---|
444 | ALLOCATE( z0_av(nysg:nyng,nxlg:nxrg) ) |
---|
445 | ENDIF |
---|
446 | z0_av = 0.0_wp |
---|
447 | |
---|
448 | CASE ( 'z0h*' ) |
---|
449 | IF ( .NOT. ALLOCATED( z0h_av ) ) THEN |
---|
450 | ALLOCATE( z0h_av(nysg:nyng,nxlg:nxrg) ) |
---|
451 | ENDIF |
---|
452 | z0h_av = 0.0_wp |
---|
453 | |
---|
454 | CASE DEFAULT |
---|
455 | ! |
---|
456 | !-- User-defined quantity |
---|
457 | CALL user_3d_data_averaging( 'allocate', doav(ii) ) |
---|
458 | |
---|
459 | END SELECT |
---|
460 | |
---|
461 | ENDDO |
---|
462 | |
---|
463 | ENDIF |
---|
464 | |
---|
465 | ! |
---|
466 | !-- Loop of all variables to be averaged. |
---|
467 | DO ii = 1, doav_n |
---|
468 | |
---|
469 | ! |
---|
470 | !-- Store the array chosen on the temporary array. |
---|
471 | SELECT CASE ( TRIM( doav(ii) ) ) |
---|
472 | |
---|
473 | CASE ( 'c_liq*' ) |
---|
474 | DO i = nxlg, nxrg |
---|
475 | DO j = nysg, nyng |
---|
476 | c_liq_av(j,i) = c_liq_av(j,i) |
---|
477 | ENDDO |
---|
478 | ENDDO |
---|
479 | |
---|
480 | CASE ( 'c_soil*' ) |
---|
481 | DO i = nxlg, nxrg |
---|
482 | DO j = nysg, nyng |
---|
483 | c_soil_av(j,i) = c_soil_av(j,i) + (1.0_wp - c_veg(j,i)) |
---|
484 | ENDDO |
---|
485 | ENDDO |
---|
486 | |
---|
487 | CASE ( 'c_veg*' ) |
---|
488 | DO i = nxlg, nxrg |
---|
489 | DO j = nysg, nyng |
---|
490 | c_veg_av(j,i) = c_veg_av(j,i) |
---|
491 | ENDDO |
---|
492 | ENDDO |
---|
493 | |
---|
494 | CASE ( 'e' ) |
---|
495 | DO i = nxlg, nxrg |
---|
496 | DO j = nysg, nyng |
---|
497 | DO k = nzb, nzt+1 |
---|
498 | e_av(k,j,i) = e_av(k,j,i) + e(k,j,i) |
---|
499 | ENDDO |
---|
500 | ENDDO |
---|
501 | ENDDO |
---|
502 | |
---|
503 | CASE ( 'ghf_eb*' ) |
---|
504 | DO i = nxlg, nxrg |
---|
505 | DO j = nysg, nyng |
---|
506 | ghf_eb_av(j,i) = ghf_eb_av(j,i) + ghf_eb(j,i) |
---|
507 | ENDDO |
---|
508 | ENDDO |
---|
509 | |
---|
510 | CASE ( 'lai*' ) |
---|
511 | DO i = nxlg, nxrg |
---|
512 | DO j = nysg, nyng |
---|
513 | lai_av(j,i) = lai_av(j,i) |
---|
514 | ENDDO |
---|
515 | ENDDO |
---|
516 | |
---|
517 | CASE ( 'lpt' ) |
---|
518 | DO i = nxlg, nxrg |
---|
519 | DO j = nysg, nyng |
---|
520 | DO k = nzb, nzt+1 |
---|
521 | lpt_av(k,j,i) = lpt_av(k,j,i) + pt(k,j,i) |
---|
522 | ENDDO |
---|
523 | ENDDO |
---|
524 | ENDDO |
---|
525 | |
---|
526 | CASE ( 'lwp*' ) |
---|
527 | DO i = nxlg, nxrg |
---|
528 | DO j = nysg, nyng |
---|
529 | lwp_av(j,i) = lwp_av(j,i) + SUM( ql(nzb:nzt,j,i) * & |
---|
530 | dzw(1:nzt+1) ) |
---|
531 | ENDDO |
---|
532 | ENDDO |
---|
533 | |
---|
534 | CASE ( 'm_liq_eb*' ) |
---|
535 | DO i = nxlg, nxrg |
---|
536 | DO j = nysg, nyng |
---|
537 | m_liq_eb_av(j,i) = m_liq_eb_av(j,i) + m_liq_eb(j,i) |
---|
538 | ENDDO |
---|
539 | ENDDO |
---|
540 | |
---|
541 | CASE ( 'm_soil' ) |
---|
542 | DO i = nxlg, nxrg |
---|
543 | DO j = nysg, nyng |
---|
544 | DO k = nzb_soil, nzt_soil |
---|
545 | m_soil_av(k,j,i) = m_soil_av(k,j,i) + m_soil(k,j,i) |
---|
546 | ENDDO |
---|
547 | ENDDO |
---|
548 | ENDDO |
---|
549 | |
---|
550 | CASE ( 'nr' ) |
---|
551 | DO i = nxlg, nxrg |
---|
552 | DO j = nysg, nyng |
---|
553 | DO k = nzb, nzt+1 |
---|
554 | nr_av(k,j,i) = nr_av(k,j,i) + nr(k,j,i) |
---|
555 | ENDDO |
---|
556 | ENDDO |
---|
557 | ENDDO |
---|
558 | |
---|
559 | CASE ( 'p' ) |
---|
560 | DO i = nxlg, nxrg |
---|
561 | DO j = nysg, nyng |
---|
562 | DO k = nzb, nzt+1 |
---|
563 | p_av(k,j,i) = p_av(k,j,i) + p(k,j,i) |
---|
564 | ENDDO |
---|
565 | ENDDO |
---|
566 | ENDDO |
---|
567 | |
---|
568 | CASE ( 'pc' ) |
---|
569 | DO i = nxl, nxr |
---|
570 | DO j = nys, nyn |
---|
571 | DO k = nzb, nzt+1 |
---|
572 | pc_av(k,j,i) = pc_av(k,j,i) + prt_count(k,j,i) |
---|
573 | ENDDO |
---|
574 | ENDDO |
---|
575 | ENDDO |
---|
576 | |
---|
577 | CASE ( 'pr' ) |
---|
578 | DO i = nxl, nxr |
---|
579 | DO j = nys, nyn |
---|
580 | DO k = nzb, nzt+1 |
---|
581 | number_of_particles = prt_count(k,j,i) |
---|
582 | IF ( number_of_particles <= 0 ) CYCLE |
---|
583 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
584 | s_r2 = 0.0_wp |
---|
585 | s_r3 = 0.0_wp |
---|
586 | |
---|
587 | DO n = 1, number_of_particles |
---|
588 | IF ( particles(n)%particle_mask ) THEN |
---|
589 | s_r2 = s_r2 + particles(n)%radius**2 * & |
---|
590 | particles(n)%weight_factor |
---|
591 | s_r3 = s_r3 + particles(n)%radius**3 * & |
---|
592 | particles(n)%weight_factor |
---|
593 | ENDIF |
---|
594 | ENDDO |
---|
595 | |
---|
596 | IF ( s_r2 > 0.0_wp ) THEN |
---|
597 | mean_r = s_r3 / s_r2 |
---|
598 | ELSE |
---|
599 | mean_r = 0.0_wp |
---|
600 | ENDIF |
---|
601 | pr_av(k,j,i) = pr_av(k,j,i) + mean_r |
---|
602 | ENDDO |
---|
603 | ENDDO |
---|
604 | ENDDO |
---|
605 | |
---|
606 | |
---|
607 | CASE ( 'pr*' ) |
---|
608 | DO i = nxlg, nxrg |
---|
609 | DO j = nysg, nyng |
---|
610 | precipitation_rate_av(j,i) = precipitation_rate_av(j,i) + & |
---|
611 | precipitation_rate(j,i) |
---|
612 | ENDDO |
---|
613 | ENDDO |
---|
614 | |
---|
615 | CASE ( 'pt' ) |
---|
616 | IF ( .NOT. cloud_physics ) THEN |
---|
617 | DO i = nxlg, nxrg |
---|
618 | DO j = nysg, nyng |
---|
619 | DO k = nzb, nzt+1 |
---|
620 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) |
---|
621 | ENDDO |
---|
622 | ENDDO |
---|
623 | ENDDO |
---|
624 | ELSE |
---|
625 | DO i = nxlg, nxrg |
---|
626 | DO j = nysg, nyng |
---|
627 | DO k = nzb, nzt+1 |
---|
628 | pt_av(k,j,i) = pt_av(k,j,i) + pt(k,j,i) + l_d_cp * & |
---|
629 | pt_d_t(k) * ql(k,j,i) |
---|
630 | ENDDO |
---|
631 | ENDDO |
---|
632 | ENDDO |
---|
633 | ENDIF |
---|
634 | |
---|
635 | CASE ( 'q' ) |
---|
636 | DO i = nxlg, nxrg |
---|
637 | DO j = nysg, nyng |
---|
638 | DO k = nzb, nzt+1 |
---|
639 | q_av(k,j,i) = q_av(k,j,i) + q(k,j,i) |
---|
640 | ENDDO |
---|
641 | ENDDO |
---|
642 | ENDDO |
---|
643 | |
---|
644 | CASE ( 'qc' ) |
---|
645 | DO i = nxlg, nxrg |
---|
646 | DO j = nysg, nyng |
---|
647 | DO k = nzb, nzt+1 |
---|
648 | qc_av(k,j,i) = qc_av(k,j,i) + qc(k,j,i) |
---|
649 | ENDDO |
---|
650 | ENDDO |
---|
651 | ENDDO |
---|
652 | |
---|
653 | CASE ( 'ql' ) |
---|
654 | DO i = nxlg, nxrg |
---|
655 | DO j = nysg, nyng |
---|
656 | DO k = nzb, nzt+1 |
---|
657 | ql_av(k,j,i) = ql_av(k,j,i) + ql(k,j,i) |
---|
658 | ENDDO |
---|
659 | ENDDO |
---|
660 | ENDDO |
---|
661 | |
---|
662 | CASE ( 'ql_c' ) |
---|
663 | DO i = nxlg, nxrg |
---|
664 | DO j = nysg, nyng |
---|
665 | DO k = nzb, nzt+1 |
---|
666 | ql_c_av(k,j,i) = ql_c_av(k,j,i) + ql_c(k,j,i) |
---|
667 | ENDDO |
---|
668 | ENDDO |
---|
669 | ENDDO |
---|
670 | |
---|
671 | CASE ( 'ql_v' ) |
---|
672 | DO i = nxlg, nxrg |
---|
673 | DO j = nysg, nyng |
---|
674 | DO k = nzb, nzt+1 |
---|
675 | ql_v_av(k,j,i) = ql_v_av(k,j,i) + ql_v(k,j,i) |
---|
676 | ENDDO |
---|
677 | ENDDO |
---|
678 | ENDDO |
---|
679 | |
---|
680 | CASE ( 'ql_vp' ) |
---|
681 | DO i = nxl, nxr |
---|
682 | DO j = nys, nyn |
---|
683 | DO k = nzb, nzt+1 |
---|
684 | number_of_particles = prt_count(k,j,i) |
---|
685 | IF ( number_of_particles <= 0 ) CYCLE |
---|
686 | particles => grid_particles(k,j,i)%particles(1:number_of_particles) |
---|
687 | DO n = 1, number_of_particles |
---|
688 | IF ( particles(n)%particle_mask ) THEN |
---|
689 | ql_vp_av(k,j,i) = ql_vp_av(k,j,i) + & |
---|
690 | particles(n)%weight_factor / & |
---|
691 | number_of_particles |
---|
692 | ENDIF |
---|
693 | ENDDO |
---|
694 | ENDDO |
---|
695 | ENDDO |
---|
696 | ENDDO |
---|
697 | |
---|
698 | CASE ( 'qr' ) |
---|
699 | DO i = nxlg, nxrg |
---|
700 | DO j = nysg, nyng |
---|
701 | DO k = nzb, nzt+1 |
---|
702 | qr_av(k,j,i) = qr_av(k,j,i) + qr(k,j,i) |
---|
703 | ENDDO |
---|
704 | ENDDO |
---|
705 | ENDDO |
---|
706 | |
---|
707 | CASE ( 'qsws*' ) |
---|
708 | DO i = nxlg, nxrg |
---|
709 | DO j = nysg, nyng |
---|
710 | qsws_av(j,i) = qsws_av(j,i) + qsws(j,i) |
---|
711 | ENDDO |
---|
712 | ENDDO |
---|
713 | |
---|
714 | CASE ( 'qsws_eb*' ) |
---|
715 | DO i = nxlg, nxrg |
---|
716 | DO j = nysg, nyng |
---|
717 | qsws_eb_av(j,i) = qsws_eb_av(j,i) + qsws_eb(j,i) |
---|
718 | ENDDO |
---|
719 | ENDDO |
---|
720 | |
---|
721 | CASE ( 'qsws_liq_eb*' ) |
---|
722 | DO i = nxlg, nxrg |
---|
723 | DO j = nysg, nyng |
---|
724 | qsws_liq_eb_av(j,i) = qsws_liq_eb_av(j,i) + qsws_liq_eb(j,i) |
---|
725 | ENDDO |
---|
726 | ENDDO |
---|
727 | |
---|
728 | CASE ( 'qsws_soil_eb*' ) |
---|
729 | DO i = nxlg, nxrg |
---|
730 | DO j = nysg, nyng |
---|
731 | qsws_soil_eb_av(j,i) = qsws_soil_eb_av(j,i) + qsws_soil_eb(j,i) |
---|
732 | ENDDO |
---|
733 | ENDDO |
---|
734 | |
---|
735 | CASE ( 'qsws_veg_eb*' ) |
---|
736 | DO i = nxlg, nxrg |
---|
737 | DO j = nysg, nyng |
---|
738 | qsws_veg_eb_av(j,i) = qsws_veg_eb_av(j,i) + qsws_veg_eb(j,i) |
---|
739 | ENDDO |
---|
740 | ENDDO |
---|
741 | |
---|
742 | CASE ( 'qv' ) |
---|
743 | DO i = nxlg, nxrg |
---|
744 | DO j = nysg, nyng |
---|
745 | DO k = nzb, nzt+1 |
---|
746 | qv_av(k,j,i) = qv_av(k,j,i) + q(k,j,i) - ql(k,j,i) |
---|
747 | ENDDO |
---|
748 | ENDDO |
---|
749 | ENDDO |
---|
750 | |
---|
751 | CASE ( 'rad_net*' ) |
---|
752 | DO i = nxlg, nxrg |
---|
753 | DO j = nysg, nyng |
---|
754 | rad_net_av(j,i) = rad_net_av(j,i) + rad_net(j,i) |
---|
755 | ENDDO |
---|
756 | ENDDO |
---|
757 | |
---|
758 | CASE ( 'rad_lw_in' ) |
---|
759 | DO i = nxlg, nxrg |
---|
760 | DO j = nysg, nyng |
---|
761 | DO k = nzb, nzt+1 |
---|
762 | rad_lw_in_av(k,j,i) = rad_lw_in_av(k,j,i) + rad_lw_in(k,j,i) |
---|
763 | ENDDO |
---|
764 | ENDDO |
---|
765 | ENDDO |
---|
766 | |
---|
767 | CASE ( 'rad_lw_out' ) |
---|
768 | DO i = nxlg, nxrg |
---|
769 | DO j = nysg, nyng |
---|
770 | DO k = nzb, nzt+1 |
---|
771 | rad_lw_out_av(k,j,i) = rad_lw_out_av(k,j,i) + rad_lw_out(k,j,i) |
---|
772 | ENDDO |
---|
773 | ENDDO |
---|
774 | ENDDO |
---|
775 | |
---|
776 | |
---|
777 | CASE ( 'rad_sw_in' ) |
---|
778 | DO i = nxlg, nxrg |
---|
779 | DO j = nysg, nyng |
---|
780 | DO k = nzb, nzt+1 |
---|
781 | rad_sw_in_av(k,j,i) = rad_sw_in_av(k,j,i) + rad_sw_in(k,j,i) |
---|
782 | ENDDO |
---|
783 | ENDDO |
---|
784 | ENDDO |
---|
785 | |
---|
786 | CASE ( 'rad_sw_out' ) |
---|
787 | DO i = nxlg, nxrg |
---|
788 | DO j = nysg, nyng |
---|
789 | DO k = nzb, nzt+1 |
---|
790 | rad_sw_out_av(k,j,i) = rad_sw_out_av(k,j,i) + rad_sw_out(k,j,i) |
---|
791 | ENDDO |
---|
792 | ENDDO |
---|
793 | ENDDO |
---|
794 | |
---|
795 | CASE ( 'r_a*' ) |
---|
796 | DO i = nxlg, nxrg |
---|
797 | DO j = nysg, nyng |
---|
798 | r_a_av(j,i) = r_a_av(j,i) + r_a(j,i) |
---|
799 | ENDDO |
---|
800 | ENDDO |
---|
801 | |
---|
802 | CASE ( 'r_s*' ) |
---|
803 | DO i = nxlg, nxrg |
---|
804 | DO j = nysg, nyng |
---|
805 | r_s_av(j,i) = r_s_av(j,i) + r_s(j,i) |
---|
806 | ENDDO |
---|
807 | ENDDO |
---|
808 | |
---|
809 | CASE ( 'rho' ) |
---|
810 | DO i = nxlg, nxrg |
---|
811 | DO j = nysg, nyng |
---|
812 | DO k = nzb, nzt+1 |
---|
813 | rho_av(k,j,i) = rho_av(k,j,i) + rho(k,j,i) |
---|
814 | ENDDO |
---|
815 | ENDDO |
---|
816 | ENDDO |
---|
817 | |
---|
818 | CASE ( 's' ) |
---|
819 | DO i = nxlg, nxrg |
---|
820 | DO j = nysg, nyng |
---|
821 | DO k = nzb, nzt+1 |
---|
822 | s_av(k,j,i) = s_av(k,j,i) + q(k,j,i) |
---|
823 | ENDDO |
---|
824 | ENDDO |
---|
825 | ENDDO |
---|
826 | |
---|
827 | CASE ( 'sa' ) |
---|
828 | DO i = nxlg, nxrg |
---|
829 | DO j = nysg, nyng |
---|
830 | DO k = nzb, nzt+1 |
---|
831 | sa_av(k,j,i) = sa_av(k,j,i) + sa(k,j,i) |
---|
832 | ENDDO |
---|
833 | ENDDO |
---|
834 | ENDDO |
---|
835 | |
---|
836 | CASE ( 'shf*' ) |
---|
837 | DO i = nxlg, nxrg |
---|
838 | DO j = nysg, nyng |
---|
839 | shf_av(j,i) = shf_av(j,i) + shf(j,i) |
---|
840 | ENDDO |
---|
841 | ENDDO |
---|
842 | |
---|
843 | CASE ( 'shf_eb*' ) |
---|
844 | DO i = nxlg, nxrg |
---|
845 | DO j = nysg, nyng |
---|
846 | shf_eb_av(j,i) = shf_eb_av(j,i) + shf_eb(j,i) |
---|
847 | ENDDO |
---|
848 | ENDDO |
---|
849 | |
---|
850 | CASE ( 't*' ) |
---|
851 | DO i = nxlg, nxrg |
---|
852 | DO j = nysg, nyng |
---|
853 | ts_av(j,i) = ts_av(j,i) + ts(j,i) |
---|
854 | ENDDO |
---|
855 | ENDDO |
---|
856 | |
---|
857 | CASE ( 't_soil' ) |
---|
858 | DO i = nxlg, nxrg |
---|
859 | DO j = nysg, nyng |
---|
860 | DO k = nzb_soil, nzt_soil |
---|
861 | t_soil_av(k,j,i) = t_soil_av(k,j,i) + t_soil(k,j,i) |
---|
862 | ENDDO |
---|
863 | ENDDO |
---|
864 | ENDDO |
---|
865 | |
---|
866 | CASE ( 'u' ) |
---|
867 | DO i = nxlg, nxrg |
---|
868 | DO j = nysg, nyng |
---|
869 | DO k = nzb, nzt+1 |
---|
870 | u_av(k,j,i) = u_av(k,j,i) + u(k,j,i) |
---|
871 | ENDDO |
---|
872 | ENDDO |
---|
873 | ENDDO |
---|
874 | |
---|
875 | CASE ( 'u*' ) |
---|
876 | DO i = nxlg, nxrg |
---|
877 | DO j = nysg, nyng |
---|
878 | us_av(j,i) = us_av(j,i) + us(j,i) |
---|
879 | ENDDO |
---|
880 | ENDDO |
---|
881 | |
---|
882 | CASE ( 'v' ) |
---|
883 | DO i = nxlg, nxrg |
---|
884 | DO j = nysg, nyng |
---|
885 | DO k = nzb, nzt+1 |
---|
886 | v_av(k,j,i) = v_av(k,j,i) + v(k,j,i) |
---|
887 | ENDDO |
---|
888 | ENDDO |
---|
889 | ENDDO |
---|
890 | |
---|
891 | CASE ( 'vpt' ) |
---|
892 | DO i = nxlg, nxrg |
---|
893 | DO j = nysg, nyng |
---|
894 | DO k = nzb, nzt+1 |
---|
895 | vpt_av(k,j,i) = vpt_av(k,j,i) + vpt(k,j,i) |
---|
896 | ENDDO |
---|
897 | ENDDO |
---|
898 | ENDDO |
---|
899 | |
---|
900 | CASE ( 'w' ) |
---|
901 | DO i = nxlg, nxrg |
---|
902 | DO j = nysg, nyng |
---|
903 | DO k = nzb, nzt+1 |
---|
904 | w_av(k,j,i) = w_av(k,j,i) + w(k,j,i) |
---|
905 | ENDDO |
---|
906 | ENDDO |
---|
907 | ENDDO |
---|
908 | |
---|
909 | CASE ( 'z0*' ) |
---|
910 | DO i = nxlg, nxrg |
---|
911 | DO j = nysg, nyng |
---|
912 | z0_av(j,i) = z0_av(j,i) + z0(j,i) |
---|
913 | ENDDO |
---|
914 | ENDDO |
---|
915 | |
---|
916 | CASE ( 'z0h*' ) |
---|
917 | DO i = nxlg, nxrg |
---|
918 | DO j = nysg, nyng |
---|
919 | z0h_av(j,i) = z0h_av(j,i) + z0h(j,i) |
---|
920 | ENDDO |
---|
921 | ENDDO |
---|
922 | |
---|
923 | CASE DEFAULT |
---|
924 | ! |
---|
925 | !-- User-defined quantity |
---|
926 | CALL user_3d_data_averaging( 'sum', doav(ii) ) |
---|
927 | |
---|
928 | END SELECT |
---|
929 | |
---|
930 | ENDDO |
---|
931 | |
---|
932 | CALL cpu_log( log_point(34), 'sum_up_3d_data', 'stop' ) |
---|
933 | |
---|
934 | |
---|
935 | END SUBROUTINE sum_up_3d_data |
---|