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