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