1 | !> @file flow_statistics.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 terms of the GNU General |
---|
6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
7 | ! (at your option) any later version. |
---|
8 | ! |
---|
9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
11 | ! Public License for more details. |
---|
12 | ! |
---|
13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
14 | ! <http://www.gnu.org/licenses/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ------------------ |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: flow_statistics.f90 4672 2020-09-09 21:27:32Z suehring $ |
---|
26 | ! OpenACC bugfix |
---|
27 | ! |
---|
28 | ! 4671 2020-09-09 20:27:58Z pavelkrc |
---|
29 | ! Implementation of downward facing USM and LSM surfaces |
---|
30 | ! |
---|
31 | ! 4646 2020-08-24 16:02:40Z raasch |
---|
32 | ! file re-formatted to follow the PALM coding standard |
---|
33 | ! |
---|
34 | ! 4581 2020-06-29 08:49:58Z suehring |
---|
35 | ! Formatting adjustment |
---|
36 | ! |
---|
37 | ! 4551 2020-06-02 10:22:25Z suehring |
---|
38 | ! Bugfix in summation for statistical regions |
---|
39 | ! |
---|
40 | ! 4521 2020-05-06 11:39:49Z schwenkel |
---|
41 | ! Rename variable |
---|
42 | ! |
---|
43 | ! 4502 2020-04-17 16:14:16Z schwenkel |
---|
44 | ! Implementation of ice microphysics |
---|
45 | ! |
---|
46 | ! 4472 2020-03-24 12:21:00Z Giersch |
---|
47 | ! Calculations of the Kolmogorov lengt scale eta implemented |
---|
48 | ! |
---|
49 | ! 4464 2020-03-17 11:08:46Z Giersch |
---|
50 | ! Reset last change (r4463) |
---|
51 | ! |
---|
52 | ! 4463 2020-03-17 09:27:36Z Giersch |
---|
53 | ! Calculate horizontally averaged profiles of all velocity components at the same place |
---|
54 | ! |
---|
55 | ! 4444 2020-03-05 15:59:50Z raasch |
---|
56 | ! bugfix: cpp-directives for serial mode added |
---|
57 | ! |
---|
58 | ! 4442 2020-03-04 19:21:13Z suehring |
---|
59 | ! Change order of dimension in surface array %frac to allow for better vectorization. |
---|
60 | ! |
---|
61 | ! 4441 2020-03-04 19:20:35Z suehring |
---|
62 | ! Introduction of wall_flags_total_0, which currently sets bits based on static topography |
---|
63 | ! information used in wall_flags_static_0 |
---|
64 | ! |
---|
65 | ! 4329 2019-12-10 15:46:36Z motisi |
---|
66 | ! Renamed wall_flags_0 to wall_flags_static_0 |
---|
67 | ! |
---|
68 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
69 | ! Corrected "Former revisions" section |
---|
70 | ! |
---|
71 | ! 4131 2019-08-02 11:06:18Z monakurppa |
---|
72 | ! Allow profile output for salsa variables. |
---|
73 | ! |
---|
74 | ! 4039 2019-06-18 10:32:41Z suehring |
---|
75 | ! Correct conversion to kinematic scalar fluxes in case of pw-scheme and statistic regions |
---|
76 | ! |
---|
77 | ! 3828 2019-03-27 19:36:23Z raasch |
---|
78 | ! unused variables removed |
---|
79 | ! |
---|
80 | ! 3676 2019-01-16 15:07:05Z knoop |
---|
81 | ! Bugfix, terminate OMP Parallel block |
---|
82 | ! |
---|
83 | ! Revision 1.1 1997/08/11 06:15:17 raasch |
---|
84 | ! Initial revision |
---|
85 | ! |
---|
86 | ! |
---|
87 | ! Description: |
---|
88 | ! ------------ |
---|
89 | !> Compute average profiles and further average flow quantities for the different user-defined |
---|
90 | !> (sub-)regions. The region indexed 0 is the total model domain. |
---|
91 | !> |
---|
92 | !> @note For simplicity, nzb_s_inner and nzb_diff_s_inner are used as a lower vertical index for |
---|
93 | !> k-loops for all variables, although strictly speaking the k-loops would have to be split |
---|
94 | !> up according to the staggered grid. However, this implies no error since staggered velocity |
---|
95 | !> components are zero at the walls and inside buildings. |
---|
96 | !--------------------------------------------------------------------------------------------------! |
---|
97 | SUBROUTINE flow_statistics |
---|
98 | |
---|
99 | |
---|
100 | USE arrays_3d, & |
---|
101 | ONLY: ddzu, ddzw, d_exner, e, heatflux_output_conversion, hyp, km, kh, & |
---|
102 | momentumflux_output_conversion, nc, ni, nr, p, prho, prr, pt, q, qc, qi, ql, qr, & |
---|
103 | rho_air, rho_air_zw, rho_ocean, s, sa, u, ug, v, vg, vpt, w, w_subs, & |
---|
104 | waterflux_output_conversion, zw |
---|
105 | |
---|
106 | USE basic_constants_and_equations_mod, & |
---|
107 | ONLY: g, lv_d_cp |
---|
108 | |
---|
109 | USE bulk_cloud_model_mod, & |
---|
110 | ONLY: bulk_cloud_model, microphysics_morrison, microphysics_seifert, microphysics_ice_phase |
---|
111 | |
---|
112 | USE chem_modules, & |
---|
113 | ONLY: max_pr_cs |
---|
114 | |
---|
115 | USE control_parameters, & |
---|
116 | ONLY: air_chemistry, average_count_pr, cloud_droplets, do_sum, dt_3d, humidity, & |
---|
117 | initializing_actions, kolmogorov_length_scale, land_surface, large_scale_forcing, & |
---|
118 | large_scale_subsidence, max_pr_salsa, max_pr_user, message_string, neutral, & |
---|
119 | ocean_mode, passive_scalar, salsa, simulated_time, simulated_time_at_begin, & |
---|
120 | use_subsidence_tendencies, use_surface_fluxes, use_top_fluxes, ws_scheme_mom, & |
---|
121 | ws_scheme_sca |
---|
122 | |
---|
123 | USE cpulog, & |
---|
124 | ONLY: cpu_log, log_point |
---|
125 | |
---|
126 | USE grid_variables, & |
---|
127 | ONLY: ddx, ddy |
---|
128 | |
---|
129 | USE indices, & |
---|
130 | ONLY: ngp_2dh, ngp_2dh_s_inner, ngp_3d, ngp_3d_inner, nxl, nxr, nyn, nys, nzb, nzt, & |
---|
131 | topo_min_level, wall_flags_total_0 |
---|
132 | |
---|
133 | #if defined( __parallel ) |
---|
134 | USE indices, & |
---|
135 | ONLY: ngp_sums, ngp_sums_ls |
---|
136 | #endif |
---|
137 | |
---|
138 | USE kinds |
---|
139 | |
---|
140 | USE land_surface_model_mod, & |
---|
141 | ONLY: m_soil_h, nzb_soil, nzt_soil, t_soil_h |
---|
142 | |
---|
143 | USE lsf_nudging_mod, & |
---|
144 | ONLY: td_lsa_lpt, td_lsa_q, td_sub_lpt, td_sub_q, time_vert |
---|
145 | |
---|
146 | USE module_interface, & |
---|
147 | ONLY: module_interface_statistics |
---|
148 | |
---|
149 | USE netcdf_interface, & |
---|
150 | ONLY: dots_rad, dots_soil, dots_max |
---|
151 | |
---|
152 | USE pegrid |
---|
153 | |
---|
154 | USE radiation_model_mod, & |
---|
155 | ONLY: radiation, radiation_scheme, & |
---|
156 | rad_lw_in, rad_lw_out, rad_lw_cs_hr, rad_lw_hr, & |
---|
157 | rad_sw_in, rad_sw_out, rad_sw_cs_hr, rad_sw_hr |
---|
158 | |
---|
159 | USE statistics |
---|
160 | |
---|
161 | USE surface_mod, & |
---|
162 | ONLY : surf_def_h, surf_lsm_h, surf_usm_h |
---|
163 | |
---|
164 | |
---|
165 | IMPLICIT NONE |
---|
166 | |
---|
167 | INTEGER(iwp) :: i !< |
---|
168 | INTEGER(iwp) :: j !< |
---|
169 | INTEGER(iwp) :: k !< |
---|
170 | INTEGER(iwp) :: ki !< |
---|
171 | INTEGER(iwp) :: k_surface_level !< |
---|
172 | INTEGER(iwp) :: m !< loop variable over all horizontal wall elements |
---|
173 | INTEGER(iwp) :: l !< loop variable over surface facing -- up- or downward-facing |
---|
174 | INTEGER(iwp) :: nt !< |
---|
175 | !$ INTEGER(iwp) :: omp_get_thread_num !< |
---|
176 | INTEGER(iwp) :: sr !< |
---|
177 | INTEGER(iwp) :: tn !< |
---|
178 | |
---|
179 | LOGICAL :: first !< |
---|
180 | |
---|
181 | REAL(wp) :: dissipation !< dissipation rate |
---|
182 | REAL(wp) :: dptdz_threshold !< |
---|
183 | REAL(wp) :: du_dx !< Derivative of u fluctuations with respect to x |
---|
184 | REAL(wp) :: du_dy !< Derivative of u fluctuations with respect to y |
---|
185 | REAL(wp) :: du_dz !< Derivative of u fluctuations with respect to z |
---|
186 | REAL(wp) :: dv_dx !< Derivative of v fluctuations with respect to x |
---|
187 | REAL(wp) :: dv_dy !< Derivative of v fluctuations with respect to y |
---|
188 | REAL(wp) :: dv_dz !< Derivative of v fluctuations with respect to z |
---|
189 | REAL(wp) :: dw_dx !< Derivative of w fluctuations with respect to x |
---|
190 | REAL(wp) :: dw_dy !< Derivative of w fluctuations with respect to y |
---|
191 | REAL(wp) :: dw_dz !< Derivative of w fluctuations with respect to z |
---|
192 | REAL(wp) :: eta !< Kolmogorov length scale |
---|
193 | REAL(wp) :: fac !< |
---|
194 | REAL(wp) :: flag !< |
---|
195 | REAL(wp) :: height !< |
---|
196 | REAL(wp) :: pts !< |
---|
197 | REAL(wp) :: s11 !< fluctuating rate-of-strain tensor component 11 |
---|
198 | REAL(wp) :: s21 !< fluctuating rate-of-strain tensor component 21 |
---|
199 | REAL(wp) :: s31 !< fluctuating rate-of-strain tensor component 31 |
---|
200 | REAL(wp) :: s12 !< fluctuating rate-of-strain tensor component 12 |
---|
201 | REAL(wp) :: s22 !< fluctuating rate-of-strain tensor component 22 |
---|
202 | REAL(wp) :: s32 !< fluctuating rate-of-strain tensor component 32 |
---|
203 | REAL(wp) :: s13 !< fluctuating rate-of-strain tensor component 13 |
---|
204 | REAL(wp) :: s23 !< fluctuating rate-of-strain tensor component 23 |
---|
205 | REAL(wp) :: s33 !< fluctuating rate-of-strain tensor component 33 |
---|
206 | REAL(wp) :: sums_l_etot !< |
---|
207 | REAL(wp) :: ust !< |
---|
208 | REAL(wp) :: ust2 !< |
---|
209 | REAL(wp) :: u2 !< |
---|
210 | REAL(wp) :: vst !< |
---|
211 | REAL(wp) :: vst2 !< |
---|
212 | REAL(wp) :: v2 !< |
---|
213 | REAL(wp) :: w2 !< |
---|
214 | |
---|
215 | REAL(wp) :: dptdz(nzb+1:nzt+1) !< |
---|
216 | REAL(wp) :: sums_ll(nzb:nzt+1,2) !< |
---|
217 | |
---|
218 | |
---|
219 | CALL cpu_log( log_point(10), 'flow_statistics', 'start' ) |
---|
220 | |
---|
221 | |
---|
222 | ! |
---|
223 | !-- To be on the safe side, check whether flow_statistics has already been called once after the |
---|
224 | !-- current time step. |
---|
225 | IF ( flow_statistics_called ) THEN |
---|
226 | |
---|
227 | message_string = 'flow_statistics is called two times within one ' // 'timestep' |
---|
228 | CALL message( 'flow_statistics', 'PA0190', 1, 2, 0, 6, 0 ) |
---|
229 | |
---|
230 | ENDIF |
---|
231 | |
---|
232 | ! |
---|
233 | !-- Compute statistics for each (sub-)region |
---|
234 | DO sr = 0, statistic_regions |
---|
235 | |
---|
236 | ! |
---|
237 | !-- Initialize (local) summation array |
---|
238 | sums_l = 0.0_wp |
---|
239 | #ifdef _OPENACC |
---|
240 | !$ACC KERNELS PRESENT(sums_l) |
---|
241 | sums_l = 0.0_wp |
---|
242 | !$ACC END KERNELS |
---|
243 | #endif |
---|
244 | |
---|
245 | ! |
---|
246 | !-- Store sums that have been computed in other subroutines in summation array |
---|
247 | sums_l(:,11,:) = sums_l_l(:,sr,:) ! mixing length from diffusivities |
---|
248 | !-- WARNING: next line still has to be adjusted for OpenMP |
---|
249 | sums_l(:,21,0) = sums_wsts_bc_l(:,sr) * & |
---|
250 | heatflux_output_conversion ! heat flux from advec_s_bc |
---|
251 | sums_l(nzb+9,pr_palm,0) = sums_divold_l(sr) ! old divergence from pres |
---|
252 | sums_l(nzb+10,pr_palm,0) = sums_divnew_l(sr) ! new divergence from pres |
---|
253 | |
---|
254 | ! |
---|
255 | !-- When calcuating horizontally-averaged total (resolved- plus subgrid-scale) vertical fluxes |
---|
256 | !-- and velocity variances by using commonly-applied Reynolds-based methods |
---|
257 | !-- ( e.g. <w'pt'> = (w-<w>)*(pt-<pt>) ) in combination with the 5th order advection scheme, |
---|
258 | !-- pronounced artificial kinks could be observed in the vertical profiles near the surface. |
---|
259 | !-- Please note: these kinks were not related to the model truth, i.e. these kinks are just |
---|
260 | !-- related to an evaluation problem. |
---|
261 | !-- In order avoid these kinks, vertical fluxes and horizontal as well vertical velocity |
---|
262 | !-- variances are calculated directly within the advection routines, according to the numerical |
---|
263 | !-- discretization, to evaluate the statistical quantities as they will appear within the |
---|
264 | !-- prognostic equations. |
---|
265 | !-- Copy the turbulent quantities, evaluated in the advection routines to the local array |
---|
266 | !-- sums_l() for further computations. |
---|
267 | IF ( ws_scheme_mom .AND. sr == 0 ) THEN |
---|
268 | |
---|
269 | ! |
---|
270 | !-- According to the Neumann bc for the horizontal velocity components, the corresponding |
---|
271 | !-- fluxes has to satisfiy the same bc. |
---|
272 | IF ( ocean_mode ) THEN |
---|
273 | sums_us2_ws_l(nzt+1,:) = sums_us2_ws_l(nzt,:) |
---|
274 | sums_vs2_ws_l(nzt+1,:) = sums_vs2_ws_l(nzt,:) |
---|
275 | ENDIF |
---|
276 | |
---|
277 | DO i = 0, threads_per_task-1 |
---|
278 | ! |
---|
279 | !-- Swap the turbulent quantities evaluated in advec_ws. |
---|
280 | sums_l(:,13,i) = sums_wsus_ws_l(:,i) * momentumflux_output_conversion ! w*u* |
---|
281 | sums_l(:,15,i) = sums_wsvs_ws_l(:,i) * momentumflux_output_conversion ! w*v* |
---|
282 | sums_l(:,30,i) = sums_us2_ws_l(:,i) ! u*2 |
---|
283 | sums_l(:,31,i) = sums_vs2_ws_l(:,i) ! v*2 |
---|
284 | sums_l(:,32,i) = sums_ws2_ws_l(:,i) ! w*2 |
---|
285 | sums_l(:,34,i) = sums_l(:,34,i) + 0.5_wp * & |
---|
286 | ( sums_us2_ws_l(:,i) + sums_vs2_ws_l(:,i) + sums_ws2_ws_l(:,i) ) ! e* |
---|
287 | ENDDO |
---|
288 | |
---|
289 | ENDIF |
---|
290 | |
---|
291 | IF ( ws_scheme_sca .AND. sr == 0 ) THEN |
---|
292 | |
---|
293 | DO i = 0, threads_per_task-1 |
---|
294 | sums_l(:,17,i) = sums_wspts_ws_l(:,i) & |
---|
295 | * heatflux_output_conversion ! w*pt* |
---|
296 | IF ( ocean_mode ) sums_l(:,66,i) = sums_wssas_ws_l(:,i) ! w*sa* |
---|
297 | IF ( humidity ) sums_l(:,49,i) = sums_wsqs_ws_l(:,i) & |
---|
298 | * waterflux_output_conversion ! w*q* |
---|
299 | IF ( passive_scalar ) sums_l(:,114,i) = sums_wsss_ws_l(:,i) ! w*s* |
---|
300 | ENDDO |
---|
301 | |
---|
302 | ENDIF |
---|
303 | ! |
---|
304 | !-- Horizontally averaged profiles of horizontal velocities and temperature. |
---|
305 | !-- They must have been computed before, because they are already required for other horizontal |
---|
306 | !-- averages. |
---|
307 | tn = 0 |
---|
308 | !$OMP PARALLEL PRIVATE( i, j, k, tn, flag ) |
---|
309 | !$ tn = omp_get_thread_num() |
---|
310 | !$OMP DO |
---|
311 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag) & |
---|
312 | !$ACC PRESENT(wall_flags_total_0, u, v, pt, rmask, sums_l) |
---|
313 | DO i = nxl, nxr |
---|
314 | DO j = nys, nyn |
---|
315 | DO k = nzb, nzt+1 |
---|
316 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
317 | !$ACC ATOMIC |
---|
318 | sums_l(k,1,tn) = sums_l(k,1,tn) + u(k,j,i) * rmask(j,i,sr) * flag |
---|
319 | !$ACC ATOMIC |
---|
320 | sums_l(k,2,tn) = sums_l(k,2,tn) + v(k,j,i) * rmask(j,i,sr) * flag |
---|
321 | !$ACC ATOMIC |
---|
322 | sums_l(k,4,tn) = sums_l(k,4,tn) + pt(k,j,i) * rmask(j,i,sr) * flag |
---|
323 | ENDDO |
---|
324 | ENDDO |
---|
325 | ENDDO |
---|
326 | !$ACC UPDATE HOST(sums_l(:,1,tn), sums_l(:,2,tn), sums_l(:,4,tn)) |
---|
327 | |
---|
328 | ! |
---|
329 | !-- Horizontally averaged profile of salinity |
---|
330 | IF ( ocean_mode ) THEN |
---|
331 | !$OMP DO |
---|
332 | DO i = nxl, nxr |
---|
333 | DO j = nys, nyn |
---|
334 | DO k = nzb, nzt+1 |
---|
335 | sums_l(k,23,tn) = sums_l(k,23,tn) + sa(k,j,i) & |
---|
336 | * rmask(j,i,sr) & |
---|
337 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
338 | BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
339 | ENDDO |
---|
340 | ENDDO |
---|
341 | ENDDO |
---|
342 | ENDIF |
---|
343 | |
---|
344 | ! |
---|
345 | !-- Horizontally averaged profiles of virtual potential temperature, total water content, water |
---|
346 | !-- vapor mixing ratio and liquid water potential temperature |
---|
347 | IF ( humidity ) THEN |
---|
348 | !$OMP DO |
---|
349 | DO i = nxl, nxr |
---|
350 | DO j = nys, nyn |
---|
351 | DO k = nzb, nzt+1 |
---|
352 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
353 | sums_l(k,44,tn) = sums_l(k,44,tn) + vpt(k,j,i) * rmask(j,i,sr) * flag |
---|
354 | sums_l(k,41,tn) = sums_l(k,41,tn) + q(k,j,i) * rmask(j,i,sr) * flag |
---|
355 | ENDDO |
---|
356 | ENDDO |
---|
357 | ENDDO |
---|
358 | IF ( bulk_cloud_model ) THEN |
---|
359 | !$OMP DO |
---|
360 | DO i = nxl, nxr |
---|
361 | DO j = nys, nyn |
---|
362 | DO k = nzb, nzt+1 |
---|
363 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
364 | sums_l(k,42,tn) = sums_l(k,42,tn) + & |
---|
365 | ( q(k,j,i) - ql(k,j,i) ) * rmask(j,i,sr) * flag |
---|
366 | sums_l(k,43,tn) = sums_l(k,43,tn) + ( & |
---|
367 | pt(k,j,i) + lv_d_cp * d_exner(k) * ql(k,j,i) & |
---|
368 | ) * rmask(j,i,sr) * flag |
---|
369 | ENDDO |
---|
370 | ENDDO |
---|
371 | ENDDO |
---|
372 | ENDIF |
---|
373 | ENDIF |
---|
374 | |
---|
375 | ! |
---|
376 | !-- Horizontally averaged profiles of passive scalar |
---|
377 | IF ( passive_scalar ) THEN |
---|
378 | !$OMP DO |
---|
379 | DO i = nxl, nxr |
---|
380 | DO j = nys, nyn |
---|
381 | DO k = nzb, nzt+1 |
---|
382 | sums_l(k,115,tn) = sums_l(k,115,tn) + s(k,j,i) & |
---|
383 | * rmask(j,i,sr) & |
---|
384 | * MERGE( 1.0_wp, 0.0_wp, & |
---|
385 | BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
386 | ENDDO |
---|
387 | ENDDO |
---|
388 | ENDDO |
---|
389 | ENDIF |
---|
390 | !$OMP END PARALLEL |
---|
391 | ! |
---|
392 | !-- Summation of thread sums |
---|
393 | IF ( threads_per_task > 1 ) THEN |
---|
394 | DO i = 1, threads_per_task-1 |
---|
395 | sums_l(:,1,0) = sums_l(:,1,0) + sums_l(:,1,i) |
---|
396 | sums_l(:,2,0) = sums_l(:,2,0) + sums_l(:,2,i) |
---|
397 | sums_l(:,4,0) = sums_l(:,4,0) + sums_l(:,4,i) |
---|
398 | IF ( ocean_mode ) THEN |
---|
399 | sums_l(:,23,0) = sums_l(:,23,0) + sums_l(:,23,i) |
---|
400 | ENDIF |
---|
401 | IF ( humidity ) THEN |
---|
402 | sums_l(:,41,0) = sums_l(:,41,0) + sums_l(:,41,i) |
---|
403 | sums_l(:,44,0) = sums_l(:,44,0) + sums_l(:,44,i) |
---|
404 | IF ( bulk_cloud_model ) THEN |
---|
405 | sums_l(:,42,0) = sums_l(:,42,0) + sums_l(:,42,i) |
---|
406 | sums_l(:,43,0) = sums_l(:,43,0) + sums_l(:,43,i) |
---|
407 | ENDIF |
---|
408 | ENDIF |
---|
409 | IF ( passive_scalar ) THEN |
---|
410 | sums_l(:,115,0) = sums_l(:,115,0) + sums_l(:,115,i) |
---|
411 | ENDIF |
---|
412 | ENDDO |
---|
413 | ENDIF |
---|
414 | |
---|
415 | #if defined( __parallel ) |
---|
416 | ! |
---|
417 | !-- Compute total sum from local sums |
---|
418 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
419 | CALL MPI_ALLREDUCE( sums_l(nzb,1,0), sums(nzb,1), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d, & |
---|
420 | ierr ) |
---|
421 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
422 | CALL MPI_ALLREDUCE( sums_l(nzb,2,0), sums(nzb,2), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d, & |
---|
423 | ierr ) |
---|
424 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
425 | CALL MPI_ALLREDUCE( sums_l(nzb,4,0), sums(nzb,4), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d, & |
---|
426 | ierr ) |
---|
427 | IF ( ocean_mode ) THEN |
---|
428 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
429 | CALL MPI_ALLREDUCE( sums_l(nzb,23,0), sums(nzb,23), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d,& |
---|
430 | ierr ) |
---|
431 | ENDIF |
---|
432 | IF ( humidity ) THEN |
---|
433 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
434 | CALL MPI_ALLREDUCE( sums_l(nzb,44,0), sums(nzb,44), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d,& |
---|
435 | ierr ) |
---|
436 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
437 | CALL MPI_ALLREDUCE( sums_l(nzb,41,0), sums(nzb,41), nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d,& |
---|
438 | ierr ) |
---|
439 | IF ( bulk_cloud_model ) THEN |
---|
440 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
441 | CALL MPI_ALLREDUCE( sums_l(nzb,42,0), sums(nzb,42), nzt+2-nzb, MPI_REAL, MPI_SUM, & |
---|
442 | comm2d, ierr ) |
---|
443 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
444 | CALL MPI_ALLREDUCE( sums_l(nzb,43,0), sums(nzb,43), nzt+2-nzb, MPI_REAL, MPI_SUM, & |
---|
445 | comm2d, ierr ) |
---|
446 | ENDIF |
---|
447 | ENDIF |
---|
448 | |
---|
449 | IF ( passive_scalar ) THEN |
---|
450 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
451 | CALL MPI_ALLREDUCE( sums_l(nzb,115,0), sums(nzb,115), nzt+2-nzb, MPI_REAL, MPI_SUM, & |
---|
452 | comm2d, ierr ) |
---|
453 | ENDIF |
---|
454 | #else |
---|
455 | sums(:,1) = sums_l(:,1,0) |
---|
456 | sums(:,2) = sums_l(:,2,0) |
---|
457 | sums(:,4) = sums_l(:,4,0) |
---|
458 | IF ( ocean_mode ) sums(:,23) = sums_l(:,23,0) |
---|
459 | IF ( humidity ) THEN |
---|
460 | sums(:,44) = sums_l(:,44,0) |
---|
461 | sums(:,41) = sums_l(:,41,0) |
---|
462 | IF ( bulk_cloud_model ) THEN |
---|
463 | sums(:,42) = sums_l(:,42,0) |
---|
464 | sums(:,43) = sums_l(:,43,0) |
---|
465 | ENDIF |
---|
466 | ENDIF |
---|
467 | IF ( passive_scalar ) sums(:,115) = sums_l(:,115,0) |
---|
468 | #endif |
---|
469 | |
---|
470 | ! |
---|
471 | !-- Final values are obtained by division by the total number of grid points used for summation. |
---|
472 | !-- After that store profiles. |
---|
473 | sums(:,1) = sums(:,1) / ngp_2dh(sr) |
---|
474 | sums(:,2) = sums(:,2) / ngp_2dh(sr) |
---|
475 | sums(:,4) = sums(:,4) / ngp_2dh_s_inner(:,sr) |
---|
476 | hom(:,1,1,sr) = sums(:,1) ! u |
---|
477 | hom(:,1,2,sr) = sums(:,2) ! v |
---|
478 | hom(:,1,4,sr) = sums(:,4) ! pt |
---|
479 | !$ACC UPDATE DEVICE(hom(:,1,1,sr), hom(:,1,2,sr), hom(:,1,4,sr)) |
---|
480 | |
---|
481 | |
---|
482 | ! |
---|
483 | !-- Salinity |
---|
484 | IF ( ocean_mode ) THEN |
---|
485 | sums(:,23) = sums(:,23) / ngp_2dh_s_inner(:,sr) |
---|
486 | hom(:,1,23,sr) = sums(:,23) ! sa |
---|
487 | ENDIF |
---|
488 | |
---|
489 | ! |
---|
490 | !-- Humidity and cloud parameters |
---|
491 | IF ( humidity ) THEN |
---|
492 | sums(:,44) = sums(:,44) / ngp_2dh_s_inner(:,sr) |
---|
493 | sums(:,41) = sums(:,41) / ngp_2dh_s_inner(:,sr) |
---|
494 | hom(:,1,44,sr) = sums(:,44) ! vpt |
---|
495 | hom(:,1,41,sr) = sums(:,41) ! qv (q) |
---|
496 | IF ( bulk_cloud_model ) THEN |
---|
497 | sums(:,42) = sums(:,42) / ngp_2dh_s_inner(:,sr) |
---|
498 | sums(:,43) = sums(:,43) / ngp_2dh_s_inner(:,sr) |
---|
499 | hom(:,1,42,sr) = sums(:,42) ! qv |
---|
500 | hom(:,1,43,sr) = sums(:,43) ! pt |
---|
501 | ENDIF |
---|
502 | ENDIF |
---|
503 | |
---|
504 | ! |
---|
505 | !-- Passive scalar |
---|
506 | IF ( passive_scalar ) hom(:,1,115,sr) = sums(:,115) / ngp_2dh_s_inner(:,sr) ! s |
---|
507 | |
---|
508 | ! |
---|
509 | !-- Horizontally averaged profiles of the remaining prognostic variables, variances, the total |
---|
510 | !-- and the perturbation energy (single values in last column of sums_l) and some diagnostic |
---|
511 | !-- quantities. |
---|
512 | !-- NOTE: for simplicity, nzb_s_inner is used below, although strictly speaking the following |
---|
513 | !-- ---- k-loop would have to be split up and rearranged according to the staggered grid. |
---|
514 | !-- However, this implies no error since staggered velocity components are zero at the |
---|
515 | !-- walls and inside buildings. |
---|
516 | tn = 0 |
---|
517 | !$OMP PARALLEL PRIVATE( i, j, k, pts, sums_ll, & |
---|
518 | !$OMP sums_l_etot, tn, ust, ust2, u2, vst, vst2, v2, & |
---|
519 | !$OMP w2, flag, m, ki, l ) |
---|
520 | !$ tn = omp_get_thread_num() |
---|
521 | !$OMP DO |
---|
522 | !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j, k, m) & |
---|
523 | !$ACC PRIVATE(sums_l_etot, flag, du_dx, du_dy, du_dz) & |
---|
524 | !$ACC PRIVATE(dv_dx, dv_dy, dv_dz, dw_dx, dw_dy, dw_dz) & |
---|
525 | !$ACC PRIVATE(s11, s21, s31, s12, s22, s32, s13, s23, s33) & |
---|
526 | !$ACC PRIVATE(dissipation, eta) & |
---|
527 | !$ACC PRESENT(wall_flags_total_0, rmask, momentumflux_output_conversion) & |
---|
528 | !$ACC PRESENT(hom(:,1,1:2,sr), hom(:,1,4,sr)) & |
---|
529 | !$ACC PRESENT(e, u, v, w, km, kh, p, pt) & |
---|
530 | !$ACC PRESENT(ddx, ddy, ddzu, ddzw) & |
---|
531 | !$ACC PRESENT(surf_def_h(0), surf_lsm_h(0), surf_usm_h(0)) & |
---|
532 | !$ACC PRESENT(sums_l) |
---|
533 | DO i = nxl, nxr |
---|
534 | DO j = nys, nyn |
---|
535 | sums_l_etot = 0.0_wp |
---|
536 | DO k = nzb, nzt+1 |
---|
537 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
538 | ! |
---|
539 | !-- Prognostic and diagnostic variables |
---|
540 | !$ACC ATOMIC |
---|
541 | sums_l(k,3,tn) = sums_l(k,3,tn) + w(k,j,i) * rmask(j,i,sr) * flag |
---|
542 | !$ACC ATOMIC |
---|
543 | sums_l(k,8,tn) = sums_l(k,8,tn) + e(k,j,i) * rmask(j,i,sr) * flag |
---|
544 | !$ACC ATOMIC |
---|
545 | sums_l(k,9,tn) = sums_l(k,9,tn) + km(k,j,i) * rmask(j,i,sr) * flag |
---|
546 | !$ACC ATOMIC |
---|
547 | sums_l(k,10,tn) = sums_l(k,10,tn) + kh(k,j,i) * rmask(j,i,sr) * flag |
---|
548 | !$ACC ATOMIC |
---|
549 | sums_l(k,40,tn) = sums_l(k,40,tn) + ( p(k,j,i) & |
---|
550 | / momentumflux_output_conversion(k) ) * flag |
---|
551 | |
---|
552 | !$ACC ATOMIC |
---|
553 | sums_l(k,33,tn) = sums_l(k,33,tn) + & |
---|
554 | ( pt(k,j,i)-hom(k,1,4,sr) )**2 * rmask(j,i,sr) * flag |
---|
555 | #ifndef _OPENACC |
---|
556 | IF ( humidity ) THEN |
---|
557 | sums_l(k,70,tn) = sums_l(k,70,tn) + & |
---|
558 | ( q(k,j,i)-hom(k,1,41,sr) )**2 * rmask(j,i,sr) * flag |
---|
559 | ENDIF |
---|
560 | IF ( passive_scalar ) THEN |
---|
561 | sums_l(k,116,tn) = sums_l(k,116,tn) + & |
---|
562 | ( s(k,j,i)-hom(k,1,115,sr) )**2 * rmask(j,i,sr) * flag |
---|
563 | ENDIF |
---|
564 | #endif |
---|
565 | ! |
---|
566 | !-- Higher moments |
---|
567 | !-- (Computation of the skewness of w further below) |
---|
568 | !$ACC ATOMIC |
---|
569 | sums_l(k,38,tn) = sums_l(k,38,tn) + w(k,j,i)**3 * rmask(j,i,sr) * flag |
---|
570 | |
---|
571 | sums_l_etot = sums_l_etot + 0.5_wp * ( u(k,j,i)**2 + v(k,j,i)**2 + w(k,j,i)**2 ) & |
---|
572 | * rmask(j,i,sr) * flag |
---|
573 | |
---|
574 | ! |
---|
575 | !-- Computation of the Kolmogorov length scale. Calculation is based on gradients of the |
---|
576 | !-- deviations from the horizontal mean. |
---|
577 | !-- Kolmogorov scale at the boundaries (k=0/z=0m and k=nzt+1) is set to zero. |
---|
578 | IF ( kolmogorov_length_scale .AND. k /= nzb .AND. k /= nzt+1) THEN |
---|
579 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
580 | |
---|
581 | ! |
---|
582 | !-- Calculate components of the fluctuating rate-of-strain tensor |
---|
583 | !-- (0.5*(del u'_i/del x_j + del u'_j/del x_i)) defined in the center of each grid |
---|
584 | !-- box. |
---|
585 | du_dx = ( ( u(k,j,i+1) - hom(k,1,1,sr) ) - & |
---|
586 | ( u(k,j,i) - hom(k,1,1,sr) ) ) * ddx |
---|
587 | du_dy = 0.25_wp * ddy * & |
---|
588 | ( ( u(k,j+1,i) - hom(k,1,1,sr) ) - & |
---|
589 | ( u(k,j-1,i) - hom(k,1,1,sr) ) + & |
---|
590 | ( u(k,j+1,i+1) - hom(k,1,1,sr) ) - & |
---|
591 | ( u(k,j-1,i+1) - hom(k,1,1,sr) ) ) |
---|
592 | du_dz = 0.25_wp * ( ( ( u(k+1,j,i) - hom(k+1,1,1,sr) ) - & |
---|
593 | ( u(k,j,i) - hom(k,1,1,sr) ) ) * & |
---|
594 | ddzu(k+1) + & |
---|
595 | ( ( u(k,j,i) - hom(k,1,1,sr) ) - & |
---|
596 | ( u(k-1,j,i) - hom(k-1,1,1,sr) ) ) * & |
---|
597 | ddzu(k) + & |
---|
598 | ( ( u(k+1,j,i+1) - hom(k+1,1,1,sr) ) - & |
---|
599 | ( u(k,j,i+1) - hom(k,1,1,sr) ) ) * & |
---|
600 | ddzu(k+1) + & |
---|
601 | ( ( u(k,j,i+1) - hom(k,1,1,sr) ) - & |
---|
602 | ( u(k-1,j,i+1) - hom(k-1,1,1,sr) ) ) * & |
---|
603 | ddzu(k) ) |
---|
604 | |
---|
605 | dv_dx = 0.25_wp * ddx * & |
---|
606 | ( ( v(k,j,i+1) - hom(k,1,2,sr) ) - & |
---|
607 | ( v(k,j,i-1) - hom(k,1,2,sr) ) + & |
---|
608 | ( v(k,j+1,i+1) - hom(k,1,2,sr) ) - & |
---|
609 | ( v(k,j+1,i-1) - hom(k,1,2,sr) ) ) |
---|
610 | dv_dy = ( ( v(k,j+1,i) - hom(k,1,2,sr) ) - ( v(k,j,i) - hom(k,1,2,sr) ) ) * ddy |
---|
611 | dv_dz = 0.25_wp * ( ( ( v(k+1,j,i) - hom(k+1,1,2,sr) ) - & |
---|
612 | ( v(k,j,i) - hom(k,1,2,sr) ) ) * & |
---|
613 | ddzu(k+1) + & |
---|
614 | ( ( v(k,j,i) - hom(k,1,2,sr) ) - & |
---|
615 | ( v(k-1,j,i) - hom(k-1,1,2,sr) ) ) * & |
---|
616 | ddzu(k) + & |
---|
617 | ( ( v(k+1,j+1,i) - hom(k+1,1,2,sr) ) - & |
---|
618 | ( v(k,j+1,i) - hom(k,1,2,sr) ) ) * & |
---|
619 | ddzu(k+1) + & |
---|
620 | ( ( v(k,j+1,i) - hom(k,1,2,sr) ) - & |
---|
621 | ( v(k-1,j+1,i) - hom(k-1,1,2,sr) ) ) * & |
---|
622 | ddzu(k) ) |
---|
623 | |
---|
624 | dw_dx = 0.25_wp * ddx * ( w(k,j,i+1) - w(k,j,i-1) + w(k-1,j,i+1) - w(k-1,j,i-1) ) |
---|
625 | dw_dy = 0.25_wp * ddy * ( w(k,j+1,i) - w(k,j-1,i) + w(k-1,j+1,i) - w(k-1,j-1,i) ) |
---|
626 | dw_dz = ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) |
---|
627 | |
---|
628 | s11 = 0.5_wp * ( du_dx + du_dx ) |
---|
629 | s21 = 0.5_wp * ( dv_dx + du_dy ) |
---|
630 | s31 = 0.5_wp * ( dw_dx + du_dz ) |
---|
631 | |
---|
632 | s12 = s21 |
---|
633 | s22 = 0.5 * ( dv_dy + dv_dy ) |
---|
634 | s32 = 0.5 * ( dw_dy + dv_dz ) |
---|
635 | |
---|
636 | s13 = s31 |
---|
637 | s23 = s32 |
---|
638 | s33 = 0.5_wp * ( dw_dz + dw_dz ) |
---|
639 | |
---|
640 | !-- Calculate 3D instantaneous energy dissipation rate following Pope (2000): |
---|
641 | !-- Turbulent flows, p.259. It is defined in the center of each grid volume. |
---|
642 | dissipation = 2.0_wp * km(k,j,i) * & |
---|
643 | ( s11*s11 + s21*s21 + s31*s31 + & |
---|
644 | s12*s12 + s22*s22 + s32*s32 + & |
---|
645 | s13*s13 + s23*s23 + s33*s33 ) |
---|
646 | eta = ( km(k,j,i)**3.0_wp / ( dissipation+1.0E-12 ) )**(1.0_wp/4.0_wp) |
---|
647 | |
---|
648 | !$ACC ATOMIC |
---|
649 | sums_l(k,121,tn) = sums_l(k,121,tn) + eta * rmask(j,i,sr) * flag |
---|
650 | |
---|
651 | |
---|
652 | ENDIF !Kolmogorov length scale |
---|
653 | |
---|
654 | ENDDO !k-loop |
---|
655 | ! |
---|
656 | !-- Total and perturbation energy for the total domain (being collected in the last column |
---|
657 | !-- of sums_l). Summation of these quantities is seperated from the previous loop in order |
---|
658 | !-- to allow vectorization of that loop. |
---|
659 | !$ACC ATOMIC |
---|
660 | sums_l(nzb+4,pr_palm,tn) = sums_l(nzb+4,pr_palm,tn) + sums_l_etot |
---|
661 | ! |
---|
662 | !-- 2D-arrays (being collected in the last column of sums_l) |
---|
663 | IF ( surf_def_h(0)%end_index(j,i) >= surf_def_h(0)%start_index(j,i) ) THEN |
---|
664 | m = surf_def_h(0)%start_index(j,i) |
---|
665 | !$ACC ATOMIC |
---|
666 | sums_l(nzb,pr_palm,tn) = sums_l(nzb,pr_palm,tn) + & |
---|
667 | surf_def_h(0)%us(m) * rmask(j,i,sr) |
---|
668 | !$ACC ATOMIC |
---|
669 | sums_l(nzb+1,pr_palm,tn) = sums_l(nzb+1,pr_palm,tn) + & |
---|
670 | surf_def_h(0)%usws(m) * rmask(j,i,sr) |
---|
671 | !$ACC ATOMIC |
---|
672 | sums_l(nzb+2,pr_palm,tn) = sums_l(nzb+2,pr_palm,tn) + & |
---|
673 | surf_def_h(0)%vsws(m) * rmask(j,i,sr) |
---|
674 | !$ACC ATOMIC |
---|
675 | sums_l(nzb+3,pr_palm,tn) = sums_l(nzb+3,pr_palm,tn) + & |
---|
676 | surf_def_h(0)%ts(m) * rmask(j,i,sr) |
---|
677 | #ifndef _OPENACC |
---|
678 | IF ( humidity ) THEN |
---|
679 | sums_l(nzb+12,pr_palm,tn) = sums_l(nzb+12,pr_palm,tn) + & |
---|
680 | surf_def_h(0)%qs(m) * rmask(j,i,sr) |
---|
681 | ENDIF |
---|
682 | IF ( passive_scalar ) THEN |
---|
683 | sums_l(nzb+13,pr_palm,tn) = sums_l(nzb+13,pr_palm,tn) + & |
---|
684 | surf_def_h(0)%ss(m) * rmask(j,i,sr) |
---|
685 | ENDIF |
---|
686 | #endif |
---|
687 | ! |
---|
688 | !-- Summation of surface temperature. |
---|
689 | !$ACC ATOMIC |
---|
690 | sums_l(nzb+14,pr_palm,tn) = sums_l(nzb+14,pr_palm,tn) + & |
---|
691 | surf_def_h(0)%pt_surface(m) * rmask(j,i,sr) |
---|
692 | ENDIF |
---|
693 | IF ( surf_lsm_h(0)%end_index(j,i) >= surf_lsm_h(0)%start_index(j,i) ) THEN |
---|
694 | m = surf_lsm_h(0)%start_index(j,i) |
---|
695 | !$ACC ATOMIC |
---|
696 | sums_l(nzb,pr_palm,tn) = sums_l(nzb,pr_palm,tn) + & |
---|
697 | surf_lsm_h(0)%us(m) * rmask(j,i,sr) |
---|
698 | !$ACC ATOMIC |
---|
699 | sums_l(nzb+1,pr_palm,tn) = sums_l(nzb+1,pr_palm,tn) + & |
---|
700 | surf_lsm_h(0)%usws(m) * rmask(j,i,sr) |
---|
701 | !$ACC ATOMIC |
---|
702 | sums_l(nzb+2,pr_palm,tn) = sums_l(nzb+2,pr_palm,tn) + & |
---|
703 | surf_lsm_h(0)%vsws(m) * rmask(j,i,sr) |
---|
704 | !$ACC ATOMIC |
---|
705 | sums_l(nzb+3,pr_palm,tn) = sums_l(nzb+3,pr_palm,tn) + & |
---|
706 | surf_lsm_h(0)%ts(m) * rmask(j,i,sr) |
---|
707 | #ifndef _OPENACC |
---|
708 | IF ( humidity ) THEN |
---|
709 | sums_l(nzb+12,pr_palm,tn) = sums_l(nzb+12,pr_palm,tn) + & |
---|
710 | surf_lsm_h(0)%qs(m) * rmask(j,i,sr) |
---|
711 | ENDIF |
---|
712 | IF ( passive_scalar ) THEN |
---|
713 | sums_l(nzb+13,pr_palm,tn) = sums_l(nzb+13,pr_palm,tn) + & |
---|
714 | surf_lsm_h(0)%ss(m) * rmask(j,i,sr) |
---|
715 | ENDIF |
---|
716 | #endif |
---|
717 | ! |
---|
718 | !-- Summation of surface temperature. |
---|
719 | !$ACC ATOMIC |
---|
720 | sums_l(nzb+14,pr_palm,tn) = sums_l(nzb+14,pr_palm,tn) + & |
---|
721 | surf_lsm_h(0)%pt_surface(m) * rmask(j,i,sr) |
---|
722 | ENDIF |
---|
723 | IF ( surf_usm_h(0)%end_index(j,i) >= surf_usm_h(0)%start_index(j,i) ) THEN |
---|
724 | m = surf_usm_h(0)%start_index(j,i) |
---|
725 | !$ACC ATOMIC |
---|
726 | sums_l(nzb,pr_palm,tn) = sums_l(nzb,pr_palm,tn) + & |
---|
727 | surf_usm_h(0)%us(m) * rmask(j,i,sr) |
---|
728 | !$ACC ATOMIC |
---|
729 | sums_l(nzb+1,pr_palm,tn) = sums_l(nzb+1,pr_palm,tn) + & |
---|
730 | surf_usm_h(0)%usws(m) * rmask(j,i,sr) |
---|
731 | !$ACC ATOMIC |
---|
732 | sums_l(nzb+2,pr_palm,tn) = sums_l(nzb+2,pr_palm,tn) + & |
---|
733 | surf_usm_h(0)%vsws(m) * rmask(j,i,sr) |
---|
734 | !$ACC ATOMIC |
---|
735 | sums_l(nzb+3,pr_palm,tn) = sums_l(nzb+3,pr_palm,tn) + & |
---|
736 | surf_usm_h(0)%ts(m) * rmask(j,i,sr) |
---|
737 | #ifndef _OPENACC |
---|
738 | IF ( humidity ) THEN |
---|
739 | sums_l(nzb+12,pr_palm,tn) = sums_l(nzb+12,pr_palm,tn) + & |
---|
740 | surf_usm_h(0)%qs(m) * rmask(j,i,sr) |
---|
741 | ENDIF |
---|
742 | IF ( passive_scalar ) THEN |
---|
743 | sums_l(nzb+13,pr_palm,tn) = sums_l(nzb+13,pr_palm,tn) + & |
---|
744 | surf_usm_h(0)%ss(m) * rmask(j,i,sr) |
---|
745 | ENDIF |
---|
746 | #endif |
---|
747 | ! |
---|
748 | !-- Summation of surface temperature. |
---|
749 | !$ACC ATOMIC |
---|
750 | sums_l(nzb+14,pr_palm,tn) = sums_l(nzb+14,pr_palm,tn) + & |
---|
751 | surf_usm_h(0)%pt_surface(m) * rmask(j,i,sr) |
---|
752 | ENDIF |
---|
753 | ENDDO !j-loop |
---|
754 | ENDDO !i-loop |
---|
755 | !$ACC UPDATE & |
---|
756 | !$ACC HOST(sums_l(:,3,tn), sums_l(:,8,tn), sums_l(:,9,tn)) & |
---|
757 | !$ACC HOST(sums_l(:,10,tn), sums_l(:,40,tn), sums_l(:,33,tn)) & |
---|
758 | !$ACC HOST(sums_l(:,38,tn), sums_l(:,121,tn)) & |
---|
759 | !$ACC HOST(sums_l(nzb:nzb+4,pr_palm,tn), sums_l(nzb+14:nzb+14,pr_palm,tn)) |
---|
760 | |
---|
761 | ! |
---|
762 | !-- Computation of statistics when ws-scheme is not used. Else these |
---|
763 | !-- quantities are evaluated in the advection routines. |
---|
764 | IF ( .NOT. ws_scheme_mom .OR. sr /= 0 .OR. simulated_time == 0.0_wp ) THEN |
---|
765 | !$OMP DO |
---|
766 | DO i = nxl, nxr |
---|
767 | DO j = nys, nyn |
---|
768 | DO k = nzb, nzt+1 |
---|
769 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
770 | |
---|
771 | u2 = u(k,j,i)**2 |
---|
772 | v2 = v(k,j,i)**2 |
---|
773 | w2 = w(k,j,i)**2 |
---|
774 | ust2 = ( u(k,j,i) - hom(k,1,1,sr) )**2 |
---|
775 | vst2 = ( v(k,j,i) - hom(k,1,2,sr) )**2 |
---|
776 | |
---|
777 | sums_l(k,30,tn) = sums_l(k,30,tn) + ust2 * rmask(j,i,sr) * flag |
---|
778 | sums_l(k,31,tn) = sums_l(k,31,tn) + vst2 * rmask(j,i,sr) * flag |
---|
779 | sums_l(k,32,tn) = sums_l(k,32,tn) + w2 * rmask(j,i,sr) * flag |
---|
780 | ! |
---|
781 | !-- Perturbation energy |
---|
782 | sums_l(k,34,tn) = sums_l(k,34,tn) + & |
---|
783 | 0.5_wp * ( ust2 + vst2 + w2 ) * rmask(j,i,sr) * flag |
---|
784 | ENDDO |
---|
785 | ENDDO |
---|
786 | ENDDO |
---|
787 | ENDIF |
---|
788 | ! |
---|
789 | !-- Computaion of domain-averaged perturbation energy. Please note, to prevent that perturbation |
---|
790 | !-- energy is larger (even if only slightly) than the total kinetic energy, calculation is based |
---|
791 | !-- on deviations from the horizontal mean, instead of spatial descretization of the advection |
---|
792 | !-- term. |
---|
793 | !$OMP DO |
---|
794 | !$ACC PARALLEL LOOP COLLAPSE(3) PRIVATE(i, j, k, flag, w2, ust2, vst2) & |
---|
795 | !$ACC PRESENT(wall_flags_total_0, u, v, w, rmask, hom(:,1,1:2,sr)) & |
---|
796 | !$ACC PRESENT(sums_l) |
---|
797 | DO i = nxl, nxr |
---|
798 | DO j = nys, nyn |
---|
799 | DO k = nzb, nzt+1 |
---|
800 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
801 | |
---|
802 | w2 = w(k,j,i)**2 |
---|
803 | ust2 = ( u(k,j,i) - hom(k,1,1,sr) )**2 |
---|
804 | vst2 = ( v(k,j,i) - hom(k,1,2,sr) )**2 |
---|
805 | w2 = w(k,j,i)**2 |
---|
806 | |
---|
807 | !$ACC ATOMIC |
---|
808 | sums_l(nzb+5,pr_palm,tn) = sums_l(nzb+5,pr_palm,tn) & |
---|
809 | + 0.5_wp * ( ust2 + vst2 + w2 ) * rmask(j,i,sr) * flag |
---|
810 | |
---|
811 | ENDDO |
---|
812 | ENDDO |
---|
813 | ENDDO |
---|
814 | !$ACC UPDATE HOST(sums_l(nzb+5:nzb+5,pr_palm,tn)) |
---|
815 | |
---|
816 | ! |
---|
817 | !-- Horizontally averaged profiles of the vertical fluxes |
---|
818 | !$OMP DO |
---|
819 | !$ACC PARALLEL LOOP COLLAPSE(2) PRIVATE(i, j, k, l, m) & |
---|
820 | !$ACC PRIVATE(ki, flag, ust, vst, pts) & |
---|
821 | !$ACC PRESENT(kh, km, u, v, w, pt) & |
---|
822 | !$ACC PRESENT(wall_flags_total_0, rmask, ddzu, rho_air_zw, hom(:,1,1:4,sr)) & |
---|
823 | !$ACC PRESENT(heatflux_output_conversion, momentumflux_output_conversion) & |
---|
824 | !$ACC PRESENT(surf_def_h(0:2), surf_lsm_h(0:1), surf_usm_h(0:1)) & |
---|
825 | !$ACC PRESENT(sums_l) |
---|
826 | DO i = nxl, nxr |
---|
827 | DO j = nys, nyn |
---|
828 | ! |
---|
829 | !-- Subgridscale fluxes (without Prandtl layer from k=nzb, oterwise from k=nzb+1) |
---|
830 | !-- NOTE: for simplicity, nzb_diff_s_inner is used below, although strictly speaking the |
---|
831 | !-- ---- following k-loop would have to be split up according to the staggered grid. |
---|
832 | !-- However, this implies no error since staggered velocity components are zero at |
---|
833 | !-- the walls and inside buildings. |
---|
834 | !-- Flag 23 is used to mask surface fluxes as well as model-top fluxes, which are added |
---|
835 | !-- further below. |
---|
836 | DO k = nzb, nzt |
---|
837 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 23 ) ) * & |
---|
838 | MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 9 ) ) |
---|
839 | ! |
---|
840 | !-- Momentum flux w"u" |
---|
841 | !$ACC ATOMIC |
---|
842 | sums_l(k,12,tn) = sums_l(k,12,tn) - 0.25_wp * ( & |
---|
843 | km(k,j,i) + km(k+1,j,i) + km(k,j,i-1) + km(k+1,j,i-1) & |
---|
844 | ) * ( & |
---|
845 | ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
846 | + ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
847 | ) * rmask(j,i,sr) & |
---|
848 | * rho_air_zw(k) & |
---|
849 | * momentumflux_output_conversion(k) & |
---|
850 | * flag |
---|
851 | ! |
---|
852 | !-- Momentum flux w"v" |
---|
853 | !$ACC ATOMIC |
---|
854 | sums_l(k,14,tn) = sums_l(k,14,tn) - 0.25_wp * ( & |
---|
855 | km(k,j,i) + km(k+1,j,i) + km(k,j-1,i) + km(k+1,j-1,i) & |
---|
856 | ) * ( & |
---|
857 | ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
858 | + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
859 | ) * rmask(j,i,sr) & |
---|
860 | * rho_air_zw(k) & |
---|
861 | * momentumflux_output_conversion(k) & |
---|
862 | * flag |
---|
863 | ! |
---|
864 | !-- Heat flux w"pt" |
---|
865 | !$ACC ATOMIC |
---|
866 | sums_l(k,16,tn) = sums_l(k,16,tn) & |
---|
867 | - 0.5_wp * ( kh(k,j,i) + kh(k+1,j,i) ) & |
---|
868 | * ( pt(k+1,j,i) - pt(k,j,i) ) & |
---|
869 | * rho_air_zw(k) & |
---|
870 | * heatflux_output_conversion(k) & |
---|
871 | * ddzu(k+1) * rmask(j,i,sr) & |
---|
872 | * flag |
---|
873 | |
---|
874 | ! |
---|
875 | !-- Salinity flux w"sa" |
---|
876 | #ifndef _OPENACC |
---|
877 | IF ( ocean_mode ) THEN |
---|
878 | sums_l(k,65,tn) = sums_l(k,65,tn) & |
---|
879 | - 0.5_wp * ( kh(k,j,i) + kh(k+1,j,i) ) & |
---|
880 | * ( sa(k+1,j,i) - sa(k,j,i) ) & |
---|
881 | * ddzu(k+1) * rmask(j,i,sr) & |
---|
882 | * flag |
---|
883 | ENDIF |
---|
884 | |
---|
885 | ! |
---|
886 | !-- Buoyancy flux, water flux (humidity flux) w"q" |
---|
887 | IF ( humidity ) THEN |
---|
888 | sums_l(k,45,tn) = sums_l(k,45,tn) & |
---|
889 | - 0.5_wp * ( kh(k,j,i) + kh(k+1,j,i) ) & |
---|
890 | * ( vpt(k+1,j,i) - vpt(k,j,i) ) & |
---|
891 | * rho_air_zw(k) & |
---|
892 | * heatflux_output_conversion(k) & |
---|
893 | * ddzu(k+1) * rmask(j,i,sr) * flag |
---|
894 | sums_l(k,48,tn) = sums_l(k,48,tn) & |
---|
895 | - 0.5_wp * ( kh(k,j,i) + kh(k+1,j,i) ) & |
---|
896 | * ( q(k+1,j,i) - q(k,j,i) ) & |
---|
897 | * rho_air_zw(k) & |
---|
898 | * waterflux_output_conversion(k) & |
---|
899 | * ddzu(k+1) * rmask(j,i,sr) * flag |
---|
900 | |
---|
901 | IF ( bulk_cloud_model ) THEN |
---|
902 | sums_l(k,51,tn) = sums_l(k,51,tn) & |
---|
903 | - 0.5_wp * ( kh(k,j,i) + kh(k+1,j,i) ) & |
---|
904 | * ( ( q(k+1,j,i) - ql(k+1,j,i) ) & |
---|
905 | - ( q(k,j,i) - ql(k,j,i) ) ) & |
---|
906 | * rho_air_zw(k) & |
---|
907 | * waterflux_output_conversion(k) & |
---|
908 | * ddzu(k+1) * rmask(j,i,sr) * flag |
---|
909 | ENDIF |
---|
910 | ENDIF |
---|
911 | |
---|
912 | ! |
---|
913 | !-- Passive scalar flux |
---|
914 | IF ( passive_scalar ) THEN |
---|
915 | sums_l(k,117,tn) = sums_l(k,117,tn) & |
---|
916 | - 0.5_wp * ( kh(k,j,i) + kh(k+1,j,i) ) & |
---|
917 | * ( s(k+1,j,i) - s(k,j,i) ) & |
---|
918 | * ddzu(k+1) * rmask(j,i,sr) & |
---|
919 | * flag |
---|
920 | ENDIF |
---|
921 | #endif |
---|
922 | |
---|
923 | ENDDO |
---|
924 | |
---|
925 | ! |
---|
926 | !-- Subgridscale fluxes in the Prandtl layer |
---|
927 | IF ( use_surface_fluxes ) THEN |
---|
928 | DO l = 0, 1 |
---|
929 | ! The original code using MERGE doesn't work with the PGI |
---|
930 | ! compiler when running on the GPU. |
---|
931 | ! This is submitted as a compiler Bug in PGI ticket TPR#26718 |
---|
932 | ! ki = MERGE( -1, 0, l == 0 ) |
---|
933 | ki = -1 + l |
---|
934 | IF ( surf_def_h(l)%ns >= 1 ) THEN |
---|
935 | DO m = surf_def_h(l)%start_index(j,i), & |
---|
936 | surf_def_h(l)%end_index(j,i) |
---|
937 | k = surf_def_h(l)%k(m) |
---|
938 | |
---|
939 | !$ACC ATOMIC |
---|
940 | sums_l(k+ki,12,tn) = sums_l(k+ki,12,tn) + & |
---|
941 | momentumflux_output_conversion(k+ki) * & |
---|
942 | surf_def_h(l)%usws(m) * rmask(j,i,sr) ! w"u" |
---|
943 | !$ACC ATOMIC |
---|
944 | sums_l(k+ki,14,tn) = sums_l(k+ki,14,tn) + & |
---|
945 | momentumflux_output_conversion(k+ki) * & |
---|
946 | surf_def_h(l)%vsws(m) * rmask(j,i,sr) ! w"v" |
---|
947 | !$ACC ATOMIC |
---|
948 | sums_l(k+ki,16,tn) = sums_l(k+ki,16,tn) + & |
---|
949 | heatflux_output_conversion(k+ki) * & |
---|
950 | surf_def_h(l)%shf(m) * rmask(j,i,sr) ! w"pt" |
---|
951 | #if 0 |
---|
952 | sums_l(k+ki,58,tn) = sums_l(k+ki,58,tn) + & |
---|
953 | 0.0_wp * rmask(j,i,sr) ! u"pt" |
---|
954 | sums_l(k+ki,61,tn) = sums_l(k+ki,61,tn) + & |
---|
955 | 0.0_wp * rmask(j,i,sr) ! v"pt" |
---|
956 | #endif |
---|
957 | #ifndef _OPENACC |
---|
958 | IF ( ocean_mode ) THEN |
---|
959 | sums_l(k+ki,65,tn) = sums_l(k+ki,65,tn) + & |
---|
960 | surf_def_h(l)%sasws(m) * rmask(j,i,sr) ! w"sa" |
---|
961 | ENDIF |
---|
962 | IF ( humidity ) THEN |
---|
963 | sums_l(k+ki,48,tn) = sums_l(k+ki,48,tn) + & |
---|
964 | waterflux_output_conversion(k+ki) * & |
---|
965 | surf_def_h(l)%qsws(m) * rmask(j,i,sr) ! w"q" (w"qv") |
---|
966 | sums_l(k+ki,45,tn) = sums_l(k+ki,45,tn) + ( & |
---|
967 | ( 1.0_wp + 0.61_wp * q(k+ki,j,i) ) * & |
---|
968 | surf_def_h(l)%shf(m) + 0.61_wp * pt(k+ki,j,i) * & |
---|
969 | surf_def_h(l)%qsws(m) ) & |
---|
970 | * heatflux_output_conversion(k+ki) |
---|
971 | IF ( cloud_droplets ) THEN |
---|
972 | sums_l(k+ki,45,tn) = sums_l(k+ki,45,tn) + ( & |
---|
973 | ( 1.0_wp + 0.61_wp * q(k+ki,j,i) - & |
---|
974 | ql(k+ki,j,i) ) * surf_def_h(l)%shf(m) + & |
---|
975 | 0.61_wp * pt(k+ki,j,i) & |
---|
976 | * surf_def_h(l)%qsws(m) ) & |
---|
977 | * heatflux_output_conversion(k+ki) |
---|
978 | ENDIF |
---|
979 | IF ( bulk_cloud_model ) THEN |
---|
980 | ! |
---|
981 | !-- Formula does not work if ql(k+ki) /= 0.0 |
---|
982 | sums_l(k+ki,51,tn) = sums_l(k+ki,51,tn) + & |
---|
983 | waterflux_output_conversion(k+ki) * & |
---|
984 | surf_def_h(l)%qsws(m) * rmask(j,i,sr) ! w"q" (w"qv") |
---|
985 | ENDIF |
---|
986 | ENDIF |
---|
987 | IF ( passive_scalar ) THEN |
---|
988 | sums_l(k+ki,117,tn) = sums_l(k+ki,117,tn) + & |
---|
989 | surf_def_h(l)%ssws(m) * rmask(j,i,sr) ! w"s" |
---|
990 | ENDIF |
---|
991 | #endif |
---|
992 | |
---|
993 | ENDDO |
---|
994 | |
---|
995 | ENDIF |
---|
996 | IF ( surf_lsm_h(l)%end_index(j,i) >= surf_lsm_h(l)%start_index(j,i) ) THEN |
---|
997 | m = surf_lsm_h(l)%start_index(j,i) |
---|
998 | !$ACC ATOMIC |
---|
999 | sums_l(nzb,12,tn) = sums_l(nzb,12,tn) + & |
---|
1000 | momentumflux_output_conversion(nzb) * & |
---|
1001 | surf_lsm_h(l)%usws(m) * rmask(j,i,sr) ! w"u" |
---|
1002 | !$ACC ATOMIC |
---|
1003 | sums_l(nzb,14,tn) = sums_l(nzb,14,tn) + & |
---|
1004 | momentumflux_output_conversion(nzb) * & |
---|
1005 | surf_lsm_h(l)%vsws(m) * rmask(j,i,sr) ! w"v" |
---|
1006 | !$ACC ATOMIC |
---|
1007 | sums_l(nzb,16,tn) = sums_l(nzb,16,tn) + & |
---|
1008 | heatflux_output_conversion(nzb) * & |
---|
1009 | surf_lsm_h(l)%shf(m) * rmask(j,i,sr) ! w"pt" |
---|
1010 | #if 0 |
---|
1011 | sums_l(nzb,58,tn) = sums_l(nzb,58,tn) + & |
---|
1012 | 0.0_wp * rmask(j,i,sr) ! u"pt" |
---|
1013 | sums_l(nzb,61,tn) = sums_l(nzb,61,tn) + & |
---|
1014 | 0.0_wp * rmask(j,i,sr) ! v"pt" |
---|
1015 | #endif |
---|
1016 | #ifndef _OPENACC |
---|
1017 | IF ( ocean_mode ) THEN |
---|
1018 | sums_l(nzb,65,tn) = sums_l(nzb,65,tn) + & |
---|
1019 | surf_lsm_h(l)%sasws(m) * rmask(j,i,sr) ! w"sa" |
---|
1020 | ENDIF |
---|
1021 | IF ( humidity ) THEN |
---|
1022 | sums_l(nzb,48,tn) = sums_l(nzb,48,tn) + & |
---|
1023 | waterflux_output_conversion(nzb) * & |
---|
1024 | surf_lsm_h(l)%qsws(m) * rmask(j,i,sr) ! w"q" (w"qv") |
---|
1025 | sums_l(nzb,45,tn) = sums_l(nzb,45,tn) + ( & |
---|
1026 | ( 1.0_wp + 0.61_wp * q(nzb,j,i) ) * surf_lsm_h(l)%shf(m) + & |
---|
1027 | 0.61_wp * pt(nzb,j,i) * surf_lsm_h(l)%qsws(m) ) & |
---|
1028 | * heatflux_output_conversion(nzb) |
---|
1029 | IF ( cloud_droplets ) THEN |
---|
1030 | sums_l(nzb,45,tn) = sums_l(nzb,45,tn) + ( & |
---|
1031 | ( 1.0_wp + 0.61_wp * q(nzb,j,i) - & |
---|
1032 | ql(nzb,j,i) ) * surf_lsm_h(l)%shf(m) + & |
---|
1033 | 0.61_wp * pt(nzb,j,i) * surf_lsm_h(l)%qsws(m) ) & |
---|
1034 | * heatflux_output_conversion(nzb) |
---|
1035 | ENDIF |
---|
1036 | IF ( bulk_cloud_model ) THEN |
---|
1037 | ! |
---|
1038 | !-- Formula does not work if ql(nzb) /= 0.0 |
---|
1039 | sums_l(nzb,51,tn) = sums_l(nzb,51,tn) + & |
---|
1040 | waterflux_output_conversion(nzb) * & |
---|
1041 | surf_lsm_h(l)%qsws(m) * rmask(j,i,sr) ! w"q" (w"qv") |
---|
1042 | ENDIF |
---|
1043 | ENDIF |
---|
1044 | IF ( passive_scalar ) THEN |
---|
1045 | sums_l(nzb,117,tn) = sums_l(nzb,117,tn) + & |
---|
1046 | surf_lsm_h(l)%ssws(m) * rmask(j,i,sr) ! w"s" |
---|
1047 | ENDIF |
---|
1048 | #endif |
---|
1049 | |
---|
1050 | ENDIF |
---|
1051 | IF ( surf_usm_h(l)%end_index(j,i) >= surf_usm_h(l)%start_index(j,i) ) THEN |
---|
1052 | m = surf_usm_h(l)%start_index(j,i) |
---|
1053 | !$ACC ATOMIC |
---|
1054 | sums_l(nzb,12,tn) = sums_l(nzb,12,tn) + & |
---|
1055 | momentumflux_output_conversion(nzb) * & |
---|
1056 | surf_usm_h(l)%usws(m) * rmask(j,i,sr) ! w"u" |
---|
1057 | !$ACC ATOMIC |
---|
1058 | sums_l(nzb,14,tn) = sums_l(nzb,14,tn) + & |
---|
1059 | momentumflux_output_conversion(nzb) * & |
---|
1060 | surf_usm_h(l)%vsws(m) * rmask(j,i,sr) ! w"v" |
---|
1061 | !$ACC ATOMIC |
---|
1062 | sums_l(nzb,16,tn) = sums_l(nzb,16,tn) + & |
---|
1063 | heatflux_output_conversion(nzb) * & |
---|
1064 | surf_usm_h(l)%shf(m) * rmask(j,i,sr) ! w"pt" |
---|
1065 | #if 0 |
---|
1066 | sums_l(nzb,58,tn) = sums_l(nzb,58,tn) + 0.0_wp * rmask(j,i,sr) ! u"pt" |
---|
1067 | sums_l(nzb,61,tn) = sums_l(nzb,61,tn) + 0.0_wp * rmask(j,i,sr) ! v"pt" |
---|
1068 | #endif |
---|
1069 | #ifndef _OPENACC |
---|
1070 | IF ( ocean_mode ) THEN |
---|
1071 | sums_l(nzb,65,tn) = sums_l(nzb,65,tn) + & |
---|
1072 | surf_usm_h(l)%sasws(m) * rmask(j,i,sr) ! w"sa" |
---|
1073 | ENDIF |
---|
1074 | IF ( humidity ) THEN |
---|
1075 | sums_l(nzb,48,tn) = sums_l(nzb,48,tn) + & |
---|
1076 | waterflux_output_conversion(nzb) * & |
---|
1077 | surf_usm_h(l)%qsws(m) * rmask(j,i,sr) ! w"q" (w"qv") |
---|
1078 | sums_l(nzb,45,tn) = sums_l(nzb,45,tn) + ( & |
---|
1079 | ( 1.0_wp + 0.61_wp * q(nzb,j,i) ) * & |
---|
1080 | surf_usm_h(l)%shf(m) + 0.61_wp * pt(nzb,j,i) * & |
---|
1081 | surf_usm_h(l)%qsws(m) ) & |
---|
1082 | * heatflux_output_conversion(nzb) |
---|
1083 | IF ( cloud_droplets ) THEN |
---|
1084 | sums_l(nzb,45,tn) = sums_l(nzb,45,tn) + ( & |
---|
1085 | ( 1.0_wp + 0.61_wp * q(nzb,j,i) - & |
---|
1086 | ql(nzb,j,i) ) * surf_usm_h(l)%shf(m) + & |
---|
1087 | 0.61_wp * pt(nzb,j,i) * surf_usm_h(l)%qsws(m) ) & |
---|
1088 | * heatflux_output_conversion(nzb) |
---|
1089 | ENDIF |
---|
1090 | IF ( bulk_cloud_model ) THEN |
---|
1091 | ! |
---|
1092 | !-- Formula does not work if ql(nzb) /= 0.0 |
---|
1093 | sums_l(nzb,51,tn) = sums_l(nzb,51,tn) + & |
---|
1094 | waterflux_output_conversion(nzb) * & |
---|
1095 | surf_usm_h(l)%qsws(m) * rmask(j,i,sr) ! w"q" (w"qv") |
---|
1096 | ENDIF |
---|
1097 | ENDIF |
---|
1098 | IF ( passive_scalar ) THEN |
---|
1099 | sums_l(nzb,117,tn) = sums_l(nzb,117,tn) + & |
---|
1100 | surf_usm_h(l)%ssws(m) * rmask(j,i,sr) ! w"s" |
---|
1101 | ENDIF |
---|
1102 | #endif |
---|
1103 | |
---|
1104 | ENDIF |
---|
1105 | ENDDO |
---|
1106 | ENDIF |
---|
1107 | |
---|
1108 | #ifndef _OPENACC |
---|
1109 | IF ( .NOT. neutral ) THEN |
---|
1110 | IF ( surf_def_h(0)%end_index(j,i) >= surf_def_h(0)%start_index(j,i) ) THEN |
---|
1111 | m = surf_def_h(0)%start_index(j,i) |
---|
1112 | sums_l(nzb,112,tn) = sums_l(nzb,112,tn) + surf_def_h(0)%ol(m) * rmask(j,i,sr) ! L |
---|
1113 | ENDIF |
---|
1114 | IF ( surf_lsm_h(0)%end_index(j,i) >= surf_lsm_h(0)%start_index(j,i) ) THEN |
---|
1115 | m = surf_lsm_h(0)%start_index(j,i) |
---|
1116 | sums_l(nzb,112,tn) = sums_l(nzb,112,tn) + surf_lsm_h(0)%ol(m) * rmask(j,i,sr) ! L |
---|
1117 | ENDIF |
---|
1118 | IF ( surf_usm_h(0)%end_index(j,i) >= surf_usm_h(0)%start_index(j,i) ) THEN |
---|
1119 | m = surf_usm_h(0)%start_index(j,i) |
---|
1120 | sums_l(nzb,112,tn) = sums_l(nzb,112,tn) + surf_usm_h(0)%ol(m) * rmask(j,i,sr) ! L |
---|
1121 | ENDIF |
---|
1122 | ENDIF |
---|
1123 | |
---|
1124 | IF ( radiation ) THEN |
---|
1125 | IF ( surf_def_h(0)%end_index(j,i) >= surf_def_h(0)%start_index(j,i) ) THEN |
---|
1126 | m = surf_def_h(0)%start_index(j,i) |
---|
1127 | sums_l(nzb,99,tn) = sums_l(nzb,99,tn) + & |
---|
1128 | surf_def_h(0)%rad_net(m) * rmask(j,i,sr) |
---|
1129 | sums_l(nzb,100,tn) = sums_l(nzb,100,tn) + & |
---|
1130 | surf_def_h(0)%rad_lw_in(m) * rmask(j,i,sr) |
---|
1131 | sums_l(nzb,101,tn) = sums_l(nzb,101,tn) + & |
---|
1132 | surf_def_h(0)%rad_lw_out(m) * rmask(j,i,sr) |
---|
1133 | sums_l(nzb,102,tn) = sums_l(nzb,102,tn) + & |
---|
1134 | surf_def_h(0)%rad_sw_in(m) * rmask(j,i,sr) |
---|
1135 | sums_l(nzb,103,tn) = sums_l(nzb,103,tn) + & |
---|
1136 | surf_def_h(0)%rad_sw_out(m) * rmask(j,i,sr) |
---|
1137 | ENDIF |
---|
1138 | IF ( surf_lsm_h(0)%end_index(j,i) >= surf_lsm_h(0)%start_index(j,i) ) THEN |
---|
1139 | m = surf_lsm_h(0)%start_index(j,i) |
---|
1140 | sums_l(nzb,99,tn) = sums_l(nzb,99,tn) + & |
---|
1141 | surf_lsm_h(0)%rad_net(m) * rmask(j,i,sr) |
---|
1142 | sums_l(nzb,100,tn) = sums_l(nzb,100,tn) + & |
---|
1143 | surf_lsm_h(0)%rad_lw_in(m) * rmask(j,i,sr) |
---|
1144 | sums_l(nzb,101,tn) = sums_l(nzb,101,tn) + & |
---|
1145 | surf_lsm_h(0)%rad_lw_out(m) * rmask(j,i,sr) |
---|
1146 | sums_l(nzb,102,tn) = sums_l(nzb,102,tn) + & |
---|
1147 | surf_lsm_h(0)%rad_sw_in(m) * rmask(j,i,sr) |
---|
1148 | sums_l(nzb,103,tn) = sums_l(nzb,103,tn) + & |
---|
1149 | surf_lsm_h(0)%rad_sw_out(m) * rmask(j,i,sr) |
---|
1150 | ENDIF |
---|
1151 | IF ( surf_usm_h(0)%end_index(j,i) >= surf_usm_h(0)%start_index(j,i) ) THEN |
---|
1152 | m = surf_usm_h(0)%start_index(j,i) |
---|
1153 | sums_l(nzb,99,tn) = sums_l(nzb,99,tn) + & |
---|
1154 | surf_usm_h(0)%rad_net(m) * rmask(j,i,sr) |
---|
1155 | sums_l(nzb,100,tn) = sums_l(nzb,100,tn) + & |
---|
1156 | surf_usm_h(0)%rad_lw_in(m) * rmask(j,i,sr) |
---|
1157 | sums_l(nzb,101,tn) = sums_l(nzb,101,tn) + & |
---|
1158 | surf_usm_h(0)%rad_lw_out(m) * rmask(j,i,sr) |
---|
1159 | sums_l(nzb,102,tn) = sums_l(nzb,102,tn) + & |
---|
1160 | surf_usm_h(0)%rad_sw_in(m) * rmask(j,i,sr) |
---|
1161 | sums_l(nzb,103,tn) = sums_l(nzb,103,tn) + & |
---|
1162 | surf_usm_h(0)%rad_sw_out(m) * rmask(j,i,sr) |
---|
1163 | ENDIF |
---|
1164 | |
---|
1165 | #if defined ( __rrtmg ) |
---|
1166 | IF ( radiation_scheme == 'rrtmg' ) THEN |
---|
1167 | |
---|
1168 | IF ( surf_def_h(0)%end_index(j,i) >= surf_def_h(0)%start_index(j,i) ) THEN |
---|
1169 | m = surf_def_h(0)%start_index(j,i) |
---|
1170 | sums_l(nzb,108,tn) = sums_l(nzb,108,tn) + & |
---|
1171 | surf_def_h(0)%rrtm_aldif(m,0) * rmask(j,i,sr) |
---|
1172 | sums_l(nzb,109,tn) = sums_l(nzb,109,tn) + & |
---|
1173 | surf_def_h(0)%rrtm_aldir(m,0) * rmask(j,i,sr) |
---|
1174 | sums_l(nzb,110,tn) = sums_l(nzb,110,tn) + & |
---|
1175 | surf_def_h(0)%rrtm_asdif(m,0) * rmask(j,i,sr) |
---|
1176 | sums_l(nzb,111,tn) = sums_l(nzb,111,tn) + & |
---|
1177 | surf_def_h(0)%rrtm_asdir(m,0) * rmask(j,i,sr) |
---|
1178 | ENDIF |
---|
1179 | IF ( surf_lsm_h(0)%end_index(j,i) >= surf_lsm_h(0)%start_index(j,i) ) THEN |
---|
1180 | m = surf_lsm_h(0)%start_index(j,i) |
---|
1181 | sums_l(nzb,108,tn) = sums_l(nzb,108,tn) + & |
---|
1182 | SUM( surf_lsm_h(0)%frac(m,:) * & |
---|
1183 | surf_lsm_h(0)%rrtm_aldif(m,:) ) * rmask(j,i,sr) |
---|
1184 | sums_l(nzb,109,tn) = sums_l(nzb,109,tn) + & |
---|
1185 | SUM( surf_lsm_h(0)%frac(m,:) * & |
---|
1186 | surf_lsm_h(0)%rrtm_aldir(m,:) ) * rmask(j,i,sr) |
---|
1187 | sums_l(nzb,110,tn) = sums_l(nzb,110,tn) + & |
---|
1188 | SUM( surf_lsm_h(0)%frac(m,:) * & |
---|
1189 | surf_lsm_h(0)%rrtm_asdif(m,:) ) * rmask(j,i,sr) |
---|
1190 | sums_l(nzb,111,tn) = sums_l(nzb,111,tn) + & |
---|
1191 | SUM( surf_lsm_h(0)%frac(m,:) * & |
---|
1192 | surf_lsm_h(0)%rrtm_asdir(m,:) ) * rmask(j,i,sr) |
---|
1193 | ENDIF |
---|
1194 | IF ( surf_usm_h(0)%end_index(j,i) >= surf_usm_h(0)%start_index(j,i) ) THEN |
---|
1195 | m = surf_usm_h(0)%start_index(j,i) |
---|
1196 | sums_l(nzb,108,tn) = sums_l(nzb,108,tn) + & |
---|
1197 | SUM( surf_usm_h(0)%frac(m,:) * & |
---|
1198 | surf_usm_h(0)%rrtm_aldif(m,:) ) * rmask(j,i,sr) |
---|
1199 | sums_l(nzb,109,tn) = sums_l(nzb,109,tn) + & |
---|
1200 | SUM( surf_usm_h(0)%frac(m,:) * & |
---|
1201 | surf_usm_h(0)%rrtm_aldir(m,:) ) * rmask(j,i,sr) |
---|
1202 | sums_l(nzb,110,tn) = sums_l(nzb,110,tn) + & |
---|
1203 | SUM( surf_usm_h(0)%frac(m,:) * & |
---|
1204 | surf_usm_h(0)%rrtm_asdif(m,:) ) * rmask(j,i,sr) |
---|
1205 | sums_l(nzb,111,tn) = sums_l(nzb,111,tn) + & |
---|
1206 | SUM( surf_usm_h(0)%frac(m,:) * & |
---|
1207 | surf_usm_h(0)%rrtm_asdir(m,:) ) * rmask(j,i,sr) |
---|
1208 | ENDIF |
---|
1209 | |
---|
1210 | ENDIF |
---|
1211 | #endif |
---|
1212 | ENDIF |
---|
1213 | #endif |
---|
1214 | ! |
---|
1215 | !-- Subgridscale fluxes at the top surface |
---|
1216 | IF ( use_top_fluxes ) THEN |
---|
1217 | m = surf_def_h(2)%start_index(j,i) |
---|
1218 | !$ACC ATOMIC |
---|
1219 | sums_l(nzt,12,tn) = sums_l(nzt,12,tn) + & |
---|
1220 | momentumflux_output_conversion(nzt) * & |
---|
1221 | surf_def_h(2)%usws(m) * rmask(j,i,sr) ! w"u" |
---|
1222 | !$ACC ATOMIC |
---|
1223 | sums_l(nzt+1,12,tn) = sums_l(nzt+1,12,tn) + & |
---|
1224 | momentumflux_output_conversion(nzt+1) * & |
---|
1225 | surf_def_h(2)%usws(m) * rmask(j,i,sr) ! w"u" |
---|
1226 | !$ACC ATOMIC |
---|
1227 | sums_l(nzt,14,tn) = sums_l(nzt,14,tn) + & |
---|
1228 | momentumflux_output_conversion(nzt) * & |
---|
1229 | surf_def_h(2)%vsws(m) * rmask(j,i,sr) ! w"v" |
---|
1230 | !$ACC ATOMIC |
---|
1231 | sums_l(nzt+1,14,tn) = sums_l(nzt+1,14,tn) + & |
---|
1232 | momentumflux_output_conversion(nzt+1) * & |
---|
1233 | surf_def_h(2)%vsws(m) * rmask(j,i,sr) ! w"v" |
---|
1234 | !$ACC ATOMIC |
---|
1235 | sums_l(nzt,16,tn) = sums_l(nzt,16,tn) + & |
---|
1236 | heatflux_output_conversion(nzt) * & |
---|
1237 | surf_def_h(2)%shf(m) * rmask(j,i,sr) ! w"pt" |
---|
1238 | !$ACC ATOMIC |
---|
1239 | sums_l(nzt+1,16,tn) = sums_l(nzt+1,16,tn) + & |
---|
1240 | heatflux_output_conversion(nzt+1) * & |
---|
1241 | surf_def_h(2)%shf(m) * rmask(j,i,sr) ! w"pt" |
---|
1242 | #if 0 |
---|
1243 | sums_l(nzt:nzt+1,58,tn) = sums_l(nzt:nzt+1,58,tn) + & |
---|
1244 | 0.0_wp * rmask(j,i,sr) ! u"pt" |
---|
1245 | sums_l(nzt:nzt+1,61,tn) = sums_l(nzt:nzt+1,61,tn) + & |
---|
1246 | 0.0_wp * rmask(j,i,sr) ! v"pt" |
---|
1247 | #endif |
---|
1248 | #ifndef _OPENACC |
---|
1249 | IF ( ocean_mode ) THEN |
---|
1250 | sums_l(nzt,65,tn) = sums_l(nzt,65,tn) + & |
---|
1251 | surf_def_h(2)%sasws(m) * rmask(j,i,sr) ! w"sa" |
---|
1252 | ENDIF |
---|
1253 | IF ( humidity ) THEN |
---|
1254 | sums_l(nzt,48,tn) = sums_l(nzt,48,tn) + & |
---|
1255 | waterflux_output_conversion(nzt) * & |
---|
1256 | surf_def_h(2)%qsws(m) * rmask(j,i,sr) ! w"q" (w"qv") |
---|
1257 | sums_l(nzt,45,tn) = sums_l(nzt,45,tn) + ( & |
---|
1258 | ( 1.0_wp + 0.61_wp * q(nzt,j,i) ) * & |
---|
1259 | surf_def_h(2)%shf(m) + & |
---|
1260 | 0.61_wp * pt(nzt,j,i) * & |
---|
1261 | surf_def_h(2)%qsws(m) ) & |
---|
1262 | * heatflux_output_conversion(nzt) |
---|
1263 | IF ( cloud_droplets ) THEN |
---|
1264 | sums_l(nzt,45,tn) = sums_l(nzt,45,tn) + ( & |
---|
1265 | ( 1.0_wp + 0.61_wp * q(nzt,j,i) - & |
---|
1266 | ql(nzt,j,i) ) * & |
---|
1267 | surf_def_h(2)%shf(m) + & |
---|
1268 | 0.61_wp * pt(nzt,j,i) * & |
---|
1269 | surf_def_h(2)%qsws(m) ) & |
---|
1270 | * heatflux_output_conversion(nzt) |
---|
1271 | ENDIF |
---|
1272 | IF ( bulk_cloud_model ) THEN |
---|
1273 | ! |
---|
1274 | !-- Formula does not work if ql(nzb) /= 0.0 |
---|
1275 | sums_l(nzt,51,tn) = sums_l(nzt,51,tn) + & ! w"q" (w"qv") |
---|
1276 | waterflux_output_conversion(nzt) * & |
---|
1277 | surf_def_h(2)%qsws(m) * rmask(j,i,sr) |
---|
1278 | ENDIF |
---|
1279 | ENDIF |
---|
1280 | IF ( passive_scalar ) THEN |
---|
1281 | sums_l(nzt,117,tn) = sums_l(nzt,117,tn) + & |
---|
1282 | surf_def_h(2)%ssws(m) * rmask(j,i,sr) ! w"s" |
---|
1283 | ENDIF |
---|
1284 | #endif |
---|
1285 | ENDIF |
---|
1286 | |
---|
1287 | ! |
---|
1288 | !-- Resolved fluxes (can be computed for all horizontal points) |
---|
1289 | !-- NOTE: for simplicity, nzb_s_inner is used below, although strictly speaking the |
---|
1290 | !-- ---- following k-loop would have to be split up and rearranged according to the |
---|
1291 | !-- staggered grid. |
---|
1292 | DO k = nzb, nzt |
---|
1293 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 22 ) ) |
---|
1294 | ust = 0.5_wp * ( u(k,j,i) - hom(k,1,1,sr) + & |
---|
1295 | u(k+1,j,i) - hom(k+1,1,1,sr) ) |
---|
1296 | vst = 0.5_wp * ( v(k,j,i) - hom(k,1,2,sr) + & |
---|
1297 | v(k+1,j,i) - hom(k+1,1,2,sr) ) |
---|
1298 | pts = 0.5_wp * ( pt(k,j,i) - hom(k,1,4,sr) + & |
---|
1299 | pt(k+1,j,i) - hom(k+1,1,4,sr) ) |
---|
1300 | ! |
---|
1301 | !-- Higher moments |
---|
1302 | !$ACC ATOMIC |
---|
1303 | sums_l(k,35,tn) = sums_l(k,35,tn) + pts * w(k,j,i)**2 * rmask(j,i,sr) * flag |
---|
1304 | !$ACC ATOMIC |
---|
1305 | sums_l(k,36,tn) = sums_l(k,36,tn) + pts**2 * w(k,j,i) * rmask(j,i,sr) * flag |
---|
1306 | |
---|
1307 | ! |
---|
1308 | !-- Salinity flux and density (density does not belong to here, but so far there is no |
---|
1309 | !-- other suitable place to calculate) |
---|
1310 | #ifndef _OPENACC |
---|
1311 | IF ( ocean_mode ) THEN |
---|
1312 | IF( .NOT. ws_scheme_sca .OR. sr /= 0 ) THEN |
---|
1313 | pts = 0.5_wp * ( sa(k,j,i) - hom(k,1,23,sr) + & |
---|
1314 | sa(k+1,j,i) - hom(k+1,1,23,sr) ) |
---|
1315 | sums_l(k,66,tn) = sums_l(k,66,tn) + pts * w(k,j,i) * & |
---|
1316 | rmask(j,i,sr) * flag |
---|
1317 | ENDIF |
---|
1318 | sums_l(k,64,tn) = sums_l(k,64,tn) + rho_ocean(k,j,i) * rmask(j,i,sr) * flag |
---|
1319 | sums_l(k,71,tn) = sums_l(k,71,tn) + prho(k,j,i) * rmask(j,i,sr) * flag |
---|
1320 | ENDIF |
---|
1321 | |
---|
1322 | ! |
---|
1323 | !-- Buoyancy flux, water flux, humidity flux, liquid water content, rain drop |
---|
1324 | !-- concentration and rain water content |
---|
1325 | IF ( humidity ) THEN |
---|
1326 | IF ( bulk_cloud_model .OR. cloud_droplets ) THEN |
---|
1327 | pts = 0.5_wp * ( vpt(k,j,i) - hom(k,1,44,sr) + & |
---|
1328 | vpt(k+1,j,i) - hom(k+1,1,44,sr) ) |
---|
1329 | sums_l(k,46,tn) = sums_l(k,46,tn) + pts * w(k,j,i) * & |
---|
1330 | rho_air_zw(k) * & |
---|
1331 | heatflux_output_conversion(k) * & |
---|
1332 | rmask(j,i,sr) * flag |
---|
1333 | sums_l(k,54,tn) = sums_l(k,54,tn) + ql(k,j,i) * rmask(j,i,sr) * flag |
---|
1334 | |
---|
1335 | IF ( .NOT. cloud_droplets ) THEN |
---|
1336 | pts = 0.5_wp * & |
---|
1337 | ( ( q(k,j,i) - ql(k,j,i) ) - & |
---|
1338 | hom(k,1,42,sr) + & |
---|
1339 | ( q(k+1,j,i) - ql(k+1,j,i) ) - & |
---|
1340 | hom(k+1,1,42,sr) ) |
---|
1341 | sums_l(k,52,tn) = sums_l(k,52,tn) + pts * w(k,j,i) * & |
---|
1342 | rho_air_zw(k) * & |
---|
1343 | waterflux_output_conversion(k) * & |
---|
1344 | rmask(j,i,sr) * flag |
---|
1345 | sums_l(k,75,tn) = sums_l(k,75,tn) + qc(k,j,i) * rmask(j,i,sr) * flag |
---|
1346 | sums_l(k,76,tn) = sums_l(k,76,tn) + prr(k,j,i) * rmask(j,i,sr) * flag |
---|
1347 | IF ( microphysics_morrison ) THEN |
---|
1348 | sums_l(k,123,tn) = sums_l(k,123,tn) + nc(k,j,i) * rmask(j,i,sr) * flag |
---|
1349 | ENDIF |
---|
1350 | IF ( microphysics_ice_phase ) THEN |
---|
1351 | sums_l(k,124,tn) = sums_l(k,124,tn) + ni(k,j,i) * rmask(j,i,sr) * flag |
---|
1352 | sums_l(k,125,tn) = sums_l(k,125,tn) + qi(k,j,i) * rmask(j,i,sr) * flag |
---|
1353 | ENDIF |
---|
1354 | |
---|
1355 | IF ( microphysics_seifert ) THEN |
---|
1356 | sums_l(k,73,tn) = sums_l(k,73,tn) + nr(k,j,i) * rmask(j,i,sr) * flag |
---|
1357 | sums_l(k,74,tn) = sums_l(k,74,tn) + qr(k,j,i) * rmask(j,i,sr) * flag |
---|
1358 | ENDIF |
---|
1359 | ENDIF |
---|
1360 | |
---|
1361 | ELSE |
---|
1362 | IF( .NOT. ws_scheme_sca .OR. sr /= 0 ) THEN |
---|
1363 | pts = 0.5_wp * ( vpt(k,j,i) - hom(k,1,44,sr) + & |
---|
1364 | vpt(k+1,j,i) - hom(k+1,1,44,sr) ) |
---|
1365 | sums_l(k,46,tn) = sums_l(k,46,tn) + pts * w(k,j,i) * & |
---|
1366 | rho_air_zw(k) * & |
---|
1367 | heatflux_output_conversion(k) * & |
---|
1368 | rmask(j,i,sr) * flag |
---|
1369 | ELSE IF ( ws_scheme_sca .AND. sr == 0 ) THEN |
---|
1370 | sums_l(k,46,tn) = ( ( 1.0_wp + 0.61_wp * & |
---|
1371 | hom(k,1,41,sr) ) * & |
---|
1372 | sums_l(k,17,tn) + & |
---|
1373 | 0.61_wp * hom(k,1,4,sr) * & |
---|
1374 | sums_l(k,49,tn) & |
---|
1375 | ) * heatflux_output_conversion(k) * flag |
---|
1376 | END IF |
---|
1377 | END IF |
---|
1378 | ENDIF |
---|
1379 | ! |
---|
1380 | !-- Passive scalar flux |
---|
1381 | IF ( passive_scalar .AND. ( .NOT. ws_scheme_sca .OR. sr /= 0 ) ) THEN |
---|
1382 | pts = 0.5_wp * ( s(k,j,i) - hom(k,1,115,sr) + & |
---|
1383 | s(k+1,j,i) - hom(k+1,1,115,sr) ) |
---|
1384 | sums_l(k,114,tn) = sums_l(k,114,tn) + pts * w(k,j,i) * rmask(j,i,sr) * flag |
---|
1385 | ENDIF |
---|
1386 | #endif |
---|
1387 | |
---|
1388 | ! |
---|
1389 | !-- Energy flux w*e* |
---|
1390 | !-- has to be adjusted |
---|
1391 | !$ACC ATOMIC |
---|
1392 | sums_l(k,37,tn) = sums_l(k,37,tn) + w(k,j,i) * 0.5_wp * & |
---|
1393 | ( ust**2 + vst**2 + w(k,j,i)**2 ) & |
---|
1394 | * rho_air_zw(k) & |
---|
1395 | * momentumflux_output_conversion(k) & |
---|
1396 | * rmask(j,i,sr) * flag |
---|
1397 | ENDDO |
---|
1398 | ENDDO |
---|
1399 | ENDDO |
---|
1400 | !$OMP END PARALLEL |
---|
1401 | |
---|
1402 | !$ACC UPDATE & |
---|
1403 | !$ACC HOST(sums_l(:,12,tn), sums_l(:,14,tn), sums_l(:,16,tn)) & |
---|
1404 | !$ACC HOST(sums_l(:,35,tn), sums_l(:,36,tn), sums_l(:,37,tn)) |
---|
1405 | ! |
---|
1406 | !-- Treat land-surface quantities according to new wall model structure. |
---|
1407 | IF ( land_surface ) THEN |
---|
1408 | tn = 0 |
---|
1409 | !$OMP PARALLEL PRIVATE( i, j, m, tn ) |
---|
1410 | !$ tn = omp_get_thread_num() |
---|
1411 | !$OMP DO |
---|
1412 | DO m = 1, surf_lsm_h(0)%ns |
---|
1413 | i = surf_lsm_h(0)%i(m) |
---|
1414 | j = surf_lsm_h(0)%j(m) |
---|
1415 | |
---|
1416 | IF ( i >= nxl .AND. i <= nxr .AND. j >= nys .AND. j <= nyn ) THEN |
---|
1417 | sums_l(nzb,93,tn) = sums_l(nzb,93,tn) + surf_lsm_h(0)%ghf(m) * rmask(j,i,sr) |
---|
1418 | sums_l(nzb,94,tn) = sums_l(nzb,94,tn) + surf_lsm_h(0)%qsws_liq(m) * rmask(j,i,sr) |
---|
1419 | sums_l(nzb,95,tn) = sums_l(nzb,95,tn) + surf_lsm_h(0)%qsws_soil(m) * rmask(j,i,sr) |
---|
1420 | sums_l(nzb,96,tn) = sums_l(nzb,96,tn) + surf_lsm_h(0)%qsws_veg(m) * rmask(j,i,sr) |
---|
1421 | sums_l(nzb,97,tn) = sums_l(nzb,97,tn) + surf_lsm_h(0)%r_a(m) * rmask(j,i,sr) |
---|
1422 | sums_l(nzb,98,tn) = sums_l(nzb,98,tn) + surf_lsm_h(0)%r_s(m) * rmask(j,i,sr) |
---|
1423 | ENDIF |
---|
1424 | ENDDO |
---|
1425 | !$OMP END PARALLEL |
---|
1426 | |
---|
1427 | tn = 0 |
---|
1428 | !$OMP PARALLEL PRIVATE( i, j, k, m, tn ) |
---|
1429 | !$ tn = omp_get_thread_num() |
---|
1430 | !$OMP DO |
---|
1431 | DO m = 1, surf_lsm_h(0)%ns |
---|
1432 | |
---|
1433 | i = surf_lsm_h(0)%i(m) |
---|
1434 | j = surf_lsm_h(0)%j(m) |
---|
1435 | |
---|
1436 | IF ( i >= nxl .AND. i <= nxr .AND. j >= nys .AND. j <= nyn ) THEN |
---|
1437 | |
---|
1438 | DO k = nzb_soil, nzt_soil |
---|
1439 | sums_l(k,89,tn) = sums_l(k,89,tn) + t_soil_h(0)%var_2d(k,m) * rmask(j,i,sr) |
---|
1440 | sums_l(k,91,tn) = sums_l(k,91,tn) + m_soil_h(0)%var_2d(k,m) * rmask(j,i,sr) |
---|
1441 | ENDDO |
---|
1442 | ENDIF |
---|
1443 | ENDDO |
---|
1444 | !$OMP END PARALLEL |
---|
1445 | ENDIF |
---|
1446 | ! |
---|
1447 | !-- For speed optimization fluxes which have been computed in part directly inside the WS |
---|
1448 | !-- advection routines are treated seperatly. |
---|
1449 | !-- Momentum fluxes first: |
---|
1450 | |
---|
1451 | tn = 0 |
---|
1452 | !$OMP PARALLEL PRIVATE( i, j, k, tn, flag ) |
---|
1453 | !$ tn = omp_get_thread_num() |
---|
1454 | IF ( .NOT. ws_scheme_mom .OR. sr /= 0 ) THEN |
---|
1455 | !$OMP DO |
---|
1456 | DO i = nxl, nxr |
---|
1457 | DO j = nys, nyn |
---|
1458 | DO k = nzb, nzt |
---|
1459 | ! |
---|
1460 | !-- Flag 23 is used to mask surface fluxes as well as model-top fluxes, which are |
---|
1461 | !-- added further below. |
---|
1462 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 23 ) ) * & |
---|
1463 | MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 9 ) ) |
---|
1464 | |
---|
1465 | ust = 0.5_wp * ( u(k,j,i) - hom(k,1,1,sr) + & |
---|
1466 | u(k+1,j,i) - hom(k+1,1,1,sr) ) |
---|
1467 | vst = 0.5_wp * ( v(k,j,i) - hom(k,1,2,sr) + & |
---|
1468 | v(k+1,j,i) - hom(k+1,1,2,sr) ) |
---|
1469 | ! |
---|
1470 | !-- Momentum flux w*u* |
---|
1471 | sums_l(k,13,tn) = sums_l(k,13,tn) + 0.5_wp * & |
---|
1472 | ( w(k,j,i-1) + w(k,j,i) ) & |
---|
1473 | * rho_air_zw(k) & |
---|
1474 | * momentumflux_output_conversion(k) & |
---|
1475 | * ust * rmask(j,i,sr) & |
---|
1476 | * flag |
---|
1477 | ! |
---|
1478 | !-- Momentum flux w*v* |
---|
1479 | sums_l(k,15,tn) = sums_l(k,15,tn) + 0.5_wp * ( w(k,j-1,i) + w(k,j,i) ) & |
---|
1480 | * rho_air_zw(k) & |
---|
1481 | * momentumflux_output_conversion(k) & |
---|
1482 | * vst * rmask(j,i,sr) & |
---|
1483 | * flag |
---|
1484 | ENDDO |
---|
1485 | ENDDO |
---|
1486 | ENDDO |
---|
1487 | |
---|
1488 | ENDIF |
---|
1489 | IF ( .NOT. ws_scheme_sca .OR. sr /= 0 ) THEN |
---|
1490 | !$OMP DO |
---|
1491 | DO i = nxl, nxr |
---|
1492 | DO j = nys, nyn |
---|
1493 | DO k = nzb, nzt |
---|
1494 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 23 ) ) * & |
---|
1495 | MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 9 ) ) |
---|
1496 | ! |
---|
1497 | !-- Vertical heat flux |
---|
1498 | sums_l(k,17,tn) = sums_l(k,17,tn) + 0.5_wp * & |
---|
1499 | ( pt(k,j,i) - hom(k,1,4,sr) + & |
---|
1500 | pt(k+1,j,i) - hom(k+1,1,4,sr) ) & |
---|
1501 | * rho_air_zw(k) & |
---|
1502 | * heatflux_output_conversion(k) & |
---|
1503 | * w(k,j,i) * rmask(j,i,sr) * flag |
---|
1504 | IF ( humidity ) THEN |
---|
1505 | pts = 0.5_wp * ( q(k,j,i) - hom(k,1,41,sr) + & |
---|
1506 | q(k+1,j,i) - hom(k+1,1,41,sr) ) |
---|
1507 | sums_l(k,49,tn) = sums_l(k,49,tn) + pts * w(k,j,i) * & |
---|
1508 | rho_air_zw(k) * & |
---|
1509 | waterflux_output_conversion(k) * & |
---|
1510 | rmask(j,i,sr) * flag |
---|
1511 | ENDIF |
---|
1512 | IF ( passive_scalar ) THEN |
---|
1513 | pts = 0.5_wp * ( s(k,j,i) - hom(k,1,115,sr) + & |
---|
1514 | s(k+1,j,i) - hom(k+1,1,115,sr) ) |
---|
1515 | sums_l(k,114,tn) = sums_l(k,114,tn) + pts * w(k,j,i) * rmask(j,i,sr) * flag |
---|
1516 | ENDIF |
---|
1517 | ENDDO |
---|
1518 | ENDDO |
---|
1519 | ENDDO |
---|
1520 | |
---|
1521 | ENDIF |
---|
1522 | |
---|
1523 | ! |
---|
1524 | !-- Density at top follows Neumann condition |
---|
1525 | IF ( ocean_mode ) THEN |
---|
1526 | sums_l(nzt+1,64,tn) = sums_l(nzt,64,tn) |
---|
1527 | sums_l(nzt+1,71,tn) = sums_l(nzt,71,tn) |
---|
1528 | ENDIF |
---|
1529 | |
---|
1530 | ! |
---|
1531 | !-- Divergence of vertical flux of resolved scale energy and pressure fluctuations as well as |
---|
1532 | !-- flux of pressure fluctuation itself (68). |
---|
1533 | !-- First calculate the products, then the divergence. |
---|
1534 | !-- Calculation is time consuming. Do it only, if profiles shall be plotted. |
---|
1535 | IF ( hom(nzb+1,2,55,0) /= 0.0_wp .OR. hom(nzb+1,2,68,0) /= 0.0_wp ) THEN |
---|
1536 | sums_ll = 0.0_wp ! local array |
---|
1537 | |
---|
1538 | !$OMP DO |
---|
1539 | DO i = nxl, nxr |
---|
1540 | DO j = nys, nyn |
---|
1541 | DO k = nzb+1, nzt |
---|
1542 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
1543 | |
---|
1544 | sums_ll(k,1) = sums_ll(k,1) + 0.5_wp * w(k,j,i) * ( & |
---|
1545 | ( 0.25_wp * ( u(k,j,i)+u(k+1,j,i)+u(k,j,i+1)+u(k+1,j,i+1) ) & |
---|
1546 | - 0.5_wp * ( hom(k,1,1,sr) + hom(k+1,1,1,sr) ) )**2 & |
---|
1547 | + ( 0.25_wp * ( v(k,j,i)+v(k+1,j,i)+v(k,j+1,i)+v(k+1,j+1,i) ) & |
---|
1548 | - 0.5_wp * ( hom(k,1,2,sr) + hom(k+1,1,2,sr) ) )**2 & |
---|
1549 | + w(k,j,i)**2 ) * flag * rmask(j,i,sr) |
---|
1550 | |
---|
1551 | sums_ll(k,2) = sums_ll(k,2) + 0.5_wp * w(k,j,i) & |
---|
1552 | * ( ( p(k,j,i) + p(k+1,j,i) ) & |
---|
1553 | / momentumflux_output_conversion(k) ) & |
---|
1554 | * flag * rmask(j,i,sr) |
---|
1555 | |
---|
1556 | ENDDO |
---|
1557 | ENDDO |
---|
1558 | ENDDO |
---|
1559 | sums_ll(0,1) = 0.0_wp ! because w is zero at the bottom |
---|
1560 | sums_ll(nzt+1,1) = 0.0_wp |
---|
1561 | sums_ll(0,2) = 0.0_wp |
---|
1562 | sums_ll(nzt+1,2) = 0.0_wp |
---|
1563 | |
---|
1564 | DO k = nzb+1, nzt |
---|
1565 | sums_l(k,55,tn) = ( sums_ll(k,1) - sums_ll(k-1,1) ) * ddzw(k) |
---|
1566 | sums_l(k,56,tn) = ( sums_ll(k,2) - sums_ll(k-1,2) ) * ddzw(k) |
---|
1567 | sums_l(k,68,tn) = sums_ll(k,2) |
---|
1568 | ENDDO |
---|
1569 | sums_l(nzb,55,tn) = sums_l(nzb+1,55,tn) |
---|
1570 | sums_l(nzb,56,tn) = sums_l(nzb+1,56,tn) |
---|
1571 | sums_l(nzb,68,tn) = 0.0_wp ! because w* = 0 at nzb |
---|
1572 | |
---|
1573 | ENDIF |
---|
1574 | |
---|
1575 | ! |
---|
1576 | !-- Divergence of vertical flux of SGS TKE and the flux itself (69) |
---|
1577 | IF ( hom(nzb+1,2,57,0) /= 0.0_wp .OR. hom(nzb+1,2,69,0) /= 0.0_wp ) THEN |
---|
1578 | !$OMP DO |
---|
1579 | DO i = nxl, nxr |
---|
1580 | DO j = nys, nyn |
---|
1581 | DO k = nzb+1, nzt |
---|
1582 | |
---|
1583 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
1584 | |
---|
1585 | sums_l(k,57,tn) = sums_l(k,57,tn) - 0.5_wp * ( & |
---|
1586 | (km(k,j,i)+km(k+1,j,i)) * (e(k+1,j,i)-e(k,j,i)) * ddzu(k+1) & |
---|
1587 | - (km(k-1,j,i)+km(k,j,i)) * (e(k,j,i)-e(k-1,j,i)) * ddzu(k) & |
---|
1588 | ) * ddzw(k) & |
---|
1589 | * flag * rmask(j,i,sr) |
---|
1590 | |
---|
1591 | sums_l(k,69,tn) = sums_l(k,69,tn) - 0.5_wp * ( & |
---|
1592 | ( km(k,j,i) + km(k+1,j,i) ) * & |
---|
1593 | ( e(k+1,j,i) - e(k,j,i) ) * ddzu(k+1) & |
---|
1594 | ) * flag * rmask(j,i,sr) |
---|
1595 | |
---|
1596 | ENDDO |
---|
1597 | ENDDO |
---|
1598 | ENDDO |
---|
1599 | sums_l(nzb,57,tn) = sums_l(nzb+1,57,tn) |
---|
1600 | sums_l(nzb,69,tn) = sums_l(nzb+1,69,tn) |
---|
1601 | |
---|
1602 | ENDIF |
---|
1603 | |
---|
1604 | ! |
---|
1605 | !-- Horizontal heat fluxes (subgrid, resolved, total). |
---|
1606 | !-- Do it only, if profiles shall be plotted. |
---|
1607 | IF ( hom(nzb+1,2,58,0) /= 0.0_wp ) THEN |
---|
1608 | |
---|
1609 | !$OMP DO |
---|
1610 | DO i = nxl, nxr |
---|
1611 | DO j = nys, nyn |
---|
1612 | DO k = nzb+1, nzt |
---|
1613 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
1614 | ! |
---|
1615 | !-- Subgrid horizontal heat fluxes u"pt", v"pt" |
---|
1616 | sums_l(k,58,tn) = sums_l(k,58,tn) - 0.5_wp * & |
---|
1617 | ( kh(k,j,i) + kh(k,j,i-1) ) & |
---|
1618 | * ( pt(k,j,i-1) - pt(k,j,i) ) & |
---|
1619 | * rho_air_zw(k) & |
---|
1620 | * heatflux_output_conversion(k) & |
---|
1621 | * ddx * rmask(j,i,sr) * flag |
---|
1622 | sums_l(k,61,tn) = sums_l(k,61,tn) - 0.5_wp * & |
---|
1623 | ( kh(k,j,i) + kh(k,j-1,i) ) & |
---|
1624 | * ( pt(k,j-1,i) - pt(k,j,i) ) & |
---|
1625 | * rho_air_zw(k) & |
---|
1626 | * heatflux_output_conversion(k) & |
---|
1627 | * ddy * rmask(j,i,sr) * flag |
---|
1628 | ! |
---|
1629 | !-- Resolved horizontal heat fluxes u*pt*, v*pt* |
---|
1630 | sums_l(k,59,tn) = sums_l(k,59,tn) + ( u(k,j,i) - hom(k,1,1,sr) ) & |
---|
1631 | * 0.5_wp * ( pt(k,j,i-1) - hom(k,1,4,sr) + & |
---|
1632 | pt(k,j,i) - hom(k,1,4,sr) ) & |
---|
1633 | * heatflux_output_conversion(k) & |
---|
1634 | * flag |
---|
1635 | pts = 0.5_wp * ( pt(k,j-1,i) - hom(k,1,4,sr) + & |
---|
1636 | pt(k,j,i) - hom(k,1,4,sr) ) |
---|
1637 | sums_l(k,62,tn) = sums_l(k,62,tn) + ( v(k,j,i) - hom(k,1,2,sr) ) & |
---|
1638 | * 0.5_wp * ( pt(k,j-1,i) - hom(k,1,4,sr) + & |
---|
1639 | pt(k,j,i) - hom(k,1,4,sr) ) & |
---|
1640 | * heatflux_output_conversion(k) & |
---|
1641 | * flag |
---|
1642 | ENDDO |
---|
1643 | ENDDO |
---|
1644 | ENDDO |
---|
1645 | ! |
---|
1646 | !-- Fluxes at the surface must be zero (e.g. due to the Prandtl-layer) |
---|
1647 | sums_l(nzb,58,tn) = 0.0_wp |
---|
1648 | sums_l(nzb,59,tn) = 0.0_wp |
---|
1649 | sums_l(nzb,60,tn) = 0.0_wp |
---|
1650 | sums_l(nzb,61,tn) = 0.0_wp |
---|
1651 | sums_l(nzb,62,tn) = 0.0_wp |
---|
1652 | sums_l(nzb,63,tn) = 0.0_wp |
---|
1653 | |
---|
1654 | ENDIF |
---|
1655 | !$OMP END PARALLEL |
---|
1656 | |
---|
1657 | ! |
---|
1658 | !-- Collect current large scale advection and subsidence tendencies for |
---|
1659 | !-- data output |
---|
1660 | IF ( large_scale_forcing .AND. ( simulated_time > 0.0_wp ) ) THEN |
---|
1661 | ! |
---|
1662 | !-- Interpolation in time of LSF_DATA |
---|
1663 | nt = 1 |
---|
1664 | DO WHILE ( simulated_time - dt_3d > time_vert(nt) ) |
---|
1665 | nt = nt + 1 |
---|
1666 | ENDDO |
---|
1667 | IF ( simulated_time - dt_3d /= time_vert(nt) ) THEN |
---|
1668 | nt = nt - 1 |
---|
1669 | ENDIF |
---|
1670 | |
---|
1671 | fac = ( simulated_time - dt_3d - time_vert(nt) ) / ( time_vert(nt+1)-time_vert(nt) ) |
---|
1672 | |
---|
1673 | |
---|
1674 | DO k = nzb, nzt |
---|
1675 | sums_ls_l(k,0) = td_lsa_lpt(k,nt) + fac * ( td_lsa_lpt(k,nt+1) - td_lsa_lpt(k,nt) ) |
---|
1676 | sums_ls_l(k,1) = td_lsa_q(k,nt) + fac * ( td_lsa_q(k,nt+1) - td_lsa_q(k,nt) ) |
---|
1677 | ENDDO |
---|
1678 | |
---|
1679 | sums_ls_l(nzt+1,0) = sums_ls_l(nzt,0) |
---|
1680 | sums_ls_l(nzt+1,1) = sums_ls_l(nzt,1) |
---|
1681 | |
---|
1682 | IF ( large_scale_subsidence .AND. use_subsidence_tendencies ) THEN |
---|
1683 | |
---|
1684 | DO k = nzb, nzt |
---|
1685 | sums_ls_l(k,2) = td_sub_lpt(k,nt) + fac * ( td_sub_lpt(k,nt+1) - td_sub_lpt(k,nt) ) |
---|
1686 | sums_ls_l(k,3) = td_sub_q(k,nt) + fac * ( td_sub_q(k,nt+1) - td_sub_q(k,nt) ) |
---|
1687 | ENDDO |
---|
1688 | |
---|
1689 | sums_ls_l(nzt+1,2) = sums_ls_l(nzt,2) |
---|
1690 | sums_ls_l(nzt+1,3) = sums_ls_l(nzt,3) |
---|
1691 | |
---|
1692 | ENDIF |
---|
1693 | |
---|
1694 | ENDIF |
---|
1695 | |
---|
1696 | tn = 0 |
---|
1697 | !$OMP PARALLEL PRIVATE( i, j, k, tn ) |
---|
1698 | !$ tn = omp_get_thread_num() |
---|
1699 | IF ( radiation .AND. radiation_scheme == 'rrtmg' ) THEN |
---|
1700 | !$OMP DO |
---|
1701 | DO i = nxl, nxr |
---|
1702 | DO j = nys, nyn |
---|
1703 | DO k = nzb+1, nzt+1 |
---|
1704 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_total_0(k,j,i), 0 ) ) |
---|
1705 | |
---|
1706 | sums_l(k,100,tn) = sums_l(k,100,tn) + rad_lw_in(k,j,i) * rmask(j,i,sr) * flag |
---|
1707 | sums_l(k,101,tn) = sums_l(k,101,tn) + rad_lw_out(k,j,i) * rmask(j,i,sr) * flag |
---|
1708 | sums_l(k,102,tn) = sums_l(k,102,tn) + rad_sw_in(k,j,i) * rmask(j,i,sr) * flag |
---|
1709 | sums_l(k,103,tn) = sums_l(k,103,tn) + rad_sw_out(k,j,i) * rmask(j,i,sr) * flag |
---|
1710 | sums_l(k,104,tn) = sums_l(k,104,tn) + rad_lw_cs_hr(k,j,i) * rmask(j,i,sr) * flag |
---|
1711 | sums_l(k,105,tn) = sums_l(k,105,tn) + rad_lw_hr(k,j,i) * rmask(j,i,sr) * flag |
---|
1712 | sums_l(k,106,tn) = sums_l(k,106,tn) + rad_sw_cs_hr(k,j,i) * rmask(j,i,sr) * flag |
---|
1713 | sums_l(k,107,tn) = sums_l(k,107,tn) + rad_sw_hr(k,j,i) * rmask(j,i,sr) * flag |
---|
1714 | ENDDO |
---|
1715 | ENDDO |
---|
1716 | ENDDO |
---|
1717 | ENDIF |
---|
1718 | |
---|
1719 | ! |
---|
1720 | !-- Calculate the profiles for all other modules |
---|
1721 | CALL module_interface_statistics( 'profiles', sr, tn, dots_max ) |
---|
1722 | !$OMP END PARALLEL |
---|
1723 | |
---|
1724 | ! |
---|
1725 | !-- Summation of thread sums |
---|
1726 | IF ( threads_per_task > 1 ) THEN |
---|
1727 | DO i = 1, threads_per_task-1 |
---|
1728 | sums_l(:,3,0) = sums_l(:,3,0) + sums_l(:,3,i) |
---|
1729 | sums_l(:,4:40,0) = sums_l(:,4:40,0) + sums_l(:,4:40,i) |
---|
1730 | sums_l(:,45:pr_palm,0) = sums_l(:,45:pr_palm,0) + & |
---|
1731 | sums_l(:,45:pr_palm,i) |
---|
1732 | IF ( max_pr_user > 0 ) THEN |
---|
1733 | sums_l(:,pr_palm+1:pr_palm+max_pr_user,0) = & |
---|
1734 | sums_l(:,pr_palm+1:pr_palm+max_pr_user,0) + & |
---|
1735 | sums_l(:,pr_palm+1:pr_palm+max_pr_user,i) |
---|
1736 | ENDIF |
---|
1737 | |
---|
1738 | IF ( air_chemistry ) THEN |
---|
1739 | IF ( max_pr_cs > 0 ) THEN |
---|
1740 | sums_l(:,pr_palm+max_pr_user+1:pr_palm + max_pr_user+ max_pr_cs,0) = & |
---|
1741 | sums_l(:,pr_palm+max_pr_user+1:pr_palm + max_pr_user+max_pr_cs,0) + & |
---|
1742 | sums_l(:,pr_palm+max_pr_user+1:pr_palm + max_pr_user+max_pr_cs,i) |
---|
1743 | |
---|
1744 | ENDIF |
---|
1745 | ENDIF |
---|
1746 | IF ( salsa ) THEN |
---|
1747 | IF ( max_pr_cs > 0 ) THEN |
---|
1748 | sums_l(:,pr_palm+max_pr_user+max_pr_cs+1:pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0) = & |
---|
1749 | sums_l(:,pr_palm+max_pr_user+max_pr_cs+1:pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,0) + & |
---|
1750 | sums_l(:,pr_palm+max_pr_user+max_pr_cs+1:pr_palm+max_pr_user+max_pr_cs+max_pr_salsa,i) |
---|
1751 | |
---|
1752 | ENDIF |
---|
1753 | ENDIF |
---|
1754 | ENDDO |
---|
1755 | ENDIF |
---|
1756 | |
---|
1757 | #if defined( __parallel ) |
---|
1758 | |
---|
1759 | ! |
---|
1760 | !-- Compute total sum from local sums |
---|
1761 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1762 | CALL MPI_ALLREDUCE( sums_l(nzb,1,0), sums(nzb,1), ngp_sums, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1763 | IF ( large_scale_forcing ) THEN |
---|
1764 | CALL MPI_ALLREDUCE( sums_ls_l(nzb,2), sums(nzb,83), ngp_sums_ls, MPI_REAL, MPI_SUM, & |
---|
1765 | comm2d, ierr ) |
---|
1766 | ENDIF |
---|
1767 | |
---|
1768 | IF ( air_chemistry .AND. max_pr_cs > 0 ) THEN |
---|
1769 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1770 | DO i = 1, max_pr_cs |
---|
1771 | CALL MPI_ALLREDUCE( sums_l(nzb,pr_palm+max_pr_user+i,0), & |
---|
1772 | sums(nzb,pr_palm+max_pr_user+i), & |
---|
1773 | nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1774 | ENDDO |
---|
1775 | ENDIF |
---|
1776 | |
---|
1777 | IF ( salsa .AND. max_pr_salsa > 0 ) THEN |
---|
1778 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
1779 | DO i = 1, max_pr_salsa |
---|
1780 | CALL MPI_ALLREDUCE( sums_l(nzb,pr_palm+max_pr_user+max_pr_cs+i,0), & |
---|
1781 | sums(nzb,pr_palm+max_pr_user+max_pr_user+i), & |
---|
1782 | nzt+2-nzb, MPI_REAL, MPI_SUM, comm2d, ierr ) |
---|
1783 | ENDDO |
---|
1784 | ENDIF |
---|
1785 | |
---|
1786 | #else |
---|
1787 | sums = sums_l(:,:,0) |
---|
1788 | IF ( large_scale_forcing ) THEN |
---|
1789 | sums(:,81:88) = sums_ls_l |
---|
1790 | ENDIF |
---|
1791 | #endif |
---|
1792 | |
---|
1793 | ! |
---|
1794 | !-- Final values are obtained by division by the total number of grid points used for summation. |
---|
1795 | !-- After that store profiles. |
---|
1796 | !-- Check, if statistical regions do contain at least one grid point at the respective k-level, |
---|
1797 | !-- otherwise division by zero will lead to undefined values, which may cause e.g. problems with |
---|
1798 | !-- NetCDF output. |
---|
1799 | !-- Profiles: |
---|
1800 | DO k = nzb, nzt+1 |
---|
1801 | sums(k,3) = sums(k,3) / ngp_2dh(sr) |
---|
1802 | sums(k,12:22) = sums(k,12:22) / ngp_2dh(sr) |
---|
1803 | sums(k,30:32) = sums(k,30:32) / ngp_2dh(sr) |
---|
1804 | sums(k,35:39) = sums(k,35:39) / ngp_2dh(sr) |
---|
1805 | sums(k,45:53) = sums(k,45:53) / ngp_2dh(sr) |
---|
1806 | sums(k,55:63) = sums(k,55:63) / ngp_2dh(sr) |
---|
1807 | sums(k,81:88) = sums(k,81:88) / ngp_2dh(sr) |
---|
1808 | sums(k,89:112) = sums(k,89:112) / ngp_2dh(sr) |
---|
1809 | sums(k,114) = sums(k,114) / ngp_2dh(sr) |
---|
1810 | sums(k,117) = sums(k,117) / ngp_2dh(sr) |
---|
1811 | IF ( ngp_2dh_s_inner(k,sr) /= 0 ) THEN |
---|
1812 | sums(k,8:11) = sums(k,8:11) / ngp_2dh_s_inner(k,sr) |
---|
1813 | sums(k,23:29) = sums(k,23:29) / ngp_2dh_s_inner(k,sr) |
---|
1814 | sums(k,33:34) = sums(k,33:34) / ngp_2dh_s_inner(k,sr) |
---|
1815 | sums(k,40) = sums(k,40) / ngp_2dh_s_inner(k,sr) |
---|
1816 | sums(k,54) = sums(k,54) / ngp_2dh_s_inner(k,sr) |
---|
1817 | sums(k,64) = sums(k,64) / ngp_2dh_s_inner(k,sr) |
---|
1818 | sums(k,70:80) = sums(k,70:80) / ngp_2dh_s_inner(k,sr) |
---|
1819 | sums(k,116) = sums(k,116) / ngp_2dh_s_inner(k,sr) |
---|
1820 | sums(k,118:pr_palm-2) = sums(k,118:pr_palm-2) / ngp_2dh_s_inner(k,sr) |
---|
1821 | sums(k,123:125) = sums(k,123:125) * ngp_2dh_s_inner(k,sr) / ngp_2dh(sr) |
---|
1822 | ENDIF |
---|
1823 | ENDDO |
---|
1824 | |
---|
1825 | !-- u* and so on |
---|
1826 | !-- As sums(nzb:nzb+3,pr_palm) are full 2D arrays (us, usws, vsws, ts) whose size is always |
---|
1827 | !-- ( nx + 1 ) * ( ny + 1 ), defined at the first grid layer above the topography, they are |
---|
1828 | !-- divided by ngp_2dh(sr) |
---|
1829 | sums(nzb:nzb+3,pr_palm) = sums(nzb:nzb+3,pr_palm) / ngp_2dh(sr) |
---|
1830 | sums(nzb+12,pr_palm) = sums(nzb+12,pr_palm) / ngp_2dh(sr) ! qs |
---|
1831 | sums(nzb+13,pr_palm) = sums(nzb+13,pr_palm) / ngp_2dh(sr) ! ss |
---|
1832 | sums(nzb+14,pr_palm) = sums(nzb+14,pr_palm) / ngp_2dh(sr) ! surface temperature |
---|
1833 | |
---|
1834 | !-- eges, e* |
---|
1835 | sums(nzb+4:nzb+5,pr_palm) = sums(nzb+4:nzb+5,pr_palm) / ngp_3d(sr) |
---|
1836 | !-- Old and new divergence |
---|
1837 | sums(nzb+9:nzb+10,pr_palm) = sums(nzb+9:nzb+10,pr_palm) / ngp_3d_inner(sr) |
---|
1838 | |
---|
1839 | !-- User-defined profiles |
---|
1840 | IF ( max_pr_user > 0 ) THEN |
---|
1841 | DO k = nzb, nzt+1 |
---|
1842 | sums(k,pr_palm+1:pr_palm+max_pr_user) = sums(k,pr_palm+1:pr_palm+max_pr_user) / & |
---|
1843 | ngp_2dh_s_inner(k,sr) |
---|
1844 | ENDDO |
---|
1845 | ENDIF |
---|
1846 | |
---|
1847 | IF ( air_chemistry ) THEN |
---|
1848 | IF ( max_pr_cs > 0 ) THEN |
---|
1849 | DO k = nzb, nzt+1 |
---|
1850 | sums(k, pr_palm+1:pr_palm+max_pr_user+max_pr_cs) = & |
---|
1851 | sums(k, pr_palm+1:pr_palm+max_pr_user+max_pr_cs) / & |
---|
1852 | ngp_2dh_s_inner(k,sr) |
---|
1853 | ENDDO |
---|
1854 | ENDIF |
---|
1855 | ENDIF |
---|
1856 | |
---|
1857 | IF ( salsa ) THEN |
---|
1858 | IF ( max_pr_salsa > 0 ) THEN |
---|
1859 | DO k = nzb, nzt+1 |
---|
1860 | sums(k,pr_palm+max_pr_user+max_pr_cs+1:pr_palm+max_pr_user+max_pr_cs+max_pr_salsa) = & |
---|
1861 | sums(k,pr_palm+max_pr_user+max_pr_cs+1:pr_palm+max_pr_user+max_pr_cs+max_pr_salsa) & |
---|
1862 | / ngp_2dh_s_inner(k,sr) |
---|
1863 | ENDDO |
---|
1864 | ENDIF |
---|
1865 | ENDIF |
---|
1866 | |
---|
1867 | ! |
---|
1868 | !-- Collect horizontal average in hom. |
---|
1869 | !-- Compute deduced averages (e.g. total heat flux) |
---|
1870 | hom(:,1,3,sr) = sums(:,3) ! w |
---|
1871 | hom(:,1,8,sr) = sums(:,8) ! e profiles 5-7 are initial profiles |
---|
1872 | hom(:,1,9,sr) = sums(:,9) ! km |
---|
1873 | hom(:,1,10,sr) = sums(:,10) ! kh |
---|
1874 | hom(:,1,11,sr) = sums(:,11) ! l |
---|
1875 | hom(:,1,12,sr) = sums(:,12) ! w"u" |
---|
1876 | hom(:,1,13,sr) = sums(:,13) ! w*u* |
---|
1877 | hom(:,1,14,sr) = sums(:,14) ! w"v" |
---|
1878 | hom(:,1,15,sr) = sums(:,15) ! w*v* |
---|
1879 | hom(:,1,16,sr) = sums(:,16) ! w"pt" |
---|
1880 | hom(:,1,17,sr) = sums(:,17) ! w*pt* |
---|
1881 | hom(:,1,18,sr) = sums(:,16) + sums(:,17) ! wpt |
---|
1882 | hom(:,1,19,sr) = sums(:,12) + sums(:,13) ! wu |
---|
1883 | hom(:,1,20,sr) = sums(:,14) + sums(:,15) ! wv |
---|
1884 | hom(:,1,21,sr) = sums(:,21) ! w*pt*BC |
---|
1885 | hom(:,1,22,sr) = sums(:,16) + sums(:,21) ! wptBC |
---|
1886 | ! profile 24 is initial profile (sa) |
---|
1887 | ! profiles 25-29 left empty for initial |
---|
1888 | ! profiles |
---|
1889 | hom(:,1,30,sr) = sums(:,30) ! u*2 |
---|
1890 | hom(:,1,31,sr) = sums(:,31) ! v*2 |
---|
1891 | hom(:,1,32,sr) = sums(:,32) ! w*2 |
---|
1892 | hom(:,1,33,sr) = sums(:,33) ! pt*2 |
---|
1893 | hom(:,1,34,sr) = sums(:,34) ! e* |
---|
1894 | hom(:,1,35,sr) = sums(:,35) ! w*2pt* |
---|
1895 | hom(:,1,36,sr) = sums(:,36) ! w*pt*2 |
---|
1896 | hom(:,1,37,sr) = sums(:,37) ! w*e* |
---|
1897 | hom(:,1,38,sr) = sums(:,38) ! w*3 |
---|
1898 | hom(:,1,39,sr) = sums(:,38) / ( ABS( sums(:,32) ) + 1E-20_wp )**1.5_wp ! Sw |
---|
1899 | hom(:,1,40,sr) = sums(:,40) ! p |
---|
1900 | hom(:,1,45,sr) = sums(:,45) ! w"vpt" |
---|
1901 | hom(:,1,46,sr) = sums(:,46) ! w*vpt* |
---|
1902 | hom(:,1,47,sr) = sums(:,45) + sums(:,46) ! wvpt |
---|
1903 | hom(:,1,48,sr) = sums(:,48) ! w"q" (w"qv") |
---|
1904 | hom(:,1,49,sr) = sums(:,49) ! w*q* (w*qv*) |
---|
1905 | hom(:,1,50,sr) = sums(:,48) + sums(:,49) ! wq (wqv) |
---|
1906 | hom(:,1,51,sr) = sums(:,51) ! w"qv" |
---|
1907 | hom(:,1,52,sr) = sums(:,52) ! w*qv* |
---|
1908 | hom(:,1,53,sr) = sums(:,52) + sums(:,51) ! wq (wqv) |
---|
1909 | hom(:,1,54,sr) = sums(:,54) ! ql |
---|
1910 | hom(:,1,55,sr) = sums(:,55) ! w*u*u*/dz |
---|
1911 | hom(:,1,56,sr) = sums(:,56) ! w*p*/dz |
---|
1912 | hom(:,1,57,sr) = sums(:,57) ! ( w"e + w"p"/rho_ocean )/dz |
---|
1913 | hom(:,1,58,sr) = sums(:,58) ! u"pt" |
---|
1914 | hom(:,1,59,sr) = sums(:,59) ! u*pt* |
---|
1915 | hom(:,1,60,sr) = sums(:,58) + sums(:,59) ! upt_t |
---|
1916 | hom(:,1,61,sr) = sums(:,61) ! v"pt" |
---|
1917 | hom(:,1,62,sr) = sums(:,62) ! v*pt* |
---|
1918 | hom(:,1,63,sr) = sums(:,61) + sums(:,62) ! vpt_t |
---|
1919 | hom(:,1,64,sr) = sums(:,64) ! rho_ocean |
---|
1920 | hom(:,1,65,sr) = sums(:,65) ! w"sa" |
---|
1921 | hom(:,1,66,sr) = sums(:,66) ! w*sa* |
---|
1922 | hom(:,1,67,sr) = sums(:,65) + sums(:,66) ! wsa |
---|
1923 | hom(:,1,68,sr) = sums(:,68) ! w*p* |
---|
1924 | hom(:,1,69,sr) = sums(:,69) ! w"e + w"p"/rho_ocean |
---|
1925 | hom(:,1,70,sr) = sums(:,70) ! q*2 |
---|
1926 | hom(:,1,71,sr) = sums(:,71) ! prho |
---|
1927 | hom(:,1,72,sr) = hyp * 1E-2_wp ! hyp in hPa |
---|
1928 | hom(:,1,123,sr) = sums(:,123) ! nc |
---|
1929 | hom(:,1,124,sr) = sums(:,124) ! ni |
---|
1930 | hom(:,1,125,sr) = sums(:,125) ! qi |
---|
1931 | hom(:,1,73,sr) = sums(:,73) ! nr |
---|
1932 | hom(:,1,74,sr) = sums(:,74) ! qr |
---|
1933 | hom(:,1,75,sr) = sums(:,75) ! qc |
---|
1934 | hom(:,1,76,sr) = sums(:,76) ! prr (precipitation rate) |
---|
1935 | ! 77 is initial density profile |
---|
1936 | hom(:,1,78,sr) = ug ! ug |
---|
1937 | hom(:,1,79,sr) = vg ! vg |
---|
1938 | hom(:,1,80,sr) = w_subs ! w_subs |
---|
1939 | |
---|
1940 | IF ( large_scale_forcing ) THEN |
---|
1941 | hom(:,1,81,sr) = sums_ls_l(:,0) ! td_lsa_lpt |
---|
1942 | hom(:,1,82,sr) = sums_ls_l(:,1) ! td_lsa_q |
---|
1943 | IF ( use_subsidence_tendencies ) THEN |
---|
1944 | hom(:,1,83,sr) = sums_ls_l(:,2) ! td_sub_lpt |
---|
1945 | hom(:,1,84,sr) = sums_ls_l(:,3) ! td_sub_q |
---|
1946 | ELSE |
---|
1947 | hom(:,1,83,sr) = sums(:,83) ! td_sub_lpt |
---|
1948 | hom(:,1,84,sr) = sums(:,84) ! td_sub_q |
---|
1949 | ENDIF |
---|
1950 | hom(:,1,85,sr) = sums(:,85) ! td_nud_lpt |
---|
1951 | hom(:,1,86,sr) = sums(:,86) ! td_nud_q |
---|
1952 | hom(:,1,87,sr) = sums(:,87) ! td_nud_u |
---|
1953 | hom(:,1,88,sr) = sums(:,88) ! td_nud_v |
---|
1954 | ENDIF |
---|
1955 | |
---|
1956 | IF ( land_surface ) THEN |
---|
1957 | hom(:,1,89,sr) = sums(:,89) ! t_soil |
---|
1958 | ! 90 is initial t_soil profile |
---|
1959 | hom(:,1,91,sr) = sums(:,91) ! m_soil |
---|
1960 | ! 92 is initial m_soil profile |
---|
1961 | hom(:,1,93,sr) = sums(:,93) ! ghf |
---|
1962 | hom(:,1,94,sr) = sums(:,94) ! qsws_liq |
---|
1963 | hom(:,1,95,sr) = sums(:,95) ! qsws_soil |
---|
1964 | hom(:,1,96,sr) = sums(:,96) ! qsws_veg |
---|
1965 | hom(:,1,97,sr) = sums(:,97) ! r_a |
---|
1966 | hom(:,1,98,sr) = sums(:,98) ! r_s |
---|
1967 | |
---|
1968 | ENDIF |
---|
1969 | |
---|
1970 | IF ( radiation ) THEN |
---|
1971 | hom(:,1,99,sr) = sums(:,99) ! rad_net |
---|
1972 | hom(:,1,100,sr) = sums(:,100) ! rad_lw_in |
---|
1973 | hom(:,1,101,sr) = sums(:,101) ! rad_lw_out |
---|
1974 | hom(:,1,102,sr) = sums(:,102) ! rad_sw_in |
---|
1975 | hom(:,1,103,sr) = sums(:,103) ! rad_sw_out |
---|
1976 | |
---|
1977 | IF ( radiation_scheme == 'rrtmg' ) THEN |
---|
1978 | hom(:,1,104,sr) = sums(:,104) ! rad_lw_cs_hr |
---|
1979 | hom(:,1,105,sr) = sums(:,105) ! rad_lw_hr |
---|
1980 | hom(:,1,106,sr) = sums(:,106) ! rad_sw_cs_hr |
---|
1981 | hom(:,1,107,sr) = sums(:,107) ! rad_sw_hr |
---|
1982 | |
---|
1983 | hom(:,1,108,sr) = sums(:,108) ! rrtm_aldif |
---|
1984 | hom(:,1,109,sr) = sums(:,109) ! rrtm_aldir |
---|
1985 | hom(:,1,110,sr) = sums(:,110) ! rrtm_asdif |
---|
1986 | hom(:,1,111,sr) = sums(:,111) ! rrtm_asdir |
---|
1987 | ENDIF |
---|
1988 | ENDIF |
---|
1989 | |
---|
1990 | hom(:,1,112,sr) = sums(:,112) !: L |
---|
1991 | |
---|
1992 | IF ( passive_scalar ) THEN |
---|
1993 | hom(:,1,117,sr) = sums(:,117) ! w"s" |
---|
1994 | hom(:,1,114,sr) = sums(:,114) ! w*s* |
---|
1995 | hom(:,1,118,sr) = sums(:,117) + sums(:,114) ! ws |
---|
1996 | hom(:,1,116,sr) = sums(:,116) ! s*2 |
---|
1997 | ENDIF |
---|
1998 | |
---|
1999 | hom(:,1,119,sr) = rho_air ! rho_air in Kg/m^3 |
---|
2000 | hom(:,1,120,sr) = rho_air_zw ! rho_air_zw in Kg/m^3 |
---|
2001 | |
---|
2002 | IF ( kolmogorov_length_scale ) THEN |
---|
2003 | hom(:,1,121,sr) = sums(:,121) * 1E3_wp ! eta in mm |
---|
2004 | ENDIF |
---|
2005 | |
---|
2006 | |
---|
2007 | hom(:,1,pr_palm,sr) = sums(:,pr_palm) |
---|
2008 | ! u*, w'u', w'v', t* (in last profile) |
---|
2009 | |
---|
2010 | IF ( max_pr_user > 0 ) THEN ! user-defined profiles |
---|
2011 | hom(:,1,pr_palm+1:pr_palm+max_pr_user,sr) = & |
---|
2012 | sums(:,pr_palm+1:pr_palm+max_pr_user) |
---|
2013 | ENDIF |
---|
2014 | |
---|
2015 | IF ( air_chemistry ) THEN |
---|
2016 | IF ( max_pr_cs > 0 ) THEN ! chem_spcs profiles |
---|
2017 | hom(:, 1, pr_palm+max_pr_user+1:pr_palm + max_pr_user+max_pr_cs, sr) = & |
---|
2018 | sums(:, pr_palm+max_pr_user+1:pr_palm+max_pr_user+max_pr_cs) |
---|
2019 | ENDIF |
---|
2020 | ENDIF |
---|
2021 | |
---|
2022 | IF ( salsa ) THEN |
---|
2023 | IF ( max_pr_salsa > 0 ) THEN ! salsa profiles |
---|
2024 | hom(:,1,pr_palm+max_pr_user+max_pr_cs+1:pr_palm+max_pr_user+max_pr_cs+max_pr_salsa, sr) = & |
---|
2025 | sums(:,pr_palm+max_pr_user+max_pr_cs+1:pr_palm+max_pr_user+max_pr_cs+max_pr_salsa) |
---|
2026 | ENDIF |
---|
2027 | ENDIF |
---|
2028 | ! |
---|
2029 | !-- Determine the boundary layer height using two different schemes. |
---|
2030 | !-- First scheme: Starting from the Earth's (Ocean's) surface, look for the first relative |
---|
2031 | !-- minimum (maximum) of the total heat flux. |
---|
2032 | !-- The corresponding height is assumed as the boundary layer height, if it is less than 1.5 |
---|
2033 | !-- times the height where the heat flux becomes negative (positive) for the first time. |
---|
2034 | !-- Attention: the resolved vertical sensible heat flux (hom(:,1,17,sr) = w*pt*) is not known at |
---|
2035 | !-- the beginning because the calculation happens in advec_s_ws which is called after |
---|
2036 | !-- flow_statistics. Therefore z_i is directly taken from restart data at the beginning of |
---|
2037 | !-- restart runs. |
---|
2038 | IF ( TRIM( initializing_actions ) /= 'read_restart_data' .OR. & |
---|
2039 | simulated_time_at_begin /= simulated_time ) THEN |
---|
2040 | |
---|
2041 | z_i(1) = 0.0_wp |
---|
2042 | first = .TRUE. |
---|
2043 | |
---|
2044 | IF ( ocean_mode ) THEN |
---|
2045 | DO k = nzt, nzb+1, -1 |
---|
2046 | IF ( first .AND. hom(k,1,18,sr) < -1.0E-8_wp ) THEN |
---|
2047 | first = .FALSE. |
---|
2048 | height = zw(k) |
---|
2049 | ENDIF |
---|
2050 | IF ( hom(k,1,18,sr) < -1.0E-8_wp .AND. hom(k-1,1,18,sr) > hom(k,1,18,sr) ) THEN |
---|
2051 | IF ( zw(k) < 1.5_wp * height ) THEN |
---|
2052 | z_i(1) = zw(k) |
---|
2053 | ELSE |
---|
2054 | z_i(1) = height |
---|
2055 | ENDIF |
---|
2056 | EXIT |
---|
2057 | ENDIF |
---|
2058 | ENDDO |
---|
2059 | ELSE |
---|
2060 | DO k = nzb, nzt-1 |
---|
2061 | IF ( first .AND. hom(k,1,18,sr) < -1.0E-8_wp ) THEN |
---|
2062 | first = .FALSE. |
---|
2063 | height = zw(k) |
---|
2064 | ENDIF |
---|
2065 | IF ( hom(k,1,18,sr) < -1.0E-8_wp .AND. hom(k+1,1,18,sr) > hom(k,1,18,sr) ) THEN |
---|
2066 | IF ( zw(k) < 1.5_wp * height ) THEN |
---|
2067 | z_i(1) = zw(k) |
---|
2068 | ELSE |
---|
2069 | z_i(1) = height |
---|
2070 | ENDIF |
---|
2071 | EXIT |
---|
2072 | ENDIF |
---|
2073 | ENDDO |
---|
2074 | ENDIF |
---|
2075 | |
---|
2076 | ! |
---|
2077 | !-- Second scheme: Gradient scheme from Sullivan et al. (1998), modified by Uhlenbrock(2006). |
---|
2078 | !-- The boundary layer height is the height with the maximal local temperature gradient: |
---|
2079 | !-- starting from the second (the last but one) vertical gridpoint, the local gradient must be |
---|
2080 | !-- at least 0.2K/100m and greater than the next four gradients. |
---|
2081 | !-- WARNING: The threshold value of 0.2K/100m must be adjusted for the |
---|
2082 | !-- ocean case! |
---|
2083 | z_i(2) = 0.0_wp |
---|
2084 | DO k = nzb+1, nzt+1 |
---|
2085 | dptdz(k) = ( hom(k,1,4,sr) - hom(k-1,1,4,sr) ) * ddzu(k) |
---|
2086 | ENDDO |
---|
2087 | dptdz_threshold = 0.2_wp / 100.0_wp |
---|
2088 | |
---|
2089 | IF ( ocean_mode ) THEN |
---|
2090 | DO k = nzt+1, nzb+5, -1 |
---|
2091 | IF ( dptdz(k) > dptdz_threshold .AND. & |
---|
2092 | dptdz(k) > dptdz(k-1) .AND. dptdz(k) > dptdz(k-2) .AND. & |
---|
2093 | dptdz(k) > dptdz(k-3) .AND. dptdz(k) > dptdz(k-4) ) THEN |
---|
2094 | z_i(2) = zw(k-1) |
---|
2095 | EXIT |
---|
2096 | ENDIF |
---|
2097 | ENDDO |
---|
2098 | ELSE |
---|
2099 | DO k = nzb+1, nzt-3 |
---|
2100 | IF ( dptdz(k) > dptdz_threshold .AND. & |
---|
2101 | dptdz(k) > dptdz(k+1) .AND. dptdz(k) > dptdz(k+2) .AND. & |
---|
2102 | dptdz(k) > dptdz(k+3) .AND. dptdz(k) > dptdz(k+4) ) THEN |
---|
2103 | z_i(2) = zw(k-1) |
---|
2104 | EXIT |
---|
2105 | ENDIF |
---|
2106 | ENDDO |
---|
2107 | ENDIF |
---|
2108 | |
---|
2109 | ENDIF |
---|
2110 | |
---|
2111 | hom(nzb+6,1,pr_palm,sr) = z_i(1) |
---|
2112 | hom(nzb+7,1,pr_palm,sr) = z_i(2) |
---|
2113 | |
---|
2114 | ! |
---|
2115 | !-- Determine vertical index which is nearest to the mean surface level height of the respective |
---|
2116 | !-- statistic region |
---|
2117 | DO k = nzb, nzt |
---|
2118 | IF ( zw(k) >= mean_surface_level_height(sr) ) THEN |
---|
2119 | k_surface_level = k |
---|
2120 | EXIT |
---|
2121 | ENDIF |
---|
2122 | ENDDO |
---|
2123 | |
---|
2124 | ! |
---|
2125 | !-- Computation of both the characteristic vertical velocity and the characteristic convective |
---|
2126 | !-- boundary layer temperature. |
---|
2127 | !-- The inversion height entering into the equation is defined with respect to the mean surface |
---|
2128 | !-- level height of the respective statistic region. |
---|
2129 | !-- The horizontal average at surface level index + 1 is input for the average temperature. |
---|
2130 | IF ( hom(k_surface_level,1,18,sr) > 1.0E-8_wp .AND. z_i(1) /= 0.0_wp ) THEN |
---|
2131 | hom(nzb+8,1,pr_palm,sr) = & |
---|
2132 | ( g / hom(k_surface_level+1,1,4,sr) * & |
---|
2133 | ( hom(k_surface_level,1,18,sr) / & |
---|
2134 | ( heatflux_output_conversion(nzb) * rho_air(nzb) ) ) & |
---|
2135 | * ABS( z_i(1) - mean_surface_level_height(sr) ) )**0.333333333_wp |
---|
2136 | ELSE |
---|
2137 | hom(nzb+8,1,pr_palm,sr) = 0.0_wp |
---|
2138 | ENDIF |
---|
2139 | |
---|
2140 | ! |
---|
2141 | !-- Collect the time series quantities. Please note, timeseries quantities which are collected |
---|
2142 | !-- from horizontally averaged profiles, e.g. wpt or pt(zp), are treated specially. In case of |
---|
2143 | !-- elevated model surfaces, index nzb+1 might be within topography and data will be zero. |
---|
2144 | !-- Therefore, take value for the first atmosphere index, which is topo_min_level+1. |
---|
2145 | ts_value(1,sr) = hom(nzb+4,1,pr_palm,sr) ! E |
---|
2146 | ts_value(2,sr) = hom(nzb+5,1,pr_palm,sr) ! E* |
---|
2147 | ts_value(3,sr) = dt_3d |
---|
2148 | ts_value(4,sr) = hom(nzb,1,pr_palm,sr) ! u* |
---|
2149 | ts_value(5,sr) = hom(nzb+3,1,pr_palm,sr) ! th* |
---|
2150 | ts_value(6,sr) = u_max |
---|
2151 | ts_value(7,sr) = v_max |
---|
2152 | ts_value(8,sr) = w_max |
---|
2153 | ts_value(9,sr) = hom(nzb+10,1,pr_palm,sr) ! new divergence |
---|
2154 | ts_value(10,sr) = hom(nzb+9,1,pr_palm,sr) ! old Divergence |
---|
2155 | ts_value(11,sr) = hom(nzb+6,1,pr_palm,sr) ! z_i(1) |
---|
2156 | ts_value(12,sr) = hom(nzb+7,1,pr_palm,sr) ! z_i(2) |
---|
2157 | ts_value(13,sr) = hom(nzb+8,1,pr_palm,sr) ! w* |
---|
2158 | ts_value(14,sr) = hom(nzb,1,16,sr) ! w'pt' at k=0 |
---|
2159 | ts_value(15,sr) = hom(topo_min_level+1,1,16,sr) ! w'pt' at k=1 |
---|
2160 | ts_value(16,sr) = hom(topo_min_level+1,1,18,sr) ! wpt at k=1 |
---|
2161 | ts_value(17,sr) = hom(nzb+14,1,pr_palm,sr) ! pt(0) |
---|
2162 | ts_value(18,sr) = hom(topo_min_level+1,1,4,sr) ! pt(zp) |
---|
2163 | ts_value(19,sr) = hom(nzb+1,1,pr_palm,sr) ! u'w' at k=0 |
---|
2164 | ts_value(20,sr) = hom(nzb+2,1,pr_palm,sr) ! v'w' at k=0 |
---|
2165 | ts_value(21,sr) = hom(nzb,1,48,sr) ! w"q" at k=0 |
---|
2166 | |
---|
2167 | IF ( .NOT. neutral ) THEN |
---|
2168 | ts_value(22,sr) = hom(nzb,1,112,sr) ! L |
---|
2169 | ELSE |
---|
2170 | ts_value(22,sr) = 1.0E10_wp |
---|
2171 | ENDIF |
---|
2172 | |
---|
2173 | ts_value(23,sr) = hom(nzb+12,1,pr_palm,sr) ! q* |
---|
2174 | |
---|
2175 | IF ( passive_scalar ) THEN |
---|
2176 | ts_value(24,sr) = hom(nzb+13,1,117,sr) ! w"s" ( to do ! ) |
---|
2177 | ts_value(25,sr) = hom(nzb+13,1,pr_palm,sr) ! s* |
---|
2178 | ENDIF |
---|
2179 | |
---|
2180 | ! |
---|
2181 | !-- Collect land surface model timeseries |
---|
2182 | IF ( land_surface ) THEN |
---|
2183 | ts_value(dots_soil ,sr) = hom(nzb,1,93,sr) ! ghf |
---|
2184 | ts_value(dots_soil+1,sr) = hom(nzb,1,94,sr) ! qsws_liq |
---|
2185 | ts_value(dots_soil+2,sr) = hom(nzb,1,95,sr) ! qsws_soil |
---|
2186 | ts_value(dots_soil+3,sr) = hom(nzb,1,96,sr) ! qsws_veg |
---|
2187 | ts_value(dots_soil+4,sr) = hom(nzb,1,97,sr) ! r_a |
---|
2188 | ts_value(dots_soil+5,sr) = hom(nzb,1,98,sr) ! r_s |
---|
2189 | ENDIF |
---|
2190 | ! |
---|
2191 | !-- Collect radiation model timeseries |
---|
2192 | IF ( radiation ) THEN |
---|
2193 | ts_value(dots_rad,sr) = hom(nzb,1,99,sr) ! rad_net |
---|
2194 | ts_value(dots_rad+1,sr) = hom(nzb,1,100,sr) ! rad_lw_in |
---|
2195 | ts_value(dots_rad+2,sr) = hom(nzb,1,101,sr) ! rad_lw_out |
---|
2196 | ts_value(dots_rad+3,sr) = hom(nzb,1,102,sr) ! rad_sw_in |
---|
2197 | ts_value(dots_rad+4,sr) = hom(nzb,1,103,sr) ! rad_sw_out |
---|
2198 | |
---|
2199 | IF ( radiation_scheme == 'rrtmg' ) THEN |
---|
2200 | ts_value(dots_rad+5,sr) = hom(nzb,1,108,sr) ! rrtm_aldif |
---|
2201 | ts_value(dots_rad+6,sr) = hom(nzb,1,109,sr) ! rrtm_aldir |
---|
2202 | ts_value(dots_rad+7,sr) = hom(nzb,1,110,sr) ! rrtm_asdif |
---|
2203 | ts_value(dots_rad+8,sr) = hom(nzb,1,111,sr) ! rrtm_asdir |
---|
2204 | ENDIF |
---|
2205 | |
---|
2206 | ENDIF |
---|
2207 | |
---|
2208 | ! |
---|
2209 | !-- Calculate additional statistics provided by other modules |
---|
2210 | CALL module_interface_statistics( 'time_series', sr, 0, dots_max ) |
---|
2211 | |
---|
2212 | ENDDO ! loop of the subregions |
---|
2213 | |
---|
2214 | ! |
---|
2215 | !-- If required, sum up horizontal averages for subsequent time averaging. |
---|
2216 | !-- Do not sum, if flow statistics is called before the first initial time step. |
---|
2217 | IF ( do_sum .AND. simulated_time /= 0.0_wp ) THEN |
---|
2218 | IF ( average_count_pr == 0 ) hom_sum = 0.0_wp |
---|
2219 | hom_sum = hom_sum + hom(:,1,:,:) |
---|
2220 | average_count_pr = average_count_pr + 1 |
---|
2221 | do_sum = .FALSE. |
---|
2222 | ENDIF |
---|
2223 | |
---|
2224 | ! |
---|
2225 | !-- Set flag for other UPs (e.g. output routines, but also buoyancy). |
---|
2226 | !-- This flag is reset after each time step in time_integration. |
---|
2227 | flow_statistics_called = .TRUE. |
---|
2228 | |
---|
2229 | CALL cpu_log( log_point(10), 'flow_statistics', 'stop' ) |
---|
2230 | |
---|
2231 | |
---|
2232 | END SUBROUTINE flow_statistics |
---|