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