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