[1682] | 1 | !> @file boundary_conds.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[1036] | 3 | ! This file is part of PALM. |
---|
| 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 | ! |
---|
[2101] | 17 | ! Copyright 1997-2017 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1933] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: boundary_conds.f90 2292 2017-06-20 09:51:42Z suehring $ |
---|
[2292] | 27 | ! Implementation of new microphysic scheme: cloud_scheme = 'morrison' |
---|
| 28 | ! includes two more prognostic equations for cloud drop concentration (nc) |
---|
| 29 | ! and cloud water content (qc). |
---|
| 30 | ! |
---|
| 31 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
[1321] | 32 | ! |
---|
[2233] | 33 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 34 | ! Set boundary conditions on topography top using flag method. |
---|
| 35 | ! |
---|
[2119] | 36 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
| 37 | ! OpenACC directives removed |
---|
| 38 | ! |
---|
[2001] | 39 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 40 | ! Forced header and separation lines into 80 columns |
---|
| 41 | ! |
---|
[1993] | 42 | ! 1992 2016-08-12 15:14:59Z suehring |
---|
| 43 | ! Adjustments for top boundary condition for passive scalar |
---|
| 44 | ! |
---|
[1961] | 45 | ! 1960 2016-07-12 16:34:24Z suehring |
---|
| 46 | ! Treat humidity and passive scalar separately |
---|
| 47 | ! |
---|
[1933] | 48 | ! 1823 2016-04-07 08:57:52Z hoffmann |
---|
| 49 | ! Initial version of purely vertical nesting introduced. |
---|
| 50 | ! |
---|
[1823] | 51 | ! 1822 2016-04-07 07:49:42Z hoffmann |
---|
| 52 | ! icloud_scheme removed. microphyisics_seifert added. |
---|
| 53 | ! |
---|
[1765] | 54 | ! 1764 2016-02-28 12:45:19Z raasch |
---|
| 55 | ! index bug for u_p at left outflow removed |
---|
| 56 | ! |
---|
[1763] | 57 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
| 58 | ! Introduction of nested domain feature |
---|
| 59 | ! |
---|
[1744] | 60 | ! 1742 2016-01-13 09:50:06Z raasch |
---|
| 61 | ! bugfix for outflow Neumann boundary conditions at bottom and top |
---|
| 62 | ! |
---|
[1718] | 63 | ! 1717 2015-11-11 15:09:47Z raasch |
---|
| 64 | ! Bugfix: index error in outflow conditions for left boundary |
---|
| 65 | ! |
---|
[1683] | 66 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 67 | ! Code annotations made doxygen readable |
---|
| 68 | ! |
---|
[1717] | 69 | ! 1410 2014-05-23 12:16:18Z suehring |
---|
[1463] | 70 | ! Bugfix: set dirichlet boundary condition for passive_scalar at model domain |
---|
| 71 | ! top |
---|
| 72 | ! |
---|
[1410] | 73 | ! 1399 2014-05-07 11:16:25Z heinze |
---|
| 74 | ! Bugfix: set inflow boundary conditions also if no humidity or passive_scalar |
---|
| 75 | ! is used. |
---|
| 76 | ! |
---|
[1399] | 77 | ! 1398 2014-05-07 11:15:00Z heinze |
---|
| 78 | ! Dirichlet-condition at the top for u and v changed to u_init and v_init also |
---|
| 79 | ! for large_scale_forcing |
---|
| 80 | ! |
---|
[1381] | 81 | ! 1380 2014-04-28 12:40:45Z heinze |
---|
| 82 | ! Adjust Dirichlet-condition at the top for pt in case of nudging |
---|
| 83 | ! |
---|
[1362] | 84 | ! 1361 2014-04-16 15:17:48Z hoffmann |
---|
| 85 | ! Bottom and top boundary conditions of rain water content (qr) and |
---|
| 86 | ! rain drop concentration (nr) changed to Dirichlet |
---|
| 87 | ! |
---|
[1354] | 88 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 89 | ! REAL constants provided with KIND-attribute |
---|
| 90 | ! |
---|
[1321] | 91 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 92 | ! ONLY-attribute added to USE-statements, |
---|
| 93 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 94 | ! kinds are defined in new module kinds, |
---|
| 95 | ! revision history before 2012 removed, |
---|
| 96 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 97 | ! all variable declaration statements |
---|
[1160] | 98 | ! |
---|
[1258] | 99 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
| 100 | ! loop independent clauses added |
---|
| 101 | ! |
---|
[1242] | 102 | ! 1241 2013-10-30 11:36:58Z heinze |
---|
| 103 | ! Adjust ug and vg at each timestep in case of large_scale_forcing |
---|
| 104 | ! |
---|
[1160] | 105 | ! 1159 2013-05-21 11:58:22Z fricke |
---|
[1159] | 106 | ! Bugfix: Neumann boundary conditions for the velocity components at the |
---|
| 107 | ! outflow are in fact radiation boundary conditions using the maximum phase |
---|
| 108 | ! velocity that ensures numerical stability (CFL-condition). |
---|
| 109 | ! Hence, logical operator use_cmax is now used instead of bc_lr_dirneu/_neudir. |
---|
| 110 | ! Bugfix: In case of use_cmax at the outflow, u, v, w are replaced by |
---|
| 111 | ! u_p, v_p, w_p |
---|
[1116] | 112 | ! |
---|
| 113 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
| 114 | ! boundary conditions of two-moment cloud scheme are restricted to Neumann- |
---|
| 115 | ! boundary-conditions |
---|
| 116 | ! |
---|
[1114] | 117 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
| 118 | ! GPU-porting |
---|
| 119 | ! dummy argument "range" removed |
---|
| 120 | ! Bugfix: wrong index in loops of radiation boundary condition |
---|
[1113] | 121 | ! |
---|
[1054] | 122 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
| 123 | ! boundary conditions for the two new prognostic equations (nr, qr) of the |
---|
| 124 | ! two-moment cloud scheme |
---|
| 125 | ! |
---|
[1037] | 126 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 127 | ! code put under GPL (PALM 3.9) |
---|
| 128 | ! |
---|
[997] | 129 | ! 996 2012-09-07 10:41:47Z raasch |
---|
| 130 | ! little reformatting |
---|
| 131 | ! |
---|
[979] | 132 | ! 978 2012-08-09 08:28:32Z fricke |
---|
| 133 | ! Neumann boudnary conditions are added at the inflow boundary for the SGS-TKE. |
---|
| 134 | ! Outflow boundary conditions for the velocity components can be set to Neumann |
---|
| 135 | ! conditions or to radiation conditions with a horizontal averaged phase |
---|
| 136 | ! velocity. |
---|
| 137 | ! |
---|
[876] | 138 | ! 875 2012-04-02 15:35:15Z gryschka |
---|
| 139 | ! Bugfix in case of dirichlet inflow bc at the right or north boundary |
---|
| 140 | ! |
---|
[1] | 141 | ! Revision 1.1 1997/09/12 06:21:34 raasch |
---|
| 142 | ! Initial revision |
---|
| 143 | ! |
---|
| 144 | ! |
---|
| 145 | ! Description: |
---|
| 146 | ! ------------ |
---|
[1682] | 147 | !> Boundary conditions for the prognostic quantities. |
---|
| 148 | !> One additional bottom boundary condition is applied for the TKE (=(u*)**2) |
---|
| 149 | !> in prandtl_fluxes. The cyclic lateral boundary conditions are implicitly |
---|
| 150 | !> handled in routine exchange_horiz. Pressure boundary conditions are |
---|
| 151 | !> explicitly set in routines pres, poisfft, poismg and sor. |
---|
[1] | 152 | !------------------------------------------------------------------------------! |
---|
[1682] | 153 | SUBROUTINE boundary_conds |
---|
| 154 | |
---|
[1] | 155 | |
---|
[1320] | 156 | USE arrays_3d, & |
---|
| 157 | ONLY: c_u, c_u_m, c_u_m_l, c_v, c_v_m, c_v_m_l, c_w, c_w_m, c_w_m_l, & |
---|
[2292] | 158 | dzu, e_p, nc_p, nr_p, pt, pt_p, q, q_p, qc_p, qr_p, s, s_p, sa, & |
---|
| 159 | sa_p, u, ug, u_init, u_m_l, u_m_n, u_m_r, u_m_s, u_p, & |
---|
[1320] | 160 | v, vg, v_init, v_m_l, v_m_n, v_m_r, v_m_s, v_p, & |
---|
[1960] | 161 | w, w_p, w_m_l, w_m_n, w_m_r, w_m_s, pt_init |
---|
[2292] | 162 | |
---|
[1320] | 163 | USE control_parameters, & |
---|
[1960] | 164 | ONLY: bc_pt_t_val, bc_q_t_val, bc_s_t_val, constant_diffusion, & |
---|
[1320] | 165 | cloud_physics, dt_3d, humidity, & |
---|
[1960] | 166 | ibc_pt_b, ibc_pt_t, ibc_q_b, ibc_q_t, ibc_s_b, ibc_s_t, & |
---|
| 167 | ibc_sa_t, ibc_uv_b, ibc_uv_t, inflow_l, inflow_n, inflow_r, & |
---|
| 168 | inflow_s, intermediate_timestep_count, large_scale_forcing, & |
---|
[2292] | 169 | microphysics_morrison, microphysics_seifert, nest_domain, & |
---|
| 170 | nest_bound_l, nest_bound_s, nudging, ocean, outflow_l, & |
---|
| 171 | outflow_n, outflow_r, outflow_s, passive_scalar, tsc, use_cmax |
---|
[1320] | 172 | |
---|
| 173 | USE grid_variables, & |
---|
| 174 | ONLY: ddx, ddy, dx, dy |
---|
| 175 | |
---|
| 176 | USE indices, & |
---|
| 177 | ONLY: nx, nxl, nxlg, nxr, nxrg, ny, nyn, nyng, nys, nysg, & |
---|
[2232] | 178 | nzb, nzt, wall_flags_0 |
---|
[1320] | 179 | |
---|
| 180 | USE kinds |
---|
| 181 | |
---|
[1] | 182 | USE pegrid |
---|
| 183 | |
---|
[1933] | 184 | USE pmc_interface, & |
---|
| 185 | ONLY : nesting_mode |
---|
[1320] | 186 | |
---|
[2232] | 187 | USE surface_mod, & |
---|
| 188 | ONLY : bc_h |
---|
[1933] | 189 | |
---|
[1] | 190 | IMPLICIT NONE |
---|
| 191 | |
---|
[2232] | 192 | INTEGER(iwp) :: i !< grid index x direction |
---|
| 193 | INTEGER(iwp) :: j !< grid index y direction |
---|
| 194 | INTEGER(iwp) :: k !< grid index z direction |
---|
| 195 | INTEGER(iwp) :: kb !< variable to set respective boundary value, depends on facing. |
---|
| 196 | INTEGER(iwp) :: l !< running index boundary type, for up- and downward-facing walls |
---|
| 197 | INTEGER(iwp) :: m !< running index surface elements |
---|
[1] | 198 | |
---|
[1682] | 199 | REAL(wp) :: c_max !< |
---|
| 200 | REAL(wp) :: denom !< |
---|
[1] | 201 | |
---|
[73] | 202 | |
---|
[1] | 203 | ! |
---|
[1113] | 204 | !-- Bottom boundary |
---|
| 205 | IF ( ibc_uv_b == 1 ) THEN |
---|
| 206 | u_p(nzb,:,:) = u_p(nzb+1,:,:) |
---|
| 207 | v_p(nzb,:,:) = v_p(nzb+1,:,:) |
---|
| 208 | ENDIF |
---|
[2232] | 209 | ! |
---|
| 210 | !-- Set zero vertical velocity at topography top (l=0), or bottom (l=1) in case |
---|
| 211 | !-- of downward-facing surfaces. |
---|
| 212 | DO l = 0, 1 |
---|
| 213 | ! |
---|
| 214 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 215 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 216 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 217 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 218 | DO m = 1, bc_h(l)%ns |
---|
| 219 | i = bc_h(l)%i(m) |
---|
| 220 | j = bc_h(l)%j(m) |
---|
| 221 | k = bc_h(l)%k(m) |
---|
| 222 | w_p(k+kb,j,i) = 0.0_wp |
---|
[1113] | 223 | ENDDO |
---|
| 224 | ENDDO |
---|
| 225 | |
---|
| 226 | ! |
---|
[1762] | 227 | !-- Top boundary. A nested domain ( ibc_uv_t = 3 ) does not require settings. |
---|
[1113] | 228 | IF ( ibc_uv_t == 0 ) THEN |
---|
| 229 | u_p(nzt+1,:,:) = u_init(nzt+1) |
---|
| 230 | v_p(nzt+1,:,:) = v_init(nzt+1) |
---|
[1762] | 231 | ELSEIF ( ibc_uv_t == 1 ) THEN |
---|
[1113] | 232 | u_p(nzt+1,:,:) = u_p(nzt,:,:) |
---|
| 233 | v_p(nzt+1,:,:) = v_p(nzt,:,:) |
---|
| 234 | ENDIF |
---|
| 235 | |
---|
[1762] | 236 | IF ( .NOT. nest_domain ) THEN |
---|
| 237 | w_p(nzt:nzt+1,:,:) = 0.0_wp ! nzt is not a prognostic level (but cf. pres) |
---|
| 238 | ENDIF |
---|
| 239 | |
---|
[1113] | 240 | ! |
---|
[2232] | 241 | !-- Temperature at bottom and top boundary. |
---|
[1113] | 242 | !-- In case of coupled runs (ibc_pt_b = 2) the temperature is given by |
---|
| 243 | !-- the sea surface temperature of the coupled ocean model. |
---|
[2232] | 244 | !-- Dirichlet |
---|
[1113] | 245 | IF ( ibc_pt_b == 0 ) THEN |
---|
[2232] | 246 | DO l = 0, 1 |
---|
| 247 | ! |
---|
| 248 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 249 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 250 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 251 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 252 | DO m = 1, bc_h(l)%ns |
---|
| 253 | i = bc_h(l)%i(m) |
---|
| 254 | j = bc_h(l)%j(m) |
---|
| 255 | k = bc_h(l)%k(m) |
---|
| 256 | pt_p(k+kb,j,i) = pt(k+kb,j,i) |
---|
[1] | 257 | ENDDO |
---|
| 258 | ENDDO |
---|
[2232] | 259 | ! |
---|
| 260 | !-- Neumann, zero-gradient |
---|
[1113] | 261 | ELSEIF ( ibc_pt_b == 1 ) THEN |
---|
[2232] | 262 | DO l = 0, 1 |
---|
| 263 | ! |
---|
| 264 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 265 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 266 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 267 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 268 | DO m = 1, bc_h(l)%ns |
---|
| 269 | i = bc_h(l)%i(m) |
---|
| 270 | j = bc_h(l)%j(m) |
---|
| 271 | k = bc_h(l)%k(m) |
---|
| 272 | pt_p(k+kb,j,i) = pt_p(k,j,i) |
---|
[1113] | 273 | ENDDO |
---|
| 274 | ENDDO |
---|
| 275 | ENDIF |
---|
[1] | 276 | |
---|
| 277 | ! |
---|
[1113] | 278 | !-- Temperature at top boundary |
---|
| 279 | IF ( ibc_pt_t == 0 ) THEN |
---|
| 280 | pt_p(nzt+1,:,:) = pt(nzt+1,:,:) |
---|
[1380] | 281 | ! |
---|
| 282 | !-- In case of nudging adjust top boundary to pt which is |
---|
| 283 | !-- read in from NUDGING-DATA |
---|
| 284 | IF ( nudging ) THEN |
---|
| 285 | pt_p(nzt+1,:,:) = pt_init(nzt+1) |
---|
| 286 | ENDIF |
---|
[1113] | 287 | ELSEIF ( ibc_pt_t == 1 ) THEN |
---|
| 288 | pt_p(nzt+1,:,:) = pt_p(nzt,:,:) |
---|
| 289 | ELSEIF ( ibc_pt_t == 2 ) THEN |
---|
[1992] | 290 | pt_p(nzt+1,:,:) = pt_p(nzt,:,:) + bc_pt_t_val * dzu(nzt+1) |
---|
[1113] | 291 | ENDIF |
---|
[1] | 292 | |
---|
| 293 | ! |
---|
[1113] | 294 | !-- Boundary conditions for TKE |
---|
| 295 | !-- Generally Neumann conditions with de/dz=0 are assumed |
---|
| 296 | IF ( .NOT. constant_diffusion ) THEN |
---|
[2232] | 297 | |
---|
| 298 | DO l = 0, 1 |
---|
| 299 | ! |
---|
| 300 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 301 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 302 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 303 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 304 | DO m = 1, bc_h(l)%ns |
---|
| 305 | i = bc_h(l)%i(m) |
---|
| 306 | j = bc_h(l)%j(m) |
---|
| 307 | k = bc_h(l)%k(m) |
---|
| 308 | e_p(k+kb,j,i) = e_p(k,j,i) |
---|
[73] | 309 | ENDDO |
---|
[1113] | 310 | ENDDO |
---|
[2232] | 311 | |
---|
[1762] | 312 | IF ( .NOT. nest_domain ) THEN |
---|
| 313 | e_p(nzt+1,:,:) = e_p(nzt,:,:) |
---|
| 314 | ENDIF |
---|
[1113] | 315 | ENDIF |
---|
| 316 | |
---|
| 317 | ! |
---|
| 318 | !-- Boundary conditions for salinity |
---|
| 319 | IF ( ocean ) THEN |
---|
| 320 | ! |
---|
| 321 | !-- Bottom boundary: Neumann condition because salinity flux is always |
---|
[2232] | 322 | !-- given. |
---|
| 323 | DO l = 0, 1 |
---|
| 324 | ! |
---|
| 325 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 326 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 327 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 328 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 329 | DO m = 1, bc_h(l)%ns |
---|
| 330 | i = bc_h(l)%i(m) |
---|
| 331 | j = bc_h(l)%j(m) |
---|
| 332 | k = bc_h(l)%k(m) |
---|
| 333 | sa_p(k+kb,j,i) = sa_p(k,j,i) |
---|
[1] | 334 | ENDDO |
---|
[1113] | 335 | ENDDO |
---|
[1] | 336 | ! |
---|
[1113] | 337 | !-- Top boundary: Dirichlet or Neumann |
---|
| 338 | IF ( ibc_sa_t == 0 ) THEN |
---|
| 339 | sa_p(nzt+1,:,:) = sa(nzt+1,:,:) |
---|
| 340 | ELSEIF ( ibc_sa_t == 1 ) THEN |
---|
| 341 | sa_p(nzt+1,:,:) = sa_p(nzt,:,:) |
---|
[1] | 342 | ENDIF |
---|
| 343 | |
---|
[1113] | 344 | ENDIF |
---|
| 345 | |
---|
[1] | 346 | ! |
---|
[1960] | 347 | !-- Boundary conditions for total water content, |
---|
[1113] | 348 | !-- bottom and top boundary (see also temperature) |
---|
[1960] | 349 | IF ( humidity ) THEN |
---|
[1113] | 350 | ! |
---|
| 351 | !-- Surface conditions for constant_humidity_flux |
---|
[2232] | 352 | !-- Run loop over all non-natural and natural walls. Note, in wall-datatype |
---|
| 353 | !-- the k coordinate belongs to the atmospheric grid point, therefore, set |
---|
| 354 | !-- q_p at k-1 |
---|
[1113] | 355 | IF ( ibc_q_b == 0 ) THEN |
---|
[2232] | 356 | |
---|
| 357 | DO l = 0, 1 |
---|
| 358 | ! |
---|
| 359 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 360 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 361 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 362 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 363 | DO m = 1, bc_h(l)%ns |
---|
| 364 | i = bc_h(l)%i(m) |
---|
| 365 | j = bc_h(l)%j(m) |
---|
| 366 | k = bc_h(l)%k(m) |
---|
| 367 | q_p(k+kb,j,i) = q(k+kb,j,i) |
---|
[1] | 368 | ENDDO |
---|
| 369 | ENDDO |
---|
[2232] | 370 | |
---|
[1113] | 371 | ELSE |
---|
[2232] | 372 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 373 | DO m = 1, bc_h(0)%ns |
---|
| 374 | i = bc_h(0)%i(m) |
---|
| 375 | j = bc_h(0)%j(m) |
---|
| 376 | k = bc_h(0)%k(m) |
---|
| 377 | q_p(k-1,j,i) = q_p(k,j,i) |
---|
| 378 | ENDDO |
---|
| 379 | |
---|
| 380 | DO l = 0, 1 |
---|
| 381 | ! |
---|
| 382 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 383 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 384 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 385 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 386 | DO m = 1, bc_h(l)%ns |
---|
| 387 | i = bc_h(l)%i(m) |
---|
| 388 | j = bc_h(l)%j(m) |
---|
| 389 | k = bc_h(l)%k(m) |
---|
| 390 | q_p(k+kb,j,i) = q_p(k,j,i) |
---|
[95] | 391 | ENDDO |
---|
| 392 | ENDDO |
---|
[1113] | 393 | ENDIF |
---|
[95] | 394 | ! |
---|
[1113] | 395 | !-- Top boundary |
---|
[1462] | 396 | IF ( ibc_q_t == 0 ) THEN |
---|
| 397 | q_p(nzt+1,:,:) = q(nzt+1,:,:) |
---|
| 398 | ELSEIF ( ibc_q_t == 1 ) THEN |
---|
[1992] | 399 | q_p(nzt+1,:,:) = q_p(nzt,:,:) + bc_q_t_val * dzu(nzt+1) |
---|
[1462] | 400 | ENDIF |
---|
[95] | 401 | |
---|
[2292] | 402 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
| 403 | ! |
---|
| 404 | !-- Surface conditions cloud water (Dirichlet) |
---|
| 405 | !-- Run loop over all non-natural and natural walls. Note, in wall-datatype |
---|
| 406 | !-- the k coordinate belongs to the atmospheric grid point, therefore, set |
---|
| 407 | !-- qr_p and nr_p at k-1 |
---|
| 408 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 409 | DO m = 1, bc_h(0)%ns |
---|
| 410 | i = bc_h(0)%i(m) |
---|
| 411 | j = bc_h(0)%j(m) |
---|
| 412 | k = bc_h(0)%k(m) |
---|
| 413 | qc_p(k-1,j,i) = 0.0_wp |
---|
| 414 | nc_p(k-1,j,i) = 0.0_wp |
---|
| 415 | ENDDO |
---|
| 416 | ! |
---|
| 417 | !-- Top boundary condition for cloud water (Dirichlet) |
---|
| 418 | qc_p(nzt+1,:,:) = 0.0_wp |
---|
| 419 | nc_p(nzt+1,:,:) = 0.0_wp |
---|
| 420 | |
---|
| 421 | ENDIF |
---|
| 422 | |
---|
[1822] | 423 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1113] | 424 | ! |
---|
[1361] | 425 | !-- Surface conditions rain water (Dirichlet) |
---|
[2232] | 426 | !-- Run loop over all non-natural and natural walls. Note, in wall-datatype |
---|
| 427 | !-- the k coordinate belongs to the atmospheric grid point, therefore, set |
---|
| 428 | !-- qr_p and nr_p at k-1 |
---|
| 429 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 430 | DO m = 1, bc_h(0)%ns |
---|
| 431 | i = bc_h(0)%i(m) |
---|
| 432 | j = bc_h(0)%j(m) |
---|
| 433 | k = bc_h(0)%k(m) |
---|
| 434 | qr_p(k-1,j,i) = 0.0_wp |
---|
| 435 | nr_p(k-1,j,i) = 0.0_wp |
---|
[1115] | 436 | ENDDO |
---|
[1] | 437 | ! |
---|
[1361] | 438 | !-- Top boundary condition for rain water (Dirichlet) |
---|
| 439 | qr_p(nzt+1,:,:) = 0.0_wp |
---|
| 440 | nr_p(nzt+1,:,:) = 0.0_wp |
---|
[1115] | 441 | |
---|
[1] | 442 | ENDIF |
---|
[1409] | 443 | ENDIF |
---|
[1] | 444 | ! |
---|
[1960] | 445 | !-- Boundary conditions for scalar, |
---|
| 446 | !-- bottom and top boundary (see also temperature) |
---|
| 447 | IF ( passive_scalar ) THEN |
---|
| 448 | ! |
---|
| 449 | !-- Surface conditions for constant_humidity_flux |
---|
[2232] | 450 | !-- Run loop over all non-natural and natural walls. Note, in wall-datatype |
---|
| 451 | !-- the k coordinate belongs to the atmospheric grid point, therefore, set |
---|
| 452 | !-- s_p at k-1 |
---|
[1960] | 453 | IF ( ibc_s_b == 0 ) THEN |
---|
[2232] | 454 | |
---|
| 455 | DO l = 0, 1 |
---|
| 456 | ! |
---|
| 457 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 458 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 459 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 460 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 461 | DO m = 1, bc_h(l)%ns |
---|
| 462 | i = bc_h(l)%i(m) |
---|
| 463 | j = bc_h(l)%j(m) |
---|
| 464 | k = bc_h(l)%k(m) |
---|
| 465 | s_p(k+kb,j,i) = s(k+kb,j,i) |
---|
[1960] | 466 | ENDDO |
---|
| 467 | ENDDO |
---|
[2232] | 468 | |
---|
[1960] | 469 | ELSE |
---|
[2232] | 470 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 471 | DO m = 1, bc_h(0)%ns |
---|
| 472 | i = bc_h(0)%i(m) |
---|
| 473 | j = bc_h(0)%j(m) |
---|
| 474 | k = bc_h(0)%k(m) |
---|
| 475 | s_p(k-1,j,i) = s_p(k,j,i) |
---|
| 476 | ENDDO |
---|
| 477 | |
---|
| 478 | DO l = 0, 1 |
---|
| 479 | ! |
---|
| 480 | !-- Set kb, for upward-facing surfaces value at topography top (k-1) is set, |
---|
| 481 | !-- for downward-facing surfaces at topography bottom (k+1). |
---|
| 482 | kb = MERGE( -1, 1, l == 0 ) |
---|
| 483 | !$OMP PARALLEL DO PRIVATE( i, j, k ) |
---|
| 484 | DO m = 1, bc_h(l)%ns |
---|
| 485 | i = bc_h(l)%i(m) |
---|
| 486 | j = bc_h(l)%j(m) |
---|
| 487 | k = bc_h(l)%k(m) |
---|
| 488 | s_p(k+kb,j,i) = s_p(k,j,i) |
---|
[1960] | 489 | ENDDO |
---|
| 490 | ENDDO |
---|
| 491 | ENDIF |
---|
| 492 | ! |
---|
[1992] | 493 | !-- Top boundary condition |
---|
| 494 | IF ( ibc_s_t == 0 ) THEN |
---|
[1960] | 495 | s_p(nzt+1,:,:) = s(nzt+1,:,:) |
---|
[1992] | 496 | ELSEIF ( ibc_s_t == 1 ) THEN |
---|
| 497 | s_p(nzt+1,:,:) = s_p(nzt,:,:) |
---|
| 498 | ELSEIF ( ibc_s_t == 2 ) THEN |
---|
| 499 | s_p(nzt+1,:,:) = s_p(nzt,:,:) + bc_s_t_val * dzu(nzt+1) |
---|
[1960] | 500 | ENDIF |
---|
| 501 | |
---|
| 502 | ENDIF |
---|
| 503 | ! |
---|
[1762] | 504 | !-- In case of inflow or nest boundary at the south boundary the boundary for v |
---|
| 505 | !-- is at nys and in case of inflow or nest boundary at the left boundary the |
---|
| 506 | !-- boundary for u is at nxl. Since in prognostic_equations (cache optimized |
---|
| 507 | !-- version) these levels are handled as a prognostic level, boundary values |
---|
| 508 | !-- have to be restored here. |
---|
[1409] | 509 | !-- For the SGS-TKE, Neumann boundary conditions are used at the inflow. |
---|
| 510 | IF ( inflow_s ) THEN |
---|
| 511 | v_p(:,nys,:) = v_p(:,nys-1,:) |
---|
| 512 | IF ( .NOT. constant_diffusion ) e_p(:,nys-1,:) = e_p(:,nys,:) |
---|
| 513 | ELSEIF ( inflow_n ) THEN |
---|
| 514 | IF ( .NOT. constant_diffusion ) e_p(:,nyn+1,:) = e_p(:,nyn,:) |
---|
| 515 | ELSEIF ( inflow_l ) THEN |
---|
| 516 | u_p(:,:,nxl) = u_p(:,:,nxl-1) |
---|
| 517 | IF ( .NOT. constant_diffusion ) e_p(:,:,nxl-1) = e_p(:,:,nxl) |
---|
| 518 | ELSEIF ( inflow_r ) THEN |
---|
| 519 | IF ( .NOT. constant_diffusion ) e_p(:,:,nxr+1) = e_p(:,:,nxr) |
---|
| 520 | ENDIF |
---|
[1] | 521 | |
---|
| 522 | ! |
---|
[1762] | 523 | !-- The same restoration for u at i=nxl and v at j=nys as above must be made |
---|
[1933] | 524 | !-- in case of nest boundaries. This must not be done in case of vertical nesting |
---|
| 525 | !-- mode as in that case the lateral boundaries are actually cyclic. |
---|
| 526 | IF ( nesting_mode /= 'vertical' ) THEN |
---|
| 527 | IF ( nest_bound_s ) THEN |
---|
| 528 | v_p(:,nys,:) = v_p(:,nys-1,:) |
---|
| 529 | ENDIF |
---|
| 530 | IF ( nest_bound_l ) THEN |
---|
| 531 | u_p(:,:,nxl) = u_p(:,:,nxl-1) |
---|
| 532 | ENDIF |
---|
[1762] | 533 | ENDIF |
---|
| 534 | |
---|
| 535 | ! |
---|
[1409] | 536 | !-- Lateral boundary conditions for scalar quantities at the outflow |
---|
| 537 | IF ( outflow_s ) THEN |
---|
| 538 | pt_p(:,nys-1,:) = pt_p(:,nys,:) |
---|
[2232] | 539 | IF ( .NOT. constant_diffusion ) e_p(:,nys-1,:) = e_p(:,nys,:) |
---|
[1960] | 540 | IF ( humidity ) THEN |
---|
[1409] | 541 | q_p(:,nys-1,:) = q_p(:,nys,:) |
---|
[2292] | 542 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
| 543 | qc_p(:,nys-1,:) = qc_p(:,nys,:) |
---|
| 544 | nc_p(:,nys-1,:) = nc_p(:,nys,:) |
---|
| 545 | ENDIF |
---|
[1822] | 546 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1409] | 547 | qr_p(:,nys-1,:) = qr_p(:,nys,:) |
---|
| 548 | nr_p(:,nys-1,:) = nr_p(:,nys,:) |
---|
[1053] | 549 | ENDIF |
---|
[1409] | 550 | ENDIF |
---|
[1960] | 551 | IF ( passive_scalar ) s_p(:,nys-1,:) = s_p(:,nys,:) |
---|
[1409] | 552 | ELSEIF ( outflow_n ) THEN |
---|
| 553 | pt_p(:,nyn+1,:) = pt_p(:,nyn,:) |
---|
| 554 | IF ( .NOT. constant_diffusion ) e_p(:,nyn+1,:) = e_p(:,nyn,:) |
---|
[1960] | 555 | IF ( humidity ) THEN |
---|
[1409] | 556 | q_p(:,nyn+1,:) = q_p(:,nyn,:) |
---|
[2292] | 557 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
| 558 | qc_p(:,nyn+1,:) = qc_p(:,nyn,:) |
---|
| 559 | nc_p(:,nyn+1,:) = nc_p(:,nyn,:) |
---|
| 560 | ENDIF |
---|
[1822] | 561 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1409] | 562 | qr_p(:,nyn+1,:) = qr_p(:,nyn,:) |
---|
| 563 | nr_p(:,nyn+1,:) = nr_p(:,nyn,:) |
---|
[1053] | 564 | ENDIF |
---|
[1409] | 565 | ENDIF |
---|
[1960] | 566 | IF ( passive_scalar ) s_p(:,nyn+1,:) = s_p(:,nyn,:) |
---|
[1409] | 567 | ELSEIF ( outflow_l ) THEN |
---|
| 568 | pt_p(:,:,nxl-1) = pt_p(:,:,nxl) |
---|
| 569 | IF ( .NOT. constant_diffusion ) e_p(:,:,nxl-1) = e_p(:,:,nxl) |
---|
[1960] | 570 | IF ( humidity ) THEN |
---|
[1409] | 571 | q_p(:,:,nxl-1) = q_p(:,:,nxl) |
---|
[2292] | 572 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
| 573 | qc_p(:,:,nxl-1) = qc_p(:,:,nxl) |
---|
| 574 | nc_p(:,:,nxl-1) = nc_p(:,:,nxl) |
---|
| 575 | ENDIF |
---|
[1822] | 576 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1409] | 577 | qr_p(:,:,nxl-1) = qr_p(:,:,nxl) |
---|
| 578 | nr_p(:,:,nxl-1) = nr_p(:,:,nxl) |
---|
[1053] | 579 | ENDIF |
---|
[1409] | 580 | ENDIF |
---|
[1960] | 581 | IF ( passive_scalar ) s_p(:,:,nxl-1) = s_p(:,:,nxl) |
---|
[1409] | 582 | ELSEIF ( outflow_r ) THEN |
---|
| 583 | pt_p(:,:,nxr+1) = pt_p(:,:,nxr) |
---|
| 584 | IF ( .NOT. constant_diffusion ) e_p(:,:,nxr+1) = e_p(:,:,nxr) |
---|
[1960] | 585 | IF ( humidity ) THEN |
---|
[1409] | 586 | q_p(:,:,nxr+1) = q_p(:,:,nxr) |
---|
[2292] | 587 | IF ( cloud_physics .AND. microphysics_morrison ) THEN |
---|
| 588 | qc_p(:,:,nxr+1) = qc_p(:,:,nxr) |
---|
| 589 | nc_p(:,:,nxr+1) = nc_p(:,:,nxr) |
---|
| 590 | ENDIF |
---|
[1822] | 591 | IF ( cloud_physics .AND. microphysics_seifert ) THEN |
---|
[1409] | 592 | qr_p(:,:,nxr+1) = qr_p(:,:,nxr) |
---|
| 593 | nr_p(:,:,nxr+1) = nr_p(:,:,nxr) |
---|
[1053] | 594 | ENDIF |
---|
[1] | 595 | ENDIF |
---|
[1960] | 596 | IF ( passive_scalar ) s_p(:,:,nxr+1) = s_p(:,:,nxr) |
---|
[1] | 597 | ENDIF |
---|
| 598 | |
---|
| 599 | ! |
---|
[1159] | 600 | !-- Radiation boundary conditions for the velocities at the respective outflow. |
---|
| 601 | !-- The phase velocity is either assumed to the maximum phase velocity that |
---|
| 602 | !-- ensures numerical stability (CFL-condition) or calculated after |
---|
| 603 | !-- Orlanski(1976) and averaged along the outflow boundary. |
---|
[106] | 604 | IF ( outflow_s ) THEN |
---|
[75] | 605 | |
---|
[1159] | 606 | IF ( use_cmax ) THEN |
---|
| 607 | u_p(:,-1,:) = u(:,0,:) |
---|
| 608 | v_p(:,0,:) = v(:,1,:) |
---|
| 609 | w_p(:,-1,:) = w(:,0,:) |
---|
| 610 | ELSEIF ( .NOT. use_cmax ) THEN |
---|
[75] | 611 | |
---|
[978] | 612 | c_max = dy / dt_3d |
---|
[75] | 613 | |
---|
[1353] | 614 | c_u_m_l = 0.0_wp |
---|
| 615 | c_v_m_l = 0.0_wp |
---|
| 616 | c_w_m_l = 0.0_wp |
---|
[978] | 617 | |
---|
[1353] | 618 | c_u_m = 0.0_wp |
---|
| 619 | c_v_m = 0.0_wp |
---|
| 620 | c_w_m = 0.0_wp |
---|
[978] | 621 | |
---|
[75] | 622 | ! |
---|
[996] | 623 | !-- Calculate the phase speeds for u, v, and w, first local and then |
---|
| 624 | !-- average along the outflow boundary. |
---|
| 625 | DO k = nzb+1, nzt+1 |
---|
| 626 | DO i = nxl, nxr |
---|
[75] | 627 | |
---|
[106] | 628 | denom = u_m_s(k,0,i) - u_m_s(k,1,i) |
---|
| 629 | |
---|
[1353] | 630 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 631 | c_u(k,i) = -c_max * ( u(k,0,i) - u_m_s(k,0,i) ) / ( denom * tsc(2) ) |
---|
[1353] | 632 | IF ( c_u(k,i) < 0.0_wp ) THEN |
---|
| 633 | c_u(k,i) = 0.0_wp |
---|
[106] | 634 | ELSEIF ( c_u(k,i) > c_max ) THEN |
---|
| 635 | c_u(k,i) = c_max |
---|
| 636 | ENDIF |
---|
| 637 | ELSE |
---|
| 638 | c_u(k,i) = c_max |
---|
[75] | 639 | ENDIF |
---|
| 640 | |
---|
[106] | 641 | denom = v_m_s(k,1,i) - v_m_s(k,2,i) |
---|
| 642 | |
---|
[1353] | 643 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 644 | c_v(k,i) = -c_max * ( v(k,1,i) - v_m_s(k,1,i) ) / ( denom * tsc(2) ) |
---|
[1353] | 645 | IF ( c_v(k,i) < 0.0_wp ) THEN |
---|
| 646 | c_v(k,i) = 0.0_wp |
---|
[106] | 647 | ELSEIF ( c_v(k,i) > c_max ) THEN |
---|
| 648 | c_v(k,i) = c_max |
---|
| 649 | ENDIF |
---|
| 650 | ELSE |
---|
| 651 | c_v(k,i) = c_max |
---|
[75] | 652 | ENDIF |
---|
| 653 | |
---|
[106] | 654 | denom = w_m_s(k,0,i) - w_m_s(k,1,i) |
---|
[75] | 655 | |
---|
[1353] | 656 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 657 | c_w(k,i) = -c_max * ( w(k,0,i) - w_m_s(k,0,i) ) / ( denom * tsc(2) ) |
---|
[1353] | 658 | IF ( c_w(k,i) < 0.0_wp ) THEN |
---|
| 659 | c_w(k,i) = 0.0_wp |
---|
[106] | 660 | ELSEIF ( c_w(k,i) > c_max ) THEN |
---|
| 661 | c_w(k,i) = c_max |
---|
| 662 | ENDIF |
---|
| 663 | ELSE |
---|
| 664 | c_w(k,i) = c_max |
---|
[75] | 665 | ENDIF |
---|
[106] | 666 | |
---|
[978] | 667 | c_u_m_l(k) = c_u_m_l(k) + c_u(k,i) |
---|
| 668 | c_v_m_l(k) = c_v_m_l(k) + c_v(k,i) |
---|
| 669 | c_w_m_l(k) = c_w_m_l(k) + c_w(k,i) |
---|
[106] | 670 | |
---|
[978] | 671 | ENDDO |
---|
| 672 | ENDDO |
---|
[75] | 673 | |
---|
[978] | 674 | #if defined( __parallel ) |
---|
| 675 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dx, ierr ) |
---|
| 676 | CALL MPI_ALLREDUCE( c_u_m_l(nzb+1), c_u_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 677 | MPI_SUM, comm1dx, ierr ) |
---|
| 678 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dx, ierr ) |
---|
| 679 | CALL MPI_ALLREDUCE( c_v_m_l(nzb+1), c_v_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 680 | MPI_SUM, comm1dx, ierr ) |
---|
| 681 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dx, ierr ) |
---|
| 682 | CALL MPI_ALLREDUCE( c_w_m_l(nzb+1), c_w_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 683 | MPI_SUM, comm1dx, ierr ) |
---|
| 684 | #else |
---|
| 685 | c_u_m = c_u_m_l |
---|
| 686 | c_v_m = c_v_m_l |
---|
| 687 | c_w_m = c_w_m_l |
---|
| 688 | #endif |
---|
| 689 | |
---|
| 690 | c_u_m = c_u_m / (nx+1) |
---|
| 691 | c_v_m = c_v_m / (nx+1) |
---|
| 692 | c_w_m = c_w_m / (nx+1) |
---|
| 693 | |
---|
[75] | 694 | ! |
---|
[978] | 695 | !-- Save old timelevels for the next timestep |
---|
| 696 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
| 697 | u_m_s(:,:,:) = u(:,0:1,:) |
---|
| 698 | v_m_s(:,:,:) = v(:,1:2,:) |
---|
| 699 | w_m_s(:,:,:) = w(:,0:1,:) |
---|
| 700 | ENDIF |
---|
| 701 | |
---|
| 702 | ! |
---|
| 703 | !-- Calculate the new velocities |
---|
[996] | 704 | DO k = nzb+1, nzt+1 |
---|
| 705 | DO i = nxlg, nxrg |
---|
[978] | 706 | u_p(k,-1,i) = u(k,-1,i) - dt_3d * tsc(2) * c_u_m(k) * & |
---|
[75] | 707 | ( u(k,-1,i) - u(k,0,i) ) * ddy |
---|
| 708 | |
---|
[978] | 709 | v_p(k,0,i) = v(k,0,i) - dt_3d * tsc(2) * c_v_m(k) * & |
---|
[106] | 710 | ( v(k,0,i) - v(k,1,i) ) * ddy |
---|
[75] | 711 | |
---|
[978] | 712 | w_p(k,-1,i) = w(k,-1,i) - dt_3d * tsc(2) * c_w_m(k) * & |
---|
[75] | 713 | ( w(k,-1,i) - w(k,0,i) ) * ddy |
---|
[978] | 714 | ENDDO |
---|
[75] | 715 | ENDDO |
---|
| 716 | |
---|
| 717 | ! |
---|
[978] | 718 | !-- Bottom boundary at the outflow |
---|
| 719 | IF ( ibc_uv_b == 0 ) THEN |
---|
[1353] | 720 | u_p(nzb,-1,:) = 0.0_wp |
---|
| 721 | v_p(nzb,0,:) = 0.0_wp |
---|
[978] | 722 | ELSE |
---|
| 723 | u_p(nzb,-1,:) = u_p(nzb+1,-1,:) |
---|
| 724 | v_p(nzb,0,:) = v_p(nzb+1,0,:) |
---|
| 725 | ENDIF |
---|
[1353] | 726 | w_p(nzb,-1,:) = 0.0_wp |
---|
[73] | 727 | |
---|
[75] | 728 | ! |
---|
[978] | 729 | !-- Top boundary at the outflow |
---|
| 730 | IF ( ibc_uv_t == 0 ) THEN |
---|
| 731 | u_p(nzt+1,-1,:) = u_init(nzt+1) |
---|
| 732 | v_p(nzt+1,0,:) = v_init(nzt+1) |
---|
| 733 | ELSE |
---|
[1742] | 734 | u_p(nzt+1,-1,:) = u_p(nzt,-1,:) |
---|
| 735 | v_p(nzt+1,0,:) = v_p(nzt,0,:) |
---|
[978] | 736 | ENDIF |
---|
[1353] | 737 | w_p(nzt:nzt+1,-1,:) = 0.0_wp |
---|
[978] | 738 | |
---|
[75] | 739 | ENDIF |
---|
[73] | 740 | |
---|
[75] | 741 | ENDIF |
---|
[73] | 742 | |
---|
[106] | 743 | IF ( outflow_n ) THEN |
---|
[73] | 744 | |
---|
[1159] | 745 | IF ( use_cmax ) THEN |
---|
| 746 | u_p(:,ny+1,:) = u(:,ny,:) |
---|
| 747 | v_p(:,ny+1,:) = v(:,ny,:) |
---|
| 748 | w_p(:,ny+1,:) = w(:,ny,:) |
---|
| 749 | ELSEIF ( .NOT. use_cmax ) THEN |
---|
[75] | 750 | |
---|
[978] | 751 | c_max = dy / dt_3d |
---|
[75] | 752 | |
---|
[1353] | 753 | c_u_m_l = 0.0_wp |
---|
| 754 | c_v_m_l = 0.0_wp |
---|
| 755 | c_w_m_l = 0.0_wp |
---|
[978] | 756 | |
---|
[1353] | 757 | c_u_m = 0.0_wp |
---|
| 758 | c_v_m = 0.0_wp |
---|
| 759 | c_w_m = 0.0_wp |
---|
[978] | 760 | |
---|
[1] | 761 | ! |
---|
[996] | 762 | !-- Calculate the phase speeds for u, v, and w, first local and then |
---|
| 763 | !-- average along the outflow boundary. |
---|
| 764 | DO k = nzb+1, nzt+1 |
---|
| 765 | DO i = nxl, nxr |
---|
[73] | 766 | |
---|
[106] | 767 | denom = u_m_n(k,ny,i) - u_m_n(k,ny-1,i) |
---|
| 768 | |
---|
[1353] | 769 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 770 | c_u(k,i) = -c_max * ( u(k,ny,i) - u_m_n(k,ny,i) ) / ( denom * tsc(2) ) |
---|
[1353] | 771 | IF ( c_u(k,i) < 0.0_wp ) THEN |
---|
| 772 | c_u(k,i) = 0.0_wp |
---|
[106] | 773 | ELSEIF ( c_u(k,i) > c_max ) THEN |
---|
| 774 | c_u(k,i) = c_max |
---|
| 775 | ENDIF |
---|
| 776 | ELSE |
---|
| 777 | c_u(k,i) = c_max |
---|
[73] | 778 | ENDIF |
---|
| 779 | |
---|
[106] | 780 | denom = v_m_n(k,ny,i) - v_m_n(k,ny-1,i) |
---|
[73] | 781 | |
---|
[1353] | 782 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 783 | c_v(k,i) = -c_max * ( v(k,ny,i) - v_m_n(k,ny,i) ) / ( denom * tsc(2) ) |
---|
[1353] | 784 | IF ( c_v(k,i) < 0.0_wp ) THEN |
---|
| 785 | c_v(k,i) = 0.0_wp |
---|
[106] | 786 | ELSEIF ( c_v(k,i) > c_max ) THEN |
---|
| 787 | c_v(k,i) = c_max |
---|
| 788 | ENDIF |
---|
| 789 | ELSE |
---|
| 790 | c_v(k,i) = c_max |
---|
[73] | 791 | ENDIF |
---|
| 792 | |
---|
[106] | 793 | denom = w_m_n(k,ny,i) - w_m_n(k,ny-1,i) |
---|
[73] | 794 | |
---|
[1353] | 795 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 796 | c_w(k,i) = -c_max * ( w(k,ny,i) - w_m_n(k,ny,i) ) / ( denom * tsc(2) ) |
---|
[1353] | 797 | IF ( c_w(k,i) < 0.0_wp ) THEN |
---|
| 798 | c_w(k,i) = 0.0_wp |
---|
[106] | 799 | ELSEIF ( c_w(k,i) > c_max ) THEN |
---|
| 800 | c_w(k,i) = c_max |
---|
| 801 | ENDIF |
---|
| 802 | ELSE |
---|
| 803 | c_w(k,i) = c_max |
---|
[73] | 804 | ENDIF |
---|
[106] | 805 | |
---|
[978] | 806 | c_u_m_l(k) = c_u_m_l(k) + c_u(k,i) |
---|
| 807 | c_v_m_l(k) = c_v_m_l(k) + c_v(k,i) |
---|
| 808 | c_w_m_l(k) = c_w_m_l(k) + c_w(k,i) |
---|
[106] | 809 | |
---|
[978] | 810 | ENDDO |
---|
| 811 | ENDDO |
---|
[73] | 812 | |
---|
[978] | 813 | #if defined( __parallel ) |
---|
| 814 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dx, ierr ) |
---|
| 815 | CALL MPI_ALLREDUCE( c_u_m_l(nzb+1), c_u_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 816 | MPI_SUM, comm1dx, ierr ) |
---|
| 817 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dx, ierr ) |
---|
| 818 | CALL MPI_ALLREDUCE( c_v_m_l(nzb+1), c_v_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 819 | MPI_SUM, comm1dx, ierr ) |
---|
| 820 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dx, ierr ) |
---|
| 821 | CALL MPI_ALLREDUCE( c_w_m_l(nzb+1), c_w_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 822 | MPI_SUM, comm1dx, ierr ) |
---|
| 823 | #else |
---|
| 824 | c_u_m = c_u_m_l |
---|
| 825 | c_v_m = c_v_m_l |
---|
| 826 | c_w_m = c_w_m_l |
---|
| 827 | #endif |
---|
| 828 | |
---|
| 829 | c_u_m = c_u_m / (nx+1) |
---|
| 830 | c_v_m = c_v_m / (nx+1) |
---|
| 831 | c_w_m = c_w_m / (nx+1) |
---|
| 832 | |
---|
[73] | 833 | ! |
---|
[978] | 834 | !-- Save old timelevels for the next timestep |
---|
| 835 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
| 836 | u_m_n(:,:,:) = u(:,ny-1:ny,:) |
---|
| 837 | v_m_n(:,:,:) = v(:,ny-1:ny,:) |
---|
| 838 | w_m_n(:,:,:) = w(:,ny-1:ny,:) |
---|
| 839 | ENDIF |
---|
[73] | 840 | |
---|
[978] | 841 | ! |
---|
| 842 | !-- Calculate the new velocities |
---|
[996] | 843 | DO k = nzb+1, nzt+1 |
---|
| 844 | DO i = nxlg, nxrg |
---|
[978] | 845 | u_p(k,ny+1,i) = u(k,ny+1,i) - dt_3d * tsc(2) * c_u_m(k) * & |
---|
| 846 | ( u(k,ny+1,i) - u(k,ny,i) ) * ddy |
---|
[73] | 847 | |
---|
[978] | 848 | v_p(k,ny+1,i) = v(k,ny+1,i) - dt_3d * tsc(2) * c_v_m(k) * & |
---|
| 849 | ( v(k,ny+1,i) - v(k,ny,i) ) * ddy |
---|
[73] | 850 | |
---|
[978] | 851 | w_p(k,ny+1,i) = w(k,ny+1,i) - dt_3d * tsc(2) * c_w_m(k) * & |
---|
| 852 | ( w(k,ny+1,i) - w(k,ny,i) ) * ddy |
---|
| 853 | ENDDO |
---|
[1] | 854 | ENDDO |
---|
| 855 | |
---|
| 856 | ! |
---|
[978] | 857 | !-- Bottom boundary at the outflow |
---|
| 858 | IF ( ibc_uv_b == 0 ) THEN |
---|
[1353] | 859 | u_p(nzb,ny+1,:) = 0.0_wp |
---|
| 860 | v_p(nzb,ny+1,:) = 0.0_wp |
---|
[978] | 861 | ELSE |
---|
| 862 | u_p(nzb,ny+1,:) = u_p(nzb+1,ny+1,:) |
---|
| 863 | v_p(nzb,ny+1,:) = v_p(nzb+1,ny+1,:) |
---|
| 864 | ENDIF |
---|
[1353] | 865 | w_p(nzb,ny+1,:) = 0.0_wp |
---|
[73] | 866 | |
---|
| 867 | ! |
---|
[978] | 868 | !-- Top boundary at the outflow |
---|
| 869 | IF ( ibc_uv_t == 0 ) THEN |
---|
| 870 | u_p(nzt+1,ny+1,:) = u_init(nzt+1) |
---|
| 871 | v_p(nzt+1,ny+1,:) = v_init(nzt+1) |
---|
| 872 | ELSE |
---|
| 873 | u_p(nzt+1,ny+1,:) = u_p(nzt,nyn+1,:) |
---|
| 874 | v_p(nzt+1,ny+1,:) = v_p(nzt,nyn+1,:) |
---|
| 875 | ENDIF |
---|
[1353] | 876 | w_p(nzt:nzt+1,ny+1,:) = 0.0_wp |
---|
[978] | 877 | |
---|
[1] | 878 | ENDIF |
---|
| 879 | |
---|
[75] | 880 | ENDIF |
---|
| 881 | |
---|
[106] | 882 | IF ( outflow_l ) THEN |
---|
[75] | 883 | |
---|
[1159] | 884 | IF ( use_cmax ) THEN |
---|
[1717] | 885 | u_p(:,:,0) = u(:,:,1) |
---|
| 886 | v_p(:,:,-1) = v(:,:,0) |
---|
[1159] | 887 | w_p(:,:,-1) = w(:,:,0) |
---|
| 888 | ELSEIF ( .NOT. use_cmax ) THEN |
---|
[75] | 889 | |
---|
[978] | 890 | c_max = dx / dt_3d |
---|
[75] | 891 | |
---|
[1353] | 892 | c_u_m_l = 0.0_wp |
---|
| 893 | c_v_m_l = 0.0_wp |
---|
| 894 | c_w_m_l = 0.0_wp |
---|
[978] | 895 | |
---|
[1353] | 896 | c_u_m = 0.0_wp |
---|
| 897 | c_v_m = 0.0_wp |
---|
| 898 | c_w_m = 0.0_wp |
---|
[978] | 899 | |
---|
[1] | 900 | ! |
---|
[996] | 901 | !-- Calculate the phase speeds for u, v, and w, first local and then |
---|
| 902 | !-- average along the outflow boundary. |
---|
| 903 | DO k = nzb+1, nzt+1 |
---|
| 904 | DO j = nys, nyn |
---|
[75] | 905 | |
---|
[106] | 906 | denom = u_m_l(k,j,1) - u_m_l(k,j,2) |
---|
| 907 | |
---|
[1353] | 908 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 909 | c_u(k,j) = -c_max * ( u(k,j,1) - u_m_l(k,j,1) ) / ( denom * tsc(2) ) |
---|
[1353] | 910 | IF ( c_u(k,j) < 0.0_wp ) THEN |
---|
| 911 | c_u(k,j) = 0.0_wp |
---|
[107] | 912 | ELSEIF ( c_u(k,j) > c_max ) THEN |
---|
| 913 | c_u(k,j) = c_max |
---|
[106] | 914 | ENDIF |
---|
| 915 | ELSE |
---|
[107] | 916 | c_u(k,j) = c_max |
---|
[75] | 917 | ENDIF |
---|
| 918 | |
---|
[106] | 919 | denom = v_m_l(k,j,0) - v_m_l(k,j,1) |
---|
[75] | 920 | |
---|
[1353] | 921 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 922 | c_v(k,j) = -c_max * ( v(k,j,0) - v_m_l(k,j,0) ) / ( denom * tsc(2) ) |
---|
[1353] | 923 | IF ( c_v(k,j) < 0.0_wp ) THEN |
---|
| 924 | c_v(k,j) = 0.0_wp |
---|
[106] | 925 | ELSEIF ( c_v(k,j) > c_max ) THEN |
---|
| 926 | c_v(k,j) = c_max |
---|
| 927 | ENDIF |
---|
| 928 | ELSE |
---|
| 929 | c_v(k,j) = c_max |
---|
[75] | 930 | ENDIF |
---|
| 931 | |
---|
[106] | 932 | denom = w_m_l(k,j,0) - w_m_l(k,j,1) |
---|
[75] | 933 | |
---|
[1353] | 934 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 935 | c_w(k,j) = -c_max * ( w(k,j,0) - w_m_l(k,j,0) ) / ( denom * tsc(2) ) |
---|
[1353] | 936 | IF ( c_w(k,j) < 0.0_wp ) THEN |
---|
| 937 | c_w(k,j) = 0.0_wp |
---|
[106] | 938 | ELSEIF ( c_w(k,j) > c_max ) THEN |
---|
| 939 | c_w(k,j) = c_max |
---|
| 940 | ENDIF |
---|
| 941 | ELSE |
---|
| 942 | c_w(k,j) = c_max |
---|
[75] | 943 | ENDIF |
---|
[106] | 944 | |
---|
[978] | 945 | c_u_m_l(k) = c_u_m_l(k) + c_u(k,j) |
---|
| 946 | c_v_m_l(k) = c_v_m_l(k) + c_v(k,j) |
---|
| 947 | c_w_m_l(k) = c_w_m_l(k) + c_w(k,j) |
---|
[106] | 948 | |
---|
[978] | 949 | ENDDO |
---|
| 950 | ENDDO |
---|
[75] | 951 | |
---|
[978] | 952 | #if defined( __parallel ) |
---|
| 953 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dy, ierr ) |
---|
| 954 | CALL MPI_ALLREDUCE( c_u_m_l(nzb+1), c_u_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 955 | MPI_SUM, comm1dy, ierr ) |
---|
| 956 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dy, ierr ) |
---|
| 957 | CALL MPI_ALLREDUCE( c_v_m_l(nzb+1), c_v_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 958 | MPI_SUM, comm1dy, ierr ) |
---|
| 959 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dy, ierr ) |
---|
| 960 | CALL MPI_ALLREDUCE( c_w_m_l(nzb+1), c_w_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 961 | MPI_SUM, comm1dy, ierr ) |
---|
| 962 | #else |
---|
| 963 | c_u_m = c_u_m_l |
---|
| 964 | c_v_m = c_v_m_l |
---|
| 965 | c_w_m = c_w_m_l |
---|
| 966 | #endif |
---|
| 967 | |
---|
| 968 | c_u_m = c_u_m / (ny+1) |
---|
| 969 | c_v_m = c_v_m / (ny+1) |
---|
| 970 | c_w_m = c_w_m / (ny+1) |
---|
| 971 | |
---|
[73] | 972 | ! |
---|
[978] | 973 | !-- Save old timelevels for the next timestep |
---|
| 974 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
| 975 | u_m_l(:,:,:) = u(:,:,1:2) |
---|
| 976 | v_m_l(:,:,:) = v(:,:,0:1) |
---|
| 977 | w_m_l(:,:,:) = w(:,:,0:1) |
---|
| 978 | ENDIF |
---|
| 979 | |
---|
| 980 | ! |
---|
| 981 | !-- Calculate the new velocities |
---|
[996] | 982 | DO k = nzb+1, nzt+1 |
---|
[1113] | 983 | DO j = nysg, nyng |
---|
[978] | 984 | u_p(k,j,0) = u(k,j,0) - dt_3d * tsc(2) * c_u_m(k) * & |
---|
[106] | 985 | ( u(k,j,0) - u(k,j,1) ) * ddx |
---|
[75] | 986 | |
---|
[978] | 987 | v_p(k,j,-1) = v(k,j,-1) - dt_3d * tsc(2) * c_v_m(k) * & |
---|
[75] | 988 | ( v(k,j,-1) - v(k,j,0) ) * ddx |
---|
| 989 | |
---|
[978] | 990 | w_p(k,j,-1) = w(k,j,-1) - dt_3d * tsc(2) * c_w_m(k) * & |
---|
[75] | 991 | ( w(k,j,-1) - w(k,j,0) ) * ddx |
---|
[978] | 992 | ENDDO |
---|
[75] | 993 | ENDDO |
---|
| 994 | |
---|
| 995 | ! |
---|
[978] | 996 | !-- Bottom boundary at the outflow |
---|
| 997 | IF ( ibc_uv_b == 0 ) THEN |
---|
[1353] | 998 | u_p(nzb,:,0) = 0.0_wp |
---|
| 999 | v_p(nzb,:,-1) = 0.0_wp |
---|
[978] | 1000 | ELSE |
---|
| 1001 | u_p(nzb,:,0) = u_p(nzb+1,:,0) |
---|
| 1002 | v_p(nzb,:,-1) = v_p(nzb+1,:,-1) |
---|
| 1003 | ENDIF |
---|
[1353] | 1004 | w_p(nzb,:,-1) = 0.0_wp |
---|
[1] | 1005 | |
---|
[75] | 1006 | ! |
---|
[978] | 1007 | !-- Top boundary at the outflow |
---|
| 1008 | IF ( ibc_uv_t == 0 ) THEN |
---|
[1764] | 1009 | u_p(nzt+1,:,0) = u_init(nzt+1) |
---|
[978] | 1010 | v_p(nzt+1,:,-1) = v_init(nzt+1) |
---|
| 1011 | ELSE |
---|
[1764] | 1012 | u_p(nzt+1,:,0) = u_p(nzt,:,0) |
---|
[978] | 1013 | v_p(nzt+1,:,-1) = v_p(nzt,:,-1) |
---|
| 1014 | ENDIF |
---|
[1353] | 1015 | w_p(nzt:nzt+1,:,-1) = 0.0_wp |
---|
[978] | 1016 | |
---|
[75] | 1017 | ENDIF |
---|
[73] | 1018 | |
---|
[75] | 1019 | ENDIF |
---|
[73] | 1020 | |
---|
[106] | 1021 | IF ( outflow_r ) THEN |
---|
[73] | 1022 | |
---|
[1159] | 1023 | IF ( use_cmax ) THEN |
---|
| 1024 | u_p(:,:,nx+1) = u(:,:,nx) |
---|
| 1025 | v_p(:,:,nx+1) = v(:,:,nx) |
---|
| 1026 | w_p(:,:,nx+1) = w(:,:,nx) |
---|
| 1027 | ELSEIF ( .NOT. use_cmax ) THEN |
---|
[75] | 1028 | |
---|
[978] | 1029 | c_max = dx / dt_3d |
---|
[75] | 1030 | |
---|
[1353] | 1031 | c_u_m_l = 0.0_wp |
---|
| 1032 | c_v_m_l = 0.0_wp |
---|
| 1033 | c_w_m_l = 0.0_wp |
---|
[978] | 1034 | |
---|
[1353] | 1035 | c_u_m = 0.0_wp |
---|
| 1036 | c_v_m = 0.0_wp |
---|
| 1037 | c_w_m = 0.0_wp |
---|
[978] | 1038 | |
---|
[1] | 1039 | ! |
---|
[996] | 1040 | !-- Calculate the phase speeds for u, v, and w, first local and then |
---|
| 1041 | !-- average along the outflow boundary. |
---|
| 1042 | DO k = nzb+1, nzt+1 |
---|
| 1043 | DO j = nys, nyn |
---|
[73] | 1044 | |
---|
[106] | 1045 | denom = u_m_r(k,j,nx) - u_m_r(k,j,nx-1) |
---|
| 1046 | |
---|
[1353] | 1047 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 1048 | c_u(k,j) = -c_max * ( u(k,j,nx) - u_m_r(k,j,nx) ) / ( denom * tsc(2) ) |
---|
[1353] | 1049 | IF ( c_u(k,j) < 0.0_wp ) THEN |
---|
| 1050 | c_u(k,j) = 0.0_wp |
---|
[106] | 1051 | ELSEIF ( c_u(k,j) > c_max ) THEN |
---|
| 1052 | c_u(k,j) = c_max |
---|
| 1053 | ENDIF |
---|
| 1054 | ELSE |
---|
| 1055 | c_u(k,j) = c_max |
---|
[73] | 1056 | ENDIF |
---|
| 1057 | |
---|
[106] | 1058 | denom = v_m_r(k,j,nx) - v_m_r(k,j,nx-1) |
---|
[73] | 1059 | |
---|
[1353] | 1060 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 1061 | c_v(k,j) = -c_max * ( v(k,j,nx) - v_m_r(k,j,nx) ) / ( denom * tsc(2) ) |
---|
[1353] | 1062 | IF ( c_v(k,j) < 0.0_wp ) THEN |
---|
| 1063 | c_v(k,j) = 0.0_wp |
---|
[106] | 1064 | ELSEIF ( c_v(k,j) > c_max ) THEN |
---|
| 1065 | c_v(k,j) = c_max |
---|
| 1066 | ENDIF |
---|
| 1067 | ELSE |
---|
| 1068 | c_v(k,j) = c_max |
---|
[73] | 1069 | ENDIF |
---|
| 1070 | |
---|
[106] | 1071 | denom = w_m_r(k,j,nx) - w_m_r(k,j,nx-1) |
---|
[73] | 1072 | |
---|
[1353] | 1073 | IF ( denom /= 0.0_wp ) THEN |
---|
[996] | 1074 | c_w(k,j) = -c_max * ( w(k,j,nx) - w_m_r(k,j,nx) ) / ( denom * tsc(2) ) |
---|
[1353] | 1075 | IF ( c_w(k,j) < 0.0_wp ) THEN |
---|
| 1076 | c_w(k,j) = 0.0_wp |
---|
[106] | 1077 | ELSEIF ( c_w(k,j) > c_max ) THEN |
---|
| 1078 | c_w(k,j) = c_max |
---|
| 1079 | ENDIF |
---|
| 1080 | ELSE |
---|
| 1081 | c_w(k,j) = c_max |
---|
[73] | 1082 | ENDIF |
---|
[106] | 1083 | |
---|
[978] | 1084 | c_u_m_l(k) = c_u_m_l(k) + c_u(k,j) |
---|
| 1085 | c_v_m_l(k) = c_v_m_l(k) + c_v(k,j) |
---|
| 1086 | c_w_m_l(k) = c_w_m_l(k) + c_w(k,j) |
---|
[106] | 1087 | |
---|
[978] | 1088 | ENDDO |
---|
| 1089 | ENDDO |
---|
[73] | 1090 | |
---|
[978] | 1091 | #if defined( __parallel ) |
---|
| 1092 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dy, ierr ) |
---|
| 1093 | CALL MPI_ALLREDUCE( c_u_m_l(nzb+1), c_u_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 1094 | MPI_SUM, comm1dy, ierr ) |
---|
| 1095 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dy, ierr ) |
---|
| 1096 | CALL MPI_ALLREDUCE( c_v_m_l(nzb+1), c_v_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 1097 | MPI_SUM, comm1dy, ierr ) |
---|
| 1098 | IF ( collective_wait ) CALL MPI_BARRIER( comm1dy, ierr ) |
---|
| 1099 | CALL MPI_ALLREDUCE( c_w_m_l(nzb+1), c_w_m(nzb+1), nzt-nzb, MPI_REAL, & |
---|
| 1100 | MPI_SUM, comm1dy, ierr ) |
---|
| 1101 | #else |
---|
| 1102 | c_u_m = c_u_m_l |
---|
| 1103 | c_v_m = c_v_m_l |
---|
| 1104 | c_w_m = c_w_m_l |
---|
| 1105 | #endif |
---|
| 1106 | |
---|
| 1107 | c_u_m = c_u_m / (ny+1) |
---|
| 1108 | c_v_m = c_v_m / (ny+1) |
---|
| 1109 | c_w_m = c_w_m / (ny+1) |
---|
| 1110 | |
---|
[73] | 1111 | ! |
---|
[978] | 1112 | !-- Save old timelevels for the next timestep |
---|
| 1113 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
| 1114 | u_m_r(:,:,:) = u(:,:,nx-1:nx) |
---|
| 1115 | v_m_r(:,:,:) = v(:,:,nx-1:nx) |
---|
| 1116 | w_m_r(:,:,:) = w(:,:,nx-1:nx) |
---|
| 1117 | ENDIF |
---|
[73] | 1118 | |
---|
[978] | 1119 | ! |
---|
| 1120 | !-- Calculate the new velocities |
---|
[996] | 1121 | DO k = nzb+1, nzt+1 |
---|
[1113] | 1122 | DO j = nysg, nyng |
---|
[978] | 1123 | u_p(k,j,nx+1) = u(k,j,nx+1) - dt_3d * tsc(2) * c_u_m(k) * & |
---|
| 1124 | ( u(k,j,nx+1) - u(k,j,nx) ) * ddx |
---|
[73] | 1125 | |
---|
[978] | 1126 | v_p(k,j,nx+1) = v(k,j,nx+1) - dt_3d * tsc(2) * c_v_m(k) * & |
---|
| 1127 | ( v(k,j,nx+1) - v(k,j,nx) ) * ddx |
---|
[73] | 1128 | |
---|
[978] | 1129 | w_p(k,j,nx+1) = w(k,j,nx+1) - dt_3d * tsc(2) * c_w_m(k) * & |
---|
| 1130 | ( w(k,j,nx+1) - w(k,j,nx) ) * ddx |
---|
| 1131 | ENDDO |
---|
[73] | 1132 | ENDDO |
---|
| 1133 | |
---|
| 1134 | ! |
---|
[978] | 1135 | !-- Bottom boundary at the outflow |
---|
| 1136 | IF ( ibc_uv_b == 0 ) THEN |
---|
[1353] | 1137 | u_p(nzb,:,nx+1) = 0.0_wp |
---|
| 1138 | v_p(nzb,:,nx+1) = 0.0_wp |
---|
[978] | 1139 | ELSE |
---|
| 1140 | u_p(nzb,:,nx+1) = u_p(nzb+1,:,nx+1) |
---|
| 1141 | v_p(nzb,:,nx+1) = v_p(nzb+1,:,nx+1) |
---|
| 1142 | ENDIF |
---|
[1353] | 1143 | w_p(nzb,:,nx+1) = 0.0_wp |
---|
[73] | 1144 | |
---|
| 1145 | ! |
---|
[978] | 1146 | !-- Top boundary at the outflow |
---|
| 1147 | IF ( ibc_uv_t == 0 ) THEN |
---|
| 1148 | u_p(nzt+1,:,nx+1) = u_init(nzt+1) |
---|
| 1149 | v_p(nzt+1,:,nx+1) = v_init(nzt+1) |
---|
| 1150 | ELSE |
---|
| 1151 | u_p(nzt+1,:,nx+1) = u_p(nzt,:,nx+1) |
---|
| 1152 | v_p(nzt+1,:,nx+1) = v_p(nzt,:,nx+1) |
---|
| 1153 | ENDIF |
---|
[1742] | 1154 | w_p(nzt:nzt+1,:,nx+1) = 0.0_wp |
---|
[978] | 1155 | |
---|
[1] | 1156 | ENDIF |
---|
| 1157 | |
---|
| 1158 | ENDIF |
---|
| 1159 | |
---|
| 1160 | END SUBROUTINE boundary_conds |
---|