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