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