[1] | 1 | SUBROUTINE init_grid |
---|
| 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 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 | ! |
---|
[1310] | 17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[254] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1581] | 22 | ! |
---|
[1662] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: init_grid.f90 1662 2015-09-21 08:19:00Z gronemeier $ |
---|
| 27 | ! |
---|
[1662] | 28 | ! 1660 2015-09-21 08:15:16Z gronemeier |
---|
| 29 | ! Bugfix: Definition of topography grid levels if vertical grid stretching |
---|
| 30 | ! starts below the maximum topography height. |
---|
| 31 | ! |
---|
[1581] | 32 | ! 1580 2015-04-10 13:43:49Z suehring |
---|
| 33 | ! Bugfix: setting flags for 5th order scheme near buildings |
---|
| 34 | ! |
---|
[1576] | 35 | ! 1575 2015-03-27 09:56:27Z raasch |
---|
| 36 | ! adjustments for psolver-queries |
---|
| 37 | ! |
---|
[1558] | 38 | ! 1557 2015-03-05 16:43:04Z suehring |
---|
| 39 | ! Adjustment for monotoinic limiter |
---|
| 40 | ! |
---|
[1419] | 41 | ! 1418 2014-06-06 13:05:08Z fricke |
---|
| 42 | ! Bugfix: Change if-condition for stretched grid in the ocean, with the old |
---|
| 43 | ! condition and a negative value for dz_stretch_level the condition |
---|
| 44 | ! was always true for the whole model domain |
---|
| 45 | ! |
---|
[1410] | 46 | ! 1409 2014-05-23 12:11:32Z suehring |
---|
| 47 | ! Bugfix: set wall_flags_0 at inflow and outflow boundary also for i <= nxlu |
---|
| 48 | ! j <= nysv |
---|
| 49 | ! |
---|
[1354] | 50 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 51 | ! REAL constants provided with KIND-attribute |
---|
| 52 | ! |
---|
[1323] | 53 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 54 | ! REAL constants defined as wp-kind |
---|
| 55 | ! |
---|
[1321] | 56 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 57 | ! ONLY-attribute added to USE-statements, |
---|
| 58 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 59 | ! kinds are defined in new module kinds, |
---|
| 60 | ! revision history before 2012 removed, |
---|
| 61 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 62 | ! all variable declaration statements |
---|
[1321] | 63 | ! |
---|
[1222] | 64 | ! 1221 2013-09-10 08:59:13Z raasch |
---|
| 65 | ! wall_flags_00 introduced to hold bits 32-63, |
---|
| 66 | ! additional 3D-flag arrays for replacing the 2D-index array nzb_s_inner in |
---|
| 67 | ! loops optimized for openACC (pres + flow_statistics) |
---|
| 68 | ! |
---|
[1093] | 69 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 70 | ! unused variables removed |
---|
| 71 | ! |
---|
[1070] | 72 | ! 1069 2012-11-28 16:18:43Z maronga |
---|
| 73 | ! bugfix: added coupling_char to TOPOGRAPHY_DATA to allow topography in the ocean |
---|
| 74 | ! model in case of coupled runs |
---|
| 75 | ! |
---|
[1037] | 76 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 77 | ! code put under GPL (PALM 3.9) |
---|
| 78 | ! |
---|
[1017] | 79 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 80 | ! lower index for calculating wall_flags_0 set to nzb_w_inner instead of |
---|
| 81 | ! nzb_w_inner+1 |
---|
| 82 | ! |
---|
[997] | 83 | ! 996 2012-09-07 10:41:47Z raasch |
---|
| 84 | ! little reformatting |
---|
| 85 | ! |
---|
[979] | 86 | ! 978 2012-08-09 08:28:32Z fricke |
---|
| 87 | ! Bugfix: nzb_max is set to nzt at non-cyclic lateral boundaries |
---|
| 88 | ! Bugfix: Set wall_flags_0 for inflow boundary |
---|
| 89 | ! |
---|
[928] | 90 | ! 927 2012-06-06 19:15:04Z raasch |
---|
| 91 | ! Wall flags are not set for multigrid method in case of masking method |
---|
| 92 | ! |
---|
[865] | 93 | ! 864 2012-03-27 15:10:33Z gryschka |
---|
[927] | 94 | ! In case of ocean and Dirichlet bottom bc for u and v dzu_mg and ddzu_pres |
---|
| 95 | ! were not correctly defined for k=1. |
---|
[865] | 96 | ! |
---|
[863] | 97 | ! 861 2012-03-26 14:18:34Z suehring |
---|
[861] | 98 | ! Set wall_flags_0. The array is needed for degradation in ws-scheme near walls, |
---|
| 99 | ! inflow and outflow boundaries as well as near the bottom and the top of the |
---|
[863] | 100 | ! model domain.! |
---|
[861] | 101 | ! Initialization of nzb_s_inner and nzb_w_inner. |
---|
| 102 | ! gls has to be at least nbgp to do not exceed the array bounds of nzb_local |
---|
| 103 | ! while setting wall_flags_0 |
---|
| 104 | ! |
---|
[844] | 105 | ! 843 2012-02-29 15:16:21Z gryschka |
---|
| 106 | ! In case of ocean and dirichlet bc for u and v at the bottom |
---|
| 107 | ! the first u-level ist defined at same height as the first w-level |
---|
| 108 | ! |
---|
[819] | 109 | ! 818 2012-02-08 16:11:23Z maronga |
---|
| 110 | ! Bugfix: topo_height is only required if topography is used. It is thus now |
---|
| 111 | ! allocated in the topography branch |
---|
| 112 | ! |
---|
[810] | 113 | ! 809 2012-01-30 13:32:58Z maronga |
---|
| 114 | ! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives |
---|
| 115 | ! |
---|
[808] | 116 | ! 807 2012-01-25 11:53:51Z maronga |
---|
| 117 | ! New cpp directive "__check" implemented which is used by check_namelist_files |
---|
| 118 | ! |
---|
[1] | 119 | ! Revision 1.1 1997/08/11 06:17:45 raasch |
---|
| 120 | ! Initial revision (Testversion) |
---|
| 121 | ! |
---|
| 122 | ! |
---|
| 123 | ! Description: |
---|
| 124 | ! ------------ |
---|
| 125 | ! Creating grid depending constants |
---|
| 126 | !------------------------------------------------------------------------------! |
---|
| 127 | |
---|
[1320] | 128 | USE arrays_3d, & |
---|
| 129 | ONLY: dd2zu, ddzu, ddzu_pres, ddzw, dzu, dzu_mg, dzw, dzw_mg, f1_mg, & |
---|
| 130 | f2_mg, f3_mg, l_grid, l_wall, zu, zw |
---|
| 131 | |
---|
[1353] | 132 | USE control_parameters, & |
---|
[1320] | 133 | ONLY: bc_lr, bc_ns, building_height, building_length_x, & |
---|
| 134 | building_length_y, building_wall_left, building_wall_south, & |
---|
| 135 | canyon_height, canyon_wall_left, canyon_wall_south, & |
---|
| 136 | canyon_width_x, canyon_width_y, coupling_char, dp_level_ind_b, & |
---|
| 137 | dz, dz_max, dz_stretch_factor, dz_stretch_level, & |
---|
| 138 | dz_stretch_level_index, ibc_uv_b, io_blocks, io_group, & |
---|
| 139 | inflow_l, inflow_n, inflow_r, inflow_s, masking_method, & |
---|
| 140 | maximum_grid_level, message_string, momentum_advec, ocean, & |
---|
| 141 | outflow_l, outflow_n, outflow_r, outflow_s, prandtl_layer, & |
---|
| 142 | psolver, scalar_advec, topography, topography_grid_convention, & |
---|
| 143 | use_surface_fluxes, use_top_fluxes, wall_adjustment_factor |
---|
| 144 | |
---|
| 145 | USE grid_variables, & |
---|
| 146 | ONLY: ddx, ddx2, ddx2_mg, ddy, ddy2, ddy2_mg, dx, dx2, dy, dy2, fwxm, & |
---|
| 147 | fwxp, fwym, fwyp, fxm, fxp, fym, fyp, wall_e_x, wall_e_y, & |
---|
| 148 | wall_u, wall_v, wall_w_x, wall_w_y, zu_s_inner, zw_w_inner |
---|
| 149 | |
---|
| 150 | USE indices, & |
---|
| 151 | ONLY: flags, nbgp, nx, nxl, nxlg, nxlu, nxl_mg, nxr, nxrg, nxr_mg, & |
---|
| 152 | ny, nyn, nyng, nyn_mg, nys, nysv, nys_mg, nysg, nz, nzb, & |
---|
| 153 | nzb_2d, nzb_diff, nzb_diff_s_inner, nzb_diff_s_outer, & |
---|
| 154 | nzb_diff_u, nzb_diff_v, nzb_max, nzb_s_inner, nzb_s_outer, & |
---|
| 155 | nzb_u_inner, nzb_u_outer, nzb_v_inner, nzb_v_outer, & |
---|
| 156 | nzb_w_inner, nzb_w_outer, nzt, nzt_diff, nzt_mg, rflags_invers, & |
---|
| 157 | rflags_s_inner, wall_flags_0, wall_flags_00, wall_flags_1, & |
---|
| 158 | wall_flags_10, wall_flags_2, wall_flags_3, wall_flags_4, & |
---|
| 159 | wall_flags_5, wall_flags_6, wall_flags_7, wall_flags_8, & |
---|
| 160 | wall_flags_9 |
---|
| 161 | |
---|
| 162 | USE kinds |
---|
| 163 | |
---|
[1] | 164 | USE pegrid |
---|
| 165 | |
---|
| 166 | IMPLICIT NONE |
---|
| 167 | |
---|
[1320] | 168 | INTEGER(iwp) :: bh !: |
---|
| 169 | INTEGER(iwp) :: blx !: |
---|
| 170 | INTEGER(iwp) :: bly !: |
---|
| 171 | INTEGER(iwp) :: bxl !: |
---|
| 172 | INTEGER(iwp) :: bxr !: |
---|
| 173 | INTEGER(iwp) :: byn !: |
---|
| 174 | INTEGER(iwp) :: bys !: |
---|
| 175 | INTEGER(iwp) :: ch !: |
---|
| 176 | INTEGER(iwp) :: cwx !: |
---|
| 177 | INTEGER(iwp) :: cwy !: |
---|
| 178 | INTEGER(iwp) :: cxl !: |
---|
| 179 | INTEGER(iwp) :: cxr !: |
---|
| 180 | INTEGER(iwp) :: cyn !: |
---|
| 181 | INTEGER(iwp) :: cys !: |
---|
| 182 | INTEGER(iwp) :: gls !: |
---|
| 183 | INTEGER(iwp) :: i !: |
---|
| 184 | INTEGER(iwp) :: ii !: |
---|
| 185 | INTEGER(iwp) :: inc !: |
---|
| 186 | INTEGER(iwp) :: j !: |
---|
| 187 | INTEGER(iwp) :: k !: |
---|
| 188 | INTEGER(iwp) :: l !: |
---|
| 189 | INTEGER(iwp) :: nxl_l !: |
---|
| 190 | INTEGER(iwp) :: nxr_l !: |
---|
| 191 | INTEGER(iwp) :: nyn_l !: |
---|
| 192 | INTEGER(iwp) :: nys_l !: |
---|
| 193 | INTEGER(iwp) :: nzb_si !: |
---|
| 194 | INTEGER(iwp) :: nzt_l !: |
---|
| 195 | INTEGER(iwp) :: vi !: |
---|
[1] | 196 | |
---|
[1320] | 197 | INTEGER(iwp), DIMENSION(:), ALLOCATABLE :: vertical_influence !: |
---|
[1] | 198 | |
---|
[1320] | 199 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_nl !: |
---|
| 200 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_nr !: |
---|
| 201 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_sl !: |
---|
| 202 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: corner_sr !: |
---|
| 203 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_l !: |
---|
| 204 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_n !: |
---|
| 205 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_r !: |
---|
| 206 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: wall_s !: |
---|
| 207 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: nzb_local !: |
---|
| 208 | INTEGER(iwp), DIMENSION(:,:), ALLOCATABLE :: nzb_tmp !: |
---|
[1] | 209 | |
---|
[1320] | 210 | LOGICAL :: flag_set = .FALSE. !: |
---|
[861] | 211 | |
---|
[1320] | 212 | REAL(wp) :: dx_l !: |
---|
| 213 | REAL(wp) :: dy_l !: |
---|
| 214 | REAL(wp) :: dz_stretched !: |
---|
[1] | 215 | |
---|
[1320] | 216 | REAL(wp), DIMENSION(:,:), ALLOCATABLE :: topo_height !: |
---|
[1] | 217 | |
---|
[667] | 218 | |
---|
[1] | 219 | ! |
---|
[709] | 220 | !-- Calculation of horizontal array bounds including ghost layers |
---|
[667] | 221 | nxlg = nxl - nbgp |
---|
| 222 | nxrg = nxr + nbgp |
---|
| 223 | nysg = nys - nbgp |
---|
| 224 | nyng = nyn + nbgp |
---|
[709] | 225 | |
---|
[667] | 226 | ! |
---|
[1] | 227 | !-- Allocate grid arrays |
---|
[1353] | 228 | ALLOCATE( ddzu(1:nzt+1), ddzw(1:nzt+1), dd2zu(1:nzt), dzu(1:nzt+1), & |
---|
[667] | 229 | dzw(1:nzt+1), l_grid(1:nzt), zu(nzb:nzt+1), zw(nzb:nzt+1) ) |
---|
[1] | 230 | |
---|
| 231 | ! |
---|
| 232 | !-- Compute height of u-levels from constant grid length and dz stretch factors |
---|
[1353] | 233 | IF ( dz == -1.0_wp ) THEN |
---|
[254] | 234 | message_string = 'missing dz' |
---|
| 235 | CALL message( 'init_grid', 'PA0200', 1, 2, 0, 6, 0 ) |
---|
[1353] | 236 | ELSEIF ( dz <= 0.0_wp ) THEN |
---|
[254] | 237 | WRITE( message_string, * ) 'dz=',dz,' <= 0.0' |
---|
| 238 | CALL message( 'init_grid', 'PA0201', 1, 2, 0, 6, 0 ) |
---|
[1] | 239 | ENDIF |
---|
[94] | 240 | |
---|
[1] | 241 | ! |
---|
[94] | 242 | !-- Define the vertical grid levels |
---|
| 243 | IF ( .NOT. ocean ) THEN |
---|
| 244 | ! |
---|
| 245 | !-- Grid for atmosphere with surface at z=0 (k=0, w-grid). |
---|
[843] | 246 | !-- The second u-level (k=1) corresponds to the top of the |
---|
[94] | 247 | !-- Prandtl-layer. |
---|
[667] | 248 | |
---|
| 249 | IF ( ibc_uv_b == 0 .OR. ibc_uv_b == 2 ) THEN |
---|
[1353] | 250 | zu(0) = 0.0_wp |
---|
| 251 | ! zu(0) = - dz * 0.5_wp |
---|
[667] | 252 | ELSE |
---|
[1353] | 253 | zu(0) = - dz * 0.5_wp |
---|
[667] | 254 | ENDIF |
---|
[1353] | 255 | zu(1) = dz * 0.5_wp |
---|
[1] | 256 | |
---|
[94] | 257 | dz_stretch_level_index = nzt+1 |
---|
| 258 | dz_stretched = dz |
---|
| 259 | DO k = 2, nzt+1 |
---|
| 260 | IF ( dz_stretch_level <= zu(k-1) .AND. dz_stretched < dz_max ) THEN |
---|
| 261 | dz_stretched = dz_stretched * dz_stretch_factor |
---|
| 262 | dz_stretched = MIN( dz_stretched, dz_max ) |
---|
| 263 | IF ( dz_stretch_level_index == nzt+1 ) dz_stretch_level_index = k-1 |
---|
| 264 | ENDIF |
---|
| 265 | zu(k) = zu(k-1) + dz_stretched |
---|
| 266 | ENDDO |
---|
[1] | 267 | |
---|
| 268 | ! |
---|
[94] | 269 | !-- Compute the w-levels. They are always staggered half-way between the |
---|
[843] | 270 | !-- corresponding u-levels. In case of dirichlet bc for u and v at the |
---|
| 271 | !-- ground the first u- and w-level (k=0) are defined at same height (z=0). |
---|
| 272 | !-- The top w-level is extrapolated linearly. |
---|
[1353] | 273 | zw(0) = 0.0_wp |
---|
[94] | 274 | DO k = 1, nzt |
---|
[1353] | 275 | zw(k) = ( zu(k) + zu(k+1) ) * 0.5_wp |
---|
[94] | 276 | ENDDO |
---|
[1353] | 277 | zw(nzt+1) = zw(nzt) + 2.0_wp * ( zu(nzt+1) - zw(nzt) ) |
---|
[1] | 278 | |
---|
[94] | 279 | ELSE |
---|
[1] | 280 | ! |
---|
[843] | 281 | !-- Grid for ocean with free water surface is at k=nzt (w-grid). |
---|
| 282 | !-- In case of neumann bc at the ground the first first u-level (k=0) lies |
---|
| 283 | !-- below the first w-level (k=0). In case of dirichlet bc the first u- and |
---|
| 284 | !-- w-level are defined at same height, but staggered from the second level. |
---|
| 285 | !-- The second u-level (k=1) corresponds to the top of the Prandtl-layer. |
---|
[1353] | 286 | zu(nzt+1) = dz * 0.5_wp |
---|
| 287 | zu(nzt) = - dz * 0.5_wp |
---|
[94] | 288 | |
---|
| 289 | dz_stretch_level_index = 0 |
---|
| 290 | dz_stretched = dz |
---|
| 291 | DO k = nzt-1, 0, -1 |
---|
[1418] | 292 | ! |
---|
| 293 | !-- The default value of dz_stretch_level is positive, thus the first |
---|
| 294 | !-- condition is always true. Hence, the second condition is necessary. |
---|
| 295 | IF ( dz_stretch_level >= zu(k+1) .AND. dz_stretch_level <= 0.0 & |
---|
| 296 | .AND. dz_stretched < dz_max ) THEN |
---|
[94] | 297 | dz_stretched = dz_stretched * dz_stretch_factor |
---|
| 298 | dz_stretched = MIN( dz_stretched, dz_max ) |
---|
| 299 | IF ( dz_stretch_level_index == 0 ) dz_stretch_level_index = k+1 |
---|
| 300 | ENDIF |
---|
| 301 | zu(k) = zu(k+1) - dz_stretched |
---|
| 302 | ENDDO |
---|
| 303 | |
---|
| 304 | ! |
---|
| 305 | !-- Compute the w-levels. They are always staggered half-way between the |
---|
[843] | 306 | !-- corresponding u-levels, except in case of dirichlet bc for u and v |
---|
| 307 | !-- at the ground. In this case the first u- and w-level are defined at |
---|
| 308 | !-- same height. The top w-level (nzt+1) is not used but set for |
---|
| 309 | !-- consistency, since w and all scalar variables are defined up tp nzt+1. |
---|
[94] | 310 | zw(nzt+1) = dz |
---|
[1353] | 311 | zw(nzt) = 0.0_wp |
---|
[94] | 312 | DO k = 0, nzt |
---|
[1353] | 313 | zw(k) = ( zu(k) + zu(k+1) ) * 0.5_wp |
---|
[94] | 314 | ENDDO |
---|
| 315 | |
---|
[843] | 316 | ! |
---|
| 317 | !-- In case of dirichlet bc for u and v the first u- and w-level are defined |
---|
| 318 | !-- at same height. |
---|
| 319 | IF ( ibc_uv_b == 0 ) THEN |
---|
| 320 | zu(0) = zw(0) |
---|
| 321 | ENDIF |
---|
| 322 | |
---|
[94] | 323 | ENDIF |
---|
| 324 | |
---|
| 325 | ! |
---|
[1] | 326 | !-- Compute grid lengths. |
---|
| 327 | DO k = 1, nzt+1 |
---|
| 328 | dzu(k) = zu(k) - zu(k-1) |
---|
[1353] | 329 | ddzu(k) = 1.0_wp / dzu(k) |
---|
[1] | 330 | dzw(k) = zw(k) - zw(k-1) |
---|
[1353] | 331 | ddzw(k) = 1.0_wp / dzw(k) |
---|
[1] | 332 | ENDDO |
---|
| 333 | |
---|
| 334 | DO k = 1, nzt |
---|
[1353] | 335 | dd2zu(k) = 1.0_wp / ( dzu(k) + dzu(k+1) ) |
---|
[1] | 336 | ENDDO |
---|
[667] | 337 | |
---|
| 338 | ! |
---|
[709] | 339 | !-- The FFT- SOR-pressure solvers assume grid spacings of a staggered grid |
---|
| 340 | !-- everywhere. For the actual grid, the grid spacing at the lowest level |
---|
| 341 | !-- is only dz/2, but should be dz. Therefore, an additional array |
---|
| 342 | !-- containing with appropriate grid information is created for these |
---|
| 343 | !-- solvers. |
---|
[1575] | 344 | IF ( psolver(1:9) /= 'multigrid' ) THEN |
---|
[667] | 345 | ALLOCATE( ddzu_pres(1:nzt+1) ) |
---|
| 346 | ddzu_pres = ddzu |
---|
[864] | 347 | ddzu_pres(1) = ddzu_pres(2) ! change for lowest level |
---|
[667] | 348 | ENDIF |
---|
[1] | 349 | |
---|
| 350 | ! |
---|
| 351 | !-- In case of multigrid method, compute grid lengths and grid factors for the |
---|
| 352 | !-- grid levels |
---|
[1575] | 353 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
[1] | 354 | |
---|
| 355 | ALLOCATE( ddx2_mg(maximum_grid_level), ddy2_mg(maximum_grid_level), & |
---|
| 356 | dzu_mg(nzb+1:nzt+1,maximum_grid_level), & |
---|
| 357 | dzw_mg(nzb+1:nzt+1,maximum_grid_level), & |
---|
| 358 | f1_mg(nzb+1:nzt,maximum_grid_level), & |
---|
| 359 | f2_mg(nzb+1:nzt,maximum_grid_level), & |
---|
| 360 | f3_mg(nzb+1:nzt,maximum_grid_level) ) |
---|
| 361 | |
---|
| 362 | dzu_mg(:,maximum_grid_level) = dzu |
---|
[667] | 363 | ! |
---|
[864] | 364 | !-- Next line to ensure an equally spaced grid. |
---|
| 365 | dzu_mg(1,maximum_grid_level) = dzu(2) |
---|
[709] | 366 | |
---|
[1] | 367 | dzw_mg(:,maximum_grid_level) = dzw |
---|
| 368 | nzt_l = nzt |
---|
| 369 | DO l = maximum_grid_level-1, 1, -1 |
---|
[1353] | 370 | dzu_mg(nzb+1,l) = 2.0_wp * dzu_mg(nzb+1,l+1) |
---|
| 371 | dzw_mg(nzb+1,l) = 2.0_wp * dzw_mg(nzb+1,l+1) |
---|
[1] | 372 | nzt_l = nzt_l / 2 |
---|
| 373 | DO k = 2, nzt_l+1 |
---|
| 374 | dzu_mg(k,l) = dzu_mg(2*k-2,l+1) + dzu_mg(2*k-1,l+1) |
---|
| 375 | dzw_mg(k,l) = dzw_mg(2*k-2,l+1) + dzw_mg(2*k-1,l+1) |
---|
| 376 | ENDDO |
---|
| 377 | ENDDO |
---|
| 378 | |
---|
| 379 | nzt_l = nzt |
---|
| 380 | dx_l = dx |
---|
| 381 | dy_l = dy |
---|
| 382 | DO l = maximum_grid_level, 1, -1 |
---|
[1353] | 383 | ddx2_mg(l) = 1.0_wp / dx_l**2 |
---|
| 384 | ddy2_mg(l) = 1.0_wp / dy_l**2 |
---|
[1] | 385 | DO k = nzb+1, nzt_l |
---|
[1353] | 386 | f2_mg(k,l) = 1.0_wp / ( dzu_mg(k+1,l) * dzw_mg(k,l) ) |
---|
| 387 | f3_mg(k,l) = 1.0_wp / ( dzu_mg(k,l) * dzw_mg(k,l) ) |
---|
| 388 | f1_mg(k,l) = 2.0_wp * ( ddx2_mg(l) + ddy2_mg(l) ) + & |
---|
[1] | 389 | f2_mg(k,l) + f3_mg(k,l) |
---|
| 390 | ENDDO |
---|
| 391 | nzt_l = nzt_l / 2 |
---|
[1353] | 392 | dx_l = dx_l * 2.0_wp |
---|
| 393 | dy_l = dy_l * 2.0_wp |
---|
[1] | 394 | ENDDO |
---|
| 395 | |
---|
| 396 | ENDIF |
---|
| 397 | |
---|
| 398 | ! |
---|
| 399 | !-- Compute the reciprocal values of the horizontal grid lengths. |
---|
[1353] | 400 | ddx = 1.0_wp / dx |
---|
| 401 | ddy = 1.0_wp / dy |
---|
[1] | 402 | dx2 = dx * dx |
---|
| 403 | dy2 = dy * dy |
---|
[1353] | 404 | ddx2 = 1.0_wp / dx2 |
---|
| 405 | ddy2 = 1.0_wp / dy2 |
---|
[1] | 406 | |
---|
| 407 | ! |
---|
| 408 | !-- Compute the grid-dependent mixing length. |
---|
| 409 | DO k = 1, nzt |
---|
[1322] | 410 | l_grid(k) = ( dx * dy * dzw(k) )**0.33333333333333_wp |
---|
[1] | 411 | ENDDO |
---|
| 412 | |
---|
| 413 | ! |
---|
| 414 | !-- Allocate outer and inner index arrays for topography and set |
---|
[114] | 415 | !-- defaults. |
---|
| 416 | !-- nzb_local has to contain additional layers of ghost points for calculating |
---|
| 417 | !-- the flag arrays needed for the multigrid method |
---|
| 418 | gls = 2**( maximum_grid_level ) |
---|
[861] | 419 | IF ( gls < nbgp ) gls = nbgp |
---|
[667] | 420 | |
---|
[114] | 421 | ALLOCATE( corner_nl(nys:nyn,nxl:nxr), corner_nr(nys:nyn,nxl:nxr), & |
---|
| 422 | corner_sl(nys:nyn,nxl:nxr), corner_sr(nys:nyn,nxl:nxr), & |
---|
[667] | 423 | nzb_local(-gls:ny+gls,-gls:nx+gls), & |
---|
| 424 | nzb_tmp(-nbgp:ny+nbgp,-nbgp:nx+nbgp), & |
---|
[114] | 425 | wall_l(nys:nyn,nxl:nxr), wall_n(nys:nyn,nxl:nxr), & |
---|
[1] | 426 | wall_r(nys:nyn,nxl:nxr), wall_s(nys:nyn,nxl:nxr) ) |
---|
[667] | 427 | ALLOCATE( fwxm(nysg:nyng,nxlg:nxrg), fwxp(nysg:nyng,nxlg:nxrg), & |
---|
| 428 | fwym(nysg:nyng,nxlg:nxrg), fwyp(nysg:nyng,nxlg:nxrg), & |
---|
| 429 | fxm(nysg:nyng,nxlg:nxrg), fxp(nysg:nyng,nxlg:nxrg), & |
---|
| 430 | fym(nysg:nyng,nxlg:nxrg), fyp(nysg:nyng,nxlg:nxrg), & |
---|
| 431 | nzb_s_inner(nysg:nyng,nxlg:nxrg), & |
---|
| 432 | nzb_s_outer(nysg:nyng,nxlg:nxrg), & |
---|
| 433 | nzb_u_inner(nysg:nyng,nxlg:nxrg), & |
---|
| 434 | nzb_u_outer(nysg:nyng,nxlg:nxrg), & |
---|
| 435 | nzb_v_inner(nysg:nyng,nxlg:nxrg), & |
---|
| 436 | nzb_v_outer(nysg:nyng,nxlg:nxrg), & |
---|
| 437 | nzb_w_inner(nysg:nyng,nxlg:nxrg), & |
---|
| 438 | nzb_w_outer(nysg:nyng,nxlg:nxrg), & |
---|
| 439 | nzb_diff_s_inner(nysg:nyng,nxlg:nxrg), & |
---|
| 440 | nzb_diff_s_outer(nysg:nyng,nxlg:nxrg), & |
---|
| 441 | nzb_diff_u(nysg:nyng,nxlg:nxrg), & |
---|
| 442 | nzb_diff_v(nysg:nyng,nxlg:nxrg), & |
---|
| 443 | nzb_2d(nysg:nyng,nxlg:nxrg), & |
---|
[1221] | 444 | rflags_s_inner(nzb:nzt+2,nysg:nyng,nxlg:nxrg), & |
---|
| 445 | rflags_invers(nysg:nyng,nxlg:nxrg,nzb:nzt+2), & |
---|
[667] | 446 | wall_e_x(nysg:nyng,nxlg:nxrg), & |
---|
| 447 | wall_e_y(nysg:nyng,nxlg:nxrg), & |
---|
| 448 | wall_u(nysg:nyng,nxlg:nxrg), & |
---|
| 449 | wall_v(nysg:nyng,nxlg:nxrg), & |
---|
| 450 | wall_w_x(nysg:nyng,nxlg:nxrg), & |
---|
| 451 | wall_w_y(nysg:nyng,nxlg:nxrg) ) |
---|
[1] | 452 | |
---|
| 453 | |
---|
[667] | 454 | |
---|
| 455 | ALLOCATE( l_wall(nzb:nzt+1,nysg:nyng,nxlg:nxrg) ) |
---|
| 456 | |
---|
[818] | 457 | |
---|
[1] | 458 | nzb_s_inner = nzb; nzb_s_outer = nzb |
---|
| 459 | nzb_u_inner = nzb; nzb_u_outer = nzb |
---|
| 460 | nzb_v_inner = nzb; nzb_v_outer = nzb |
---|
| 461 | nzb_w_inner = nzb; nzb_w_outer = nzb |
---|
| 462 | |
---|
[1353] | 463 | rflags_s_inner = 1.0_wp |
---|
| 464 | rflags_invers = 1.0_wp |
---|
[1221] | 465 | |
---|
[1] | 466 | ! |
---|
[19] | 467 | !-- Define vertical gridpoint from (or to) which on the usual finite difference |
---|
[1] | 468 | !-- form (which does not use surface fluxes) is applied |
---|
| 469 | IF ( prandtl_layer .OR. use_surface_fluxes ) THEN |
---|
| 470 | nzb_diff = nzb + 2 |
---|
| 471 | ELSE |
---|
| 472 | nzb_diff = nzb + 1 |
---|
| 473 | ENDIF |
---|
[19] | 474 | IF ( use_top_fluxes ) THEN |
---|
| 475 | nzt_diff = nzt - 1 |
---|
| 476 | ELSE |
---|
| 477 | nzt_diff = nzt |
---|
| 478 | ENDIF |
---|
[1] | 479 | |
---|
| 480 | nzb_diff_s_inner = nzb_diff; nzb_diff_s_outer = nzb_diff |
---|
| 481 | nzb_diff_u = nzb_diff; nzb_diff_v = nzb_diff |
---|
| 482 | |
---|
[1353] | 483 | wall_e_x = 0.0_wp; wall_e_y = 0.0_wp; wall_u = 0.0_wp; wall_v = 0.0_wp |
---|
| 484 | wall_w_x = 0.0_wp; wall_w_y = 0.0_wp |
---|
| 485 | fwxp = 1.0_wp; fwxm = 1.0_wp; fwyp = 1.0_wp; fwym = 1.0_wp |
---|
| 486 | fxp = 1.0_wp; fxm = 1.0_wp; fyp = 1.0_wp; fym = 1.0_wp |
---|
[1] | 487 | |
---|
| 488 | ! |
---|
| 489 | !-- Initialize near-wall mixing length l_wall only in the vertical direction |
---|
| 490 | !-- for the moment, |
---|
| 491 | !-- multiplication with wall_adjustment_factor near the end of this routine |
---|
| 492 | l_wall(nzb,:,:) = l_grid(1) |
---|
| 493 | DO k = nzb+1, nzt |
---|
| 494 | l_wall(k,:,:) = l_grid(k) |
---|
| 495 | ENDDO |
---|
| 496 | l_wall(nzt+1,:,:) = l_grid(nzt) |
---|
| 497 | |
---|
| 498 | ALLOCATE ( vertical_influence(nzb:nzt) ) |
---|
| 499 | DO k = 1, nzt |
---|
| 500 | vertical_influence(k) = MIN ( INT( l_grid(k) / & |
---|
[1353] | 501 | ( wall_adjustment_factor * dzw(k) ) + 0.5_wp ), nzt - k ) |
---|
[1] | 502 | ENDDO |
---|
| 503 | |
---|
| 504 | DO k = 1, MAXVAL( nzb_s_inner ) |
---|
[1353] | 505 | IF ( l_grid(k) > 1.5_wp * dx * wall_adjustment_factor .OR. & |
---|
| 506 | l_grid(k) > 1.5_wp * dy * wall_adjustment_factor ) THEN |
---|
[254] | 507 | WRITE( message_string, * ) 'grid anisotropy exceeds ', & |
---|
| 508 | 'threshold given by only local', & |
---|
| 509 | ' &horizontal reduction of near_wall ', & |
---|
| 510 | 'mixing length l_wall', & |
---|
| 511 | ' &starting from height level k = ', k, '.' |
---|
| 512 | CALL message( 'init_grid', 'PA0202', 0, 1, 0, 6, 0 ) |
---|
[1] | 513 | EXIT |
---|
| 514 | ENDIF |
---|
| 515 | ENDDO |
---|
| 516 | vertical_influence(0) = vertical_influence(1) |
---|
| 517 | |
---|
[667] | 518 | DO i = nxlg, nxrg |
---|
| 519 | DO j = nysg, nyng |
---|
[1] | 520 | DO k = nzb_s_inner(j,i) + 1, & |
---|
| 521 | nzb_s_inner(j,i) + vertical_influence(nzb_s_inner(j,i)) |
---|
| 522 | l_wall(k,j,i) = zu(k) - zw(nzb_s_inner(j,i)) |
---|
| 523 | ENDDO |
---|
| 524 | ENDDO |
---|
| 525 | ENDDO |
---|
| 526 | |
---|
| 527 | ! |
---|
| 528 | !-- Set outer and inner index arrays for non-flat topography. |
---|
| 529 | !-- Here consistency checks concerning domain size and periodicity are |
---|
| 530 | !-- necessary. |
---|
| 531 | !-- Within this SELECT CASE structure only nzb_local is initialized |
---|
| 532 | !-- individually depending on the chosen topography type, all other index |
---|
| 533 | !-- arrays are initialized further below. |
---|
| 534 | SELECT CASE ( TRIM( topography ) ) |
---|
| 535 | |
---|
| 536 | CASE ( 'flat' ) |
---|
| 537 | ! |
---|
[555] | 538 | !-- nzb_local is required for the multigrid solver |
---|
| 539 | nzb_local = 0 |
---|
[1] | 540 | |
---|
| 541 | CASE ( 'single_building' ) |
---|
| 542 | ! |
---|
| 543 | !-- Single rectangular building, by default centered in the middle of the |
---|
| 544 | !-- total domain |
---|
| 545 | blx = NINT( building_length_x / dx ) |
---|
| 546 | bly = NINT( building_length_y / dy ) |
---|
[1660] | 547 | bh = 0 |
---|
| 548 | DO k = 0, nzt |
---|
| 549 | IF ( building_height .GT. zw(k) ) THEN |
---|
| 550 | bh = k+1 |
---|
| 551 | ENDIF |
---|
| 552 | ENDDO |
---|
[1] | 553 | |
---|
[1322] | 554 | IF ( building_wall_left == 9999999.9_wp ) THEN |
---|
[1] | 555 | building_wall_left = ( nx + 1 - blx ) / 2 * dx |
---|
| 556 | ENDIF |
---|
| 557 | bxl = NINT( building_wall_left / dx ) |
---|
| 558 | bxr = bxl + blx |
---|
| 559 | |
---|
[1322] | 560 | IF ( building_wall_south == 9999999.9_wp ) THEN |
---|
[1] | 561 | building_wall_south = ( ny + 1 - bly ) / 2 * dy |
---|
| 562 | ENDIF |
---|
| 563 | bys = NINT( building_wall_south / dy ) |
---|
| 564 | byn = bys + bly |
---|
| 565 | |
---|
| 566 | ! |
---|
| 567 | !-- Building size has to meet some requirements |
---|
| 568 | IF ( ( bxl < 1 ) .OR. ( bxr > nx-1 ) .OR. ( bxr < bxl+3 ) .OR. & |
---|
| 569 | ( bys < 1 ) .OR. ( byn > ny-1 ) .OR. ( byn < bys+3 ) ) THEN |
---|
[274] | 570 | WRITE( message_string, * ) 'inconsistent building parameters:', & |
---|
| 571 | '& bxl=', bxl, 'bxr=', bxr, 'bys=', bys, & |
---|
| 572 | 'byn=', byn, 'nx=', nx, 'ny=', ny |
---|
[254] | 573 | CALL message( 'init_grid', 'PA0203', 1, 2, 0, 6, 0 ) |
---|
[1] | 574 | ENDIF |
---|
| 575 | |
---|
| 576 | ! |
---|
[217] | 577 | !-- Define the building. |
---|
[1] | 578 | nzb_local = 0 |
---|
[134] | 579 | nzb_local(bys:byn,bxl:bxr) = bh |
---|
[1] | 580 | |
---|
[240] | 581 | CASE ( 'single_street_canyon' ) |
---|
| 582 | ! |
---|
| 583 | !-- Single quasi-2D street canyon of infinite length in x or y direction. |
---|
| 584 | !-- The canyon is centered in the other direction by default. |
---|
[1322] | 585 | IF ( canyon_width_x /= 9999999.9_wp ) THEN |
---|
[240] | 586 | ! |
---|
| 587 | !-- Street canyon in y direction |
---|
| 588 | cwx = NINT( canyon_width_x / dx ) |
---|
[1322] | 589 | IF ( canyon_wall_left == 9999999.9_wp ) THEN |
---|
[240] | 590 | canyon_wall_left = ( nx + 1 - cwx ) / 2 * dx |
---|
| 591 | ENDIF |
---|
| 592 | cxl = NINT( canyon_wall_left / dx ) |
---|
| 593 | cxr = cxl + cwx |
---|
| 594 | |
---|
[1322] | 595 | ELSEIF ( canyon_width_y /= 9999999.9_wp ) THEN |
---|
[240] | 596 | ! |
---|
| 597 | !-- Street canyon in x direction |
---|
| 598 | cwy = NINT( canyon_width_y / dy ) |
---|
[1322] | 599 | IF ( canyon_wall_south == 9999999.9_wp ) THEN |
---|
[240] | 600 | canyon_wall_south = ( ny + 1 - cwy ) / 2 * dy |
---|
| 601 | ENDIF |
---|
| 602 | cys = NINT( canyon_wall_south / dy ) |
---|
| 603 | cyn = cys + cwy |
---|
| 604 | |
---|
| 605 | ELSE |
---|
[254] | 606 | |
---|
| 607 | message_string = 'no street canyon width given' |
---|
| 608 | CALL message( 'init_grid', 'PA0204', 1, 2, 0, 6, 0 ) |
---|
| 609 | |
---|
[240] | 610 | ENDIF |
---|
| 611 | |
---|
[1660] | 612 | ch = 0 |
---|
| 613 | DO k = 0, nzt |
---|
| 614 | IF ( canyon_height .GT. zw(k) ) THEN |
---|
| 615 | ch = k+1 |
---|
| 616 | ENDIF |
---|
| 617 | ENDDO |
---|
[240] | 618 | dp_level_ind_b = ch |
---|
| 619 | ! |
---|
| 620 | !-- Street canyon size has to meet some requirements |
---|
[1322] | 621 | IF ( canyon_width_x /= 9999999.9_wp ) THEN |
---|
[1353] | 622 | IF ( ( cxl < 1 ) .OR. ( cxr > nx-1 ) .OR. ( cwx < 3 ) .OR. & |
---|
[240] | 623 | ( ch < 3 ) ) THEN |
---|
[1353] | 624 | WRITE( message_string, * ) 'inconsistent canyon parameters:', & |
---|
| 625 | '&cxl=', cxl, 'cxr=', cxr, & |
---|
| 626 | 'cwx=', cwx, & |
---|
[254] | 627 | 'ch=', ch, 'nx=', nx, 'ny=', ny |
---|
| 628 | CALL message( 'init_grid', 'PA0205', 1, 2, 0, 6, 0 ) |
---|
[240] | 629 | ENDIF |
---|
[1322] | 630 | ELSEIF ( canyon_width_y /= 9999999.9_wp ) THEN |
---|
[1353] | 631 | IF ( ( cys < 1 ) .OR. ( cyn > ny-1 ) .OR. ( cwy < 3 ) .OR. & |
---|
[240] | 632 | ( ch < 3 ) ) THEN |
---|
[1353] | 633 | WRITE( message_string, * ) 'inconsistent canyon parameters:', & |
---|
| 634 | '&cys=', cys, 'cyn=', cyn, & |
---|
| 635 | 'cwy=', cwy, & |
---|
[254] | 636 | 'ch=', ch, 'nx=', nx, 'ny=', ny |
---|
| 637 | CALL message( 'init_grid', 'PA0206', 1, 2, 0, 6, 0 ) |
---|
[240] | 638 | ENDIF |
---|
| 639 | ENDIF |
---|
[1353] | 640 | IF ( canyon_width_x /= 9999999.9_wp .AND. & |
---|
| 641 | canyon_width_y /= 9999999.9_wp ) THEN |
---|
| 642 | message_string = 'inconsistent canyon parameters:' // & |
---|
| 643 | '&street canyon can only be oriented' // & |
---|
[254] | 644 | '&either in x- or in y-direction' |
---|
| 645 | CALL message( 'init_grid', 'PA0207', 1, 2, 0, 6, 0 ) |
---|
[240] | 646 | ENDIF |
---|
| 647 | |
---|
| 648 | nzb_local = ch |
---|
[1322] | 649 | IF ( canyon_width_x /= 9999999.9_wp ) THEN |
---|
[240] | 650 | nzb_local(:,cxl+1:cxr-1) = 0 |
---|
[1322] | 651 | ELSEIF ( canyon_width_y /= 9999999.9_wp ) THEN |
---|
[240] | 652 | nzb_local(cys+1:cyn-1,:) = 0 |
---|
| 653 | ENDIF |
---|
| 654 | |
---|
[1] | 655 | CASE ( 'read_from_file' ) |
---|
[759] | 656 | |
---|
[818] | 657 | ALLOCATE ( topo_height(0:ny,0:nx) ) |
---|
| 658 | |
---|
[759] | 659 | DO ii = 0, io_blocks-1 |
---|
| 660 | IF ( ii == io_group ) THEN |
---|
| 661 | |
---|
[1] | 662 | ! |
---|
[759] | 663 | !-- Arbitrary irregular topography data in PALM format (exactly |
---|
| 664 | !-- matching the grid size and total domain size) |
---|
[1069] | 665 | OPEN( 90, FILE='TOPOGRAPHY_DATA'//coupling_char, STATUS='OLD', & |
---|
[759] | 666 | FORM='FORMATTED', ERR=10 ) |
---|
| 667 | DO j = ny, 0, -1 |
---|
| 668 | READ( 90, *, ERR=11, END=11 ) ( topo_height(j,i), i = 0,nx ) |
---|
| 669 | ENDDO |
---|
| 670 | |
---|
| 671 | GOTO 12 |
---|
| 672 | |
---|
[1069] | 673 | 10 message_string = 'file TOPOGRAPHY'//coupling_char//' does not exist' |
---|
[759] | 674 | CALL message( 'init_grid', 'PA0208', 1, 2, 0, 6, 0 ) |
---|
| 675 | |
---|
[1069] | 676 | 11 message_string = 'errors in file TOPOGRAPHY_DATA'//coupling_char |
---|
[759] | 677 | CALL message( 'init_grid', 'PA0209', 1, 2, 0, 6, 0 ) |
---|
| 678 | |
---|
| 679 | 12 CLOSE( 90 ) |
---|
| 680 | |
---|
| 681 | ENDIF |
---|
[809] | 682 | #if defined( __parallel ) && ! defined ( __check ) |
---|
[759] | 683 | CALL MPI_BARRIER( comm2d, ierr ) |
---|
| 684 | #endif |
---|
[559] | 685 | ENDDO |
---|
[759] | 686 | |
---|
[1] | 687 | ! |
---|
| 688 | !-- Calculate the index height of the topography |
---|
| 689 | DO i = 0, nx |
---|
| 690 | DO j = 0, ny |
---|
[1660] | 691 | nzb_local(j,i) = 0 |
---|
| 692 | DO k = 0, nzt |
---|
| 693 | IF ( topo_height(j,i) .GT. zw(k) ) THEN |
---|
| 694 | nzb_local(j,i) = k+1 |
---|
| 695 | ENDIF |
---|
| 696 | ENDDO |
---|
[1] | 697 | ENDDO |
---|
| 698 | ENDDO |
---|
[818] | 699 | |
---|
| 700 | DEALLOCATE ( topo_height ) |
---|
[114] | 701 | ! |
---|
[759] | 702 | !-- Add cyclic boundaries (additional layers are for calculating |
---|
| 703 | !-- flag arrays needed for the multigrid sover) |
---|
[114] | 704 | nzb_local(-gls:-1,0:nx) = nzb_local(ny-gls+1:ny,0:nx) |
---|
| 705 | nzb_local(ny+1:ny+gls,0:nx) = nzb_local(0:gls-1,0:nx) |
---|
| 706 | nzb_local(:,-gls:-1) = nzb_local(:,nx-gls+1:nx) |
---|
| 707 | nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1) |
---|
[667] | 708 | |
---|
[1] | 709 | CASE DEFAULT |
---|
| 710 | ! |
---|
| 711 | !-- The DEFAULT case is reached either if the parameter topography |
---|
[217] | 712 | !-- contains a wrong character string or if the user has defined a special |
---|
[1] | 713 | !-- case in the user interface. There, the subroutine user_init_grid |
---|
| 714 | !-- checks which of these two conditions applies. |
---|
[114] | 715 | CALL user_init_grid( gls, nzb_local ) |
---|
[1] | 716 | |
---|
| 717 | END SELECT |
---|
| 718 | ! |
---|
[861] | 719 | !-- Determine the maximum level of topography. Furthermore it is used for |
---|
| 720 | !-- steering the degradation of order of the applied advection scheme. |
---|
[978] | 721 | !-- In case of non-cyclic lateral boundaries, the order of the advection |
---|
[996] | 722 | !-- scheme have to be reduced up to nzt (required at the lateral boundaries). |
---|
[861] | 723 | nzb_max = MAXVAL( nzb_local ) |
---|
[1353] | 724 | IF ( inflow_l .OR. outflow_l .OR. inflow_r .OR. outflow_r .OR. & |
---|
[978] | 725 | inflow_n .OR. outflow_n .OR. inflow_s .OR. outflow_s ) THEN |
---|
| 726 | nzb_max = nzt |
---|
| 727 | ENDIF |
---|
| 728 | |
---|
[861] | 729 | ! |
---|
[1] | 730 | !-- Consistency checks and index array initialization are only required for |
---|
[217] | 731 | !-- non-flat topography, also the initialization of topography height arrays |
---|
[49] | 732 | !-- zu_s_inner and zw_w_inner |
---|
[1] | 733 | IF ( TRIM( topography ) /= 'flat' ) THEN |
---|
| 734 | |
---|
| 735 | ! |
---|
| 736 | !-- Consistency checks |
---|
| 737 | IF ( MINVAL( nzb_local ) < 0 .OR. MAXVAL( nzb_local ) > nz + 1 ) THEN |
---|
[1353] | 738 | WRITE( message_string, * ) 'nzb_local values are outside the', & |
---|
| 739 | 'model domain', & |
---|
| 740 | '&MINVAL( nzb_local ) = ', MINVAL(nzb_local), & |
---|
[274] | 741 | '&MAXVAL( nzb_local ) = ', MAXVAL(nzb_local) |
---|
[254] | 742 | CALL message( 'init_grid', 'PA0210', 1, 2, 0, 6, 0 ) |
---|
[1] | 743 | ENDIF |
---|
| 744 | |
---|
[722] | 745 | IF ( bc_lr == 'cyclic' ) THEN |
---|
[1353] | 746 | IF ( ANY( nzb_local(:,-1) /= nzb_local(:,nx) ) .OR. & |
---|
[1] | 747 | ANY( nzb_local(:,0) /= nzb_local(:,nx+1) ) ) THEN |
---|
[1353] | 748 | message_string = 'nzb_local does not fulfill cyclic' // & |
---|
[254] | 749 | ' boundary condition in x-direction' |
---|
| 750 | CALL message( 'init_grid', 'PA0211', 1, 2, 0, 6, 0 ) |
---|
[1] | 751 | ENDIF |
---|
| 752 | ENDIF |
---|
[722] | 753 | IF ( bc_ns == 'cyclic' ) THEN |
---|
[1353] | 754 | IF ( ANY( nzb_local(-1,:) /= nzb_local(ny,:) ) .OR. & |
---|
[1] | 755 | ANY( nzb_local(0,:) /= nzb_local(ny+1,:) ) ) THEN |
---|
[1353] | 756 | message_string = 'nzb_local does not fulfill cyclic' // & |
---|
[254] | 757 | ' boundary condition in y-direction' |
---|
| 758 | CALL message( 'init_grid', 'PA0212', 1, 2, 0, 6, 0 ) |
---|
[1] | 759 | ENDIF |
---|
| 760 | ENDIF |
---|
| 761 | |
---|
[217] | 762 | IF ( topography_grid_convention == 'cell_edge' ) THEN |
---|
[134] | 763 | ! |
---|
[217] | 764 | !-- The array nzb_local as defined using the 'cell_edge' convention |
---|
| 765 | !-- describes the actual total size of topography which is defined at the |
---|
| 766 | !-- cell edges where u=0 on the topography walls in x-direction and v=0 |
---|
| 767 | !-- on the topography walls in y-direction. However, PALM uses individual |
---|
| 768 | !-- arrays nzb_u|v|w|s_inner|outer that are based on nzb_s_inner. |
---|
| 769 | !-- Therefore, the extent of topography in nzb_local is now reduced by |
---|
| 770 | !-- 1dx at the E topography walls and by 1dy at the N topography walls |
---|
| 771 | !-- to form the basis for nzb_s_inner. |
---|
| 772 | DO j = -gls, ny + gls |
---|
| 773 | DO i = -gls, nx |
---|
| 774 | nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j,i+1) ) |
---|
| 775 | ENDDO |
---|
[134] | 776 | ENDDO |
---|
[217] | 777 | !-- apply cyclic boundary conditions in x-direction |
---|
| 778 | !(ist das erforderlich? Ursache von Seung Bus Fehler?) |
---|
| 779 | nzb_local(:,nx+1:nx+gls) = nzb_local(:,0:gls-1) |
---|
| 780 | DO i = -gls, nx + gls |
---|
| 781 | DO j = -gls, ny |
---|
| 782 | nzb_local(j,i) = MIN( nzb_local(j,i), nzb_local(j+1,i) ) |
---|
| 783 | ENDDO |
---|
[134] | 784 | ENDDO |
---|
[217] | 785 | !-- apply cyclic boundary conditions in y-direction |
---|
| 786 | !(ist das erforderlich? Ursache von Seung Bus Fehler?) |
---|
| 787 | nzb_local(ny+1:ny+gls,:) = nzb_local(0:gls-1,:) |
---|
| 788 | ENDIF |
---|
[134] | 789 | |
---|
[1] | 790 | ! |
---|
| 791 | !-- Initialize index arrays nzb_s_inner and nzb_w_inner |
---|
[861] | 792 | nzb_s_inner = nzb_local(nysg:nyng,nxlg:nxrg) |
---|
| 793 | nzb_w_inner = nzb_local(nysg:nyng,nxlg:nxrg) |
---|
[1] | 794 | |
---|
| 795 | ! |
---|
| 796 | !-- Initialize remaining index arrays: |
---|
| 797 | !-- first pre-initialize them with nzb_s_inner... |
---|
| 798 | nzb_u_inner = nzb_s_inner |
---|
| 799 | nzb_u_outer = nzb_s_inner |
---|
| 800 | nzb_v_inner = nzb_s_inner |
---|
| 801 | nzb_v_outer = nzb_s_inner |
---|
| 802 | nzb_w_outer = nzb_s_inner |
---|
| 803 | nzb_s_outer = nzb_s_inner |
---|
| 804 | |
---|
| 805 | ! |
---|
| 806 | !-- ...then extend pre-initialized arrays in their according directions |
---|
| 807 | !-- based on nzb_local using nzb_tmp as a temporary global index array |
---|
| 808 | |
---|
| 809 | ! |
---|
| 810 | !-- nzb_s_outer: |
---|
| 811 | !-- extend nzb_local east-/westwards first, then north-/southwards |
---|
[667] | 812 | nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp) |
---|
[1] | 813 | DO j = -1, ny + 1 |
---|
| 814 | DO i = 0, nx |
---|
[1353] | 815 | nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i), & |
---|
[1] | 816 | nzb_local(j,i+1) ) |
---|
| 817 | ENDDO |
---|
| 818 | ENDDO |
---|
| 819 | DO i = nxl, nxr |
---|
| 820 | DO j = nys, nyn |
---|
[1353] | 821 | nzb_s_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i), & |
---|
[1] | 822 | nzb_tmp(j+1,i) ) |
---|
| 823 | ENDDO |
---|
| 824 | ! |
---|
| 825 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
| 826 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
| 827 | IF ( nys == 0 ) THEN |
---|
| 828 | j = -1 |
---|
| 829 | nzb_s_outer(j,i) = MAX( nzb_tmp(j+1,i), nzb_tmp(j,i) ) |
---|
| 830 | ENDIF |
---|
| 831 | IF ( nys == ny ) THEN |
---|
| 832 | j = ny + 1 |
---|
| 833 | nzb_s_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i) ) |
---|
| 834 | ENDIF |
---|
| 835 | ENDDO |
---|
| 836 | ! |
---|
| 837 | !-- nzb_w_outer: |
---|
| 838 | !-- identical to nzb_s_outer |
---|
| 839 | nzb_w_outer = nzb_s_outer |
---|
| 840 | |
---|
| 841 | ! |
---|
| 842 | !-- nzb_u_inner: |
---|
| 843 | !-- extend nzb_local rightwards only |
---|
[667] | 844 | nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp) |
---|
[1] | 845 | DO j = -1, ny + 1 |
---|
| 846 | DO i = 0, nx + 1 |
---|
| 847 | nzb_tmp(j,i) = MAX( nzb_local(j,i-1), nzb_local(j,i) ) |
---|
| 848 | ENDDO |
---|
| 849 | ENDDO |
---|
[667] | 850 | nzb_u_inner = nzb_tmp(nysg:nyng,nxlg:nxrg) |
---|
[1] | 851 | |
---|
| 852 | ! |
---|
| 853 | !-- nzb_u_outer: |
---|
| 854 | !-- extend current nzb_tmp (nzb_u_inner) north-/southwards |
---|
| 855 | DO i = nxl, nxr |
---|
| 856 | DO j = nys, nyn |
---|
[1353] | 857 | nzb_u_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i), & |
---|
[1] | 858 | nzb_tmp(j+1,i) ) |
---|
| 859 | ENDDO |
---|
| 860 | ! |
---|
| 861 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
| 862 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
| 863 | IF ( nys == 0 ) THEN |
---|
| 864 | j = -1 |
---|
| 865 | nzb_u_outer(j,i) = MAX( nzb_tmp(j+1,i), nzb_tmp(j,i) ) |
---|
| 866 | ENDIF |
---|
| 867 | IF ( nys == ny ) THEN |
---|
| 868 | j = ny + 1 |
---|
| 869 | nzb_u_outer(j,i) = MAX( nzb_tmp(j-1,i), nzb_tmp(j,i) ) |
---|
| 870 | ENDIF |
---|
| 871 | ENDDO |
---|
| 872 | |
---|
| 873 | ! |
---|
| 874 | !-- nzb_v_inner: |
---|
| 875 | !-- extend nzb_local northwards only |
---|
[667] | 876 | nzb_tmp = nzb_local(-nbgp:ny+nbgp,-nbgp:nx+nbgp) |
---|
[1] | 877 | DO i = -1, nx + 1 |
---|
| 878 | DO j = 0, ny + 1 |
---|
| 879 | nzb_tmp(j,i) = MAX( nzb_local(j-1,i), nzb_local(j,i) ) |
---|
| 880 | ENDDO |
---|
| 881 | ENDDO |
---|
[667] | 882 | nzb_v_inner = nzb_tmp(nys-nbgp:nyn+nbgp,nxl-nbgp:nxr+nbgp) |
---|
[1] | 883 | |
---|
| 884 | ! |
---|
| 885 | !-- nzb_v_outer: |
---|
| 886 | !-- extend current nzb_tmp (nzb_v_inner) right-/leftwards |
---|
| 887 | DO j = nys, nyn |
---|
| 888 | DO i = nxl, nxr |
---|
[1353] | 889 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i-1), nzb_tmp(j,i), & |
---|
[1] | 890 | nzb_tmp(j,i+1) ) |
---|
| 891 | ENDDO |
---|
| 892 | ! |
---|
| 893 | !-- non-cyclic boundary conditions (overwritten by call of |
---|
| 894 | !-- exchange_horiz_2d_int below in case of cyclic boundary conditions) |
---|
| 895 | IF ( nxl == 0 ) THEN |
---|
| 896 | i = -1 |
---|
| 897 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i+1), nzb_tmp(j,i) ) |
---|
| 898 | ENDIF |
---|
| 899 | IF ( nxr == nx ) THEN |
---|
| 900 | i = nx + 1 |
---|
| 901 | nzb_v_outer(j,i) = MAX( nzb_tmp(j,i-1), nzb_tmp(j,i) ) |
---|
| 902 | ENDIF |
---|
| 903 | ENDDO |
---|
[809] | 904 | #if ! defined ( __check ) |
---|
[1] | 905 | ! |
---|
| 906 | !-- Exchange of lateral boundary values (parallel computers) and cyclic |
---|
| 907 | !-- boundary conditions, if applicable. |
---|
| 908 | !-- Since nzb_s_inner and nzb_w_inner are derived directly from nzb_local |
---|
| 909 | !-- they do not require exchange and are not included here. |
---|
| 910 | CALL exchange_horiz_2d_int( nzb_u_inner ) |
---|
| 911 | CALL exchange_horiz_2d_int( nzb_u_outer ) |
---|
| 912 | CALL exchange_horiz_2d_int( nzb_v_inner ) |
---|
| 913 | CALL exchange_horiz_2d_int( nzb_v_outer ) |
---|
| 914 | CALL exchange_horiz_2d_int( nzb_w_outer ) |
---|
| 915 | CALL exchange_horiz_2d_int( nzb_s_outer ) |
---|
| 916 | |
---|
[49] | 917 | ! |
---|
| 918 | !-- Allocate and set the arrays containing the topography height |
---|
| 919 | IF ( myid == 0 ) THEN |
---|
| 920 | |
---|
| 921 | ALLOCATE( zu_s_inner(0:nx+1,0:ny+1), zw_w_inner(0:nx+1,0:ny+1) ) |
---|
| 922 | |
---|
| 923 | DO i = 0, nx + 1 |
---|
| 924 | DO j = 0, ny + 1 |
---|
| 925 | zu_s_inner(i,j) = zu(nzb_local(j,i)) |
---|
| 926 | zw_w_inner(i,j) = zw(nzb_local(j,i)) |
---|
| 927 | ENDDO |
---|
| 928 | ENDDO |
---|
| 929 | |
---|
| 930 | ENDIF |
---|
[1221] | 931 | ! |
---|
| 932 | !-- Set flag arrays to be used for masking of grid points |
---|
| 933 | DO i = nxlg, nxrg |
---|
| 934 | DO j = nysg, nyng |
---|
| 935 | DO k = nzb, nzt+1 |
---|
[1353] | 936 | IF ( k <= nzb_s_inner(j,i) ) rflags_s_inner(k,j,i) = 0.0_wp |
---|
| 937 | IF ( k <= nzb_s_inner(j,i) ) rflags_invers(j,i,k) = 0.0_wp |
---|
[1221] | 938 | ENDDO |
---|
| 939 | ENDDO |
---|
| 940 | ENDDO |
---|
[807] | 941 | #endif |
---|
[1] | 942 | ENDIF |
---|
| 943 | |
---|
[809] | 944 | #if ! defined ( __check ) |
---|
[1] | 945 | ! |
---|
| 946 | !-- Preliminary: to be removed after completion of the topography code! |
---|
| 947 | !-- Set the former default k index arrays nzb_2d |
---|
| 948 | nzb_2d = nzb |
---|
| 949 | |
---|
| 950 | ! |
---|
| 951 | !-- Set the individual index arrays which define the k index from which on |
---|
| 952 | !-- the usual finite difference form (which does not use surface fluxes) is |
---|
| 953 | !-- applied |
---|
| 954 | IF ( prandtl_layer .OR. use_surface_fluxes ) THEN |
---|
| 955 | nzb_diff_u = nzb_u_inner + 2 |
---|
| 956 | nzb_diff_v = nzb_v_inner + 2 |
---|
| 957 | nzb_diff_s_inner = nzb_s_inner + 2 |
---|
| 958 | nzb_diff_s_outer = nzb_s_outer + 2 |
---|
| 959 | ELSE |
---|
| 960 | nzb_diff_u = nzb_u_inner + 1 |
---|
| 961 | nzb_diff_v = nzb_v_inner + 1 |
---|
| 962 | nzb_diff_s_inner = nzb_s_inner + 1 |
---|
| 963 | nzb_diff_s_outer = nzb_s_outer + 1 |
---|
| 964 | ENDIF |
---|
| 965 | |
---|
| 966 | ! |
---|
| 967 | !-- Calculation of wall switches and factors required by diffusion_u/v.f90 and |
---|
| 968 | !-- for limitation of near-wall mixing length l_wall further below |
---|
| 969 | corner_nl = 0 |
---|
| 970 | corner_nr = 0 |
---|
| 971 | corner_sl = 0 |
---|
| 972 | corner_sr = 0 |
---|
| 973 | wall_l = 0 |
---|
| 974 | wall_n = 0 |
---|
| 975 | wall_r = 0 |
---|
| 976 | wall_s = 0 |
---|
| 977 | |
---|
| 978 | DO i = nxl, nxr |
---|
| 979 | DO j = nys, nyn |
---|
| 980 | ! |
---|
| 981 | !-- u-component |
---|
| 982 | IF ( nzb_u_outer(j,i) > nzb_u_outer(j+1,i) ) THEN |
---|
[1353] | 983 | wall_u(j,i) = 1.0_wp ! north wall (location of adjacent fluid) |
---|
| 984 | fym(j,i) = 0.0_wp |
---|
| 985 | fyp(j,i) = 1.0_wp |
---|
[1] | 986 | ELSEIF ( nzb_u_outer(j,i) > nzb_u_outer(j-1,i) ) THEN |
---|
[1353] | 987 | wall_u(j,i) = 1.0_wp ! south wall (location of adjacent fluid) |
---|
| 988 | fym(j,i) = 1.0_wp |
---|
| 989 | fyp(j,i) = 0.0_wp |
---|
[1] | 990 | ENDIF |
---|
| 991 | ! |
---|
| 992 | !-- v-component |
---|
| 993 | IF ( nzb_v_outer(j,i) > nzb_v_outer(j,i+1) ) THEN |
---|
[1353] | 994 | wall_v(j,i) = 1.0_wp ! rigth wall (location of adjacent fluid) |
---|
| 995 | fxm(j,i) = 0.0_wp |
---|
| 996 | fxp(j,i) = 1.0_wp |
---|
[1] | 997 | ELSEIF ( nzb_v_outer(j,i) > nzb_v_outer(j,i-1) ) THEN |
---|
[1353] | 998 | wall_v(j,i) = 1.0_wp ! left wall (location of adjacent fluid) |
---|
| 999 | fxm(j,i) = 1.0_wp |
---|
| 1000 | fxp(j,i) = 0.0_wp |
---|
[1] | 1001 | ENDIF |
---|
| 1002 | ! |
---|
| 1003 | !-- w-component, also used for scalars, separate arrays for shear |
---|
| 1004 | !-- production of tke |
---|
| 1005 | IF ( nzb_w_outer(j,i) > nzb_w_outer(j+1,i) ) THEN |
---|
[1353] | 1006 | wall_e_y(j,i) = 1.0_wp ! north wall (location of adjacent fluid) |
---|
| 1007 | wall_w_y(j,i) = 1.0_wp |
---|
| 1008 | fwym(j,i) = 0.0_wp |
---|
| 1009 | fwyp(j,i) = 1.0_wp |
---|
[1] | 1010 | ELSEIF ( nzb_w_outer(j,i) > nzb_w_outer(j-1,i) ) THEN |
---|
[1353] | 1011 | wall_e_y(j,i) = -1.0_wp ! south wall (location of adjacent fluid) |
---|
| 1012 | wall_w_y(j,i) = 1.0_wp |
---|
| 1013 | fwym(j,i) = 1.0_wp |
---|
| 1014 | fwyp(j,i) = 0.0_wp |
---|
[1] | 1015 | ENDIF |
---|
| 1016 | IF ( nzb_w_outer(j,i) > nzb_w_outer(j,i+1) ) THEN |
---|
[1353] | 1017 | wall_e_x(j,i) = 1.0_wp ! right wall (location of adjacent fluid) |
---|
| 1018 | wall_w_x(j,i) = 1.0_wp |
---|
| 1019 | fwxm(j,i) = 0.0_wp |
---|
| 1020 | fwxp(j,i) = 1.0_wp |
---|
[1] | 1021 | ELSEIF ( nzb_w_outer(j,i) > nzb_w_outer(j,i-1) ) THEN |
---|
[1353] | 1022 | wall_e_x(j,i) = -1.0_wp ! left wall (location of adjacent fluid) |
---|
| 1023 | wall_w_x(j,i) = 1.0_wp |
---|
| 1024 | fwxm(j,i) = 1.0_wp |
---|
| 1025 | fwxp(j,i) = 0.0_wp |
---|
[1] | 1026 | ENDIF |
---|
| 1027 | ! |
---|
| 1028 | !-- Wall and corner locations inside buildings for limitation of |
---|
| 1029 | !-- near-wall mixing length l_wall |
---|
| 1030 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j+1,i) ) THEN |
---|
| 1031 | |
---|
| 1032 | wall_n(j,i) = nzb_s_inner(j+1,i) + 1 ! North wall |
---|
| 1033 | |
---|
| 1034 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
| 1035 | corner_nl(j,i) = MAX( nzb_s_inner(j+1,i), & ! Northleft corner |
---|
| 1036 | nzb_s_inner(j,i-1) ) + 1 |
---|
| 1037 | ENDIF |
---|
| 1038 | |
---|
| 1039 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
| 1040 | corner_nr(j,i) = MAX( nzb_s_inner(j+1,i), & ! Northright corner |
---|
| 1041 | nzb_s_inner(j,i+1) ) + 1 |
---|
| 1042 | ENDIF |
---|
| 1043 | |
---|
| 1044 | ENDIF |
---|
| 1045 | |
---|
| 1046 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j-1,i) ) THEN |
---|
| 1047 | |
---|
| 1048 | wall_s(j,i) = nzb_s_inner(j-1,i) + 1 ! South wall |
---|
| 1049 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
| 1050 | corner_sl(j,i) = MAX( nzb_s_inner(j-1,i), & ! Southleft corner |
---|
| 1051 | nzb_s_inner(j,i-1) ) + 1 |
---|
| 1052 | ENDIF |
---|
| 1053 | |
---|
| 1054 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
| 1055 | corner_sr(j,i) = MAX( nzb_s_inner(j-1,i), & ! Southright corner |
---|
| 1056 | nzb_s_inner(j,i+1) ) + 1 |
---|
| 1057 | ENDIF |
---|
| 1058 | |
---|
| 1059 | ENDIF |
---|
| 1060 | |
---|
| 1061 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i-1) ) THEN |
---|
| 1062 | wall_l(j,i) = nzb_s_inner(j,i-1) + 1 ! Left wall |
---|
| 1063 | ENDIF |
---|
| 1064 | |
---|
| 1065 | IF ( nzb_s_inner(j,i) > nzb_s_inner(j,i+1) ) THEN |
---|
| 1066 | wall_r(j,i) = nzb_s_inner(j,i+1) + 1 ! Right wall |
---|
| 1067 | ENDIF |
---|
| 1068 | |
---|
| 1069 | ENDDO |
---|
| 1070 | ENDDO |
---|
| 1071 | |
---|
| 1072 | ! |
---|
[114] | 1073 | !-- Calculate wall flag arrays for the multigrid method |
---|
[1575] | 1074 | IF ( psolver(1:9) == 'multigrid' ) THEN |
---|
[114] | 1075 | ! |
---|
| 1076 | !-- Gridpoint increment of the current level |
---|
| 1077 | inc = 1 |
---|
| 1078 | |
---|
| 1079 | DO l = maximum_grid_level, 1 , -1 |
---|
| 1080 | |
---|
| 1081 | nxl_l = nxl_mg(l) |
---|
| 1082 | nxr_l = nxr_mg(l) |
---|
| 1083 | nys_l = nys_mg(l) |
---|
| 1084 | nyn_l = nyn_mg(l) |
---|
| 1085 | nzt_l = nzt_mg(l) |
---|
| 1086 | |
---|
| 1087 | ! |
---|
| 1088 | !-- Assign the flag level to be calculated |
---|
| 1089 | SELECT CASE ( l ) |
---|
| 1090 | CASE ( 1 ) |
---|
| 1091 | flags => wall_flags_1 |
---|
| 1092 | CASE ( 2 ) |
---|
| 1093 | flags => wall_flags_2 |
---|
| 1094 | CASE ( 3 ) |
---|
| 1095 | flags => wall_flags_3 |
---|
| 1096 | CASE ( 4 ) |
---|
| 1097 | flags => wall_flags_4 |
---|
| 1098 | CASE ( 5 ) |
---|
| 1099 | flags => wall_flags_5 |
---|
| 1100 | CASE ( 6 ) |
---|
| 1101 | flags => wall_flags_6 |
---|
| 1102 | CASE ( 7 ) |
---|
| 1103 | flags => wall_flags_7 |
---|
| 1104 | CASE ( 8 ) |
---|
| 1105 | flags => wall_flags_8 |
---|
| 1106 | CASE ( 9 ) |
---|
| 1107 | flags => wall_flags_9 |
---|
| 1108 | CASE ( 10 ) |
---|
| 1109 | flags => wall_flags_10 |
---|
| 1110 | END SELECT |
---|
| 1111 | |
---|
| 1112 | ! |
---|
| 1113 | !-- Depending on the grid level, set the respective bits in case of |
---|
| 1114 | !-- neighbouring walls |
---|
| 1115 | !-- Bit 0: wall to the bottom |
---|
| 1116 | !-- Bit 1: wall to the top (not realized in remaining PALM code so far) |
---|
| 1117 | !-- Bit 2: wall to the south |
---|
| 1118 | !-- Bit 3: wall to the north |
---|
| 1119 | !-- Bit 4: wall to the left |
---|
| 1120 | !-- Bit 5: wall to the right |
---|
[116] | 1121 | !-- Bit 6: inside building |
---|
[114] | 1122 | |
---|
| 1123 | flags = 0 |
---|
| 1124 | |
---|
[927] | 1125 | ! |
---|
| 1126 | !-- In case of masking method, flags are not set and multigrid method |
---|
| 1127 | !-- works like FFT-solver |
---|
| 1128 | IF ( .NOT. masking_method ) THEN |
---|
| 1129 | |
---|
| 1130 | DO i = nxl_l-1, nxr_l+1 |
---|
| 1131 | DO j = nys_l-1, nyn_l+1 |
---|
| 1132 | DO k = nzb, nzt_l+1 |
---|
[114] | 1133 | |
---|
| 1134 | ! |
---|
[927] | 1135 | !-- Inside/outside building (inside building does not need |
---|
| 1136 | !-- further tests for walls) |
---|
| 1137 | IF ( k*inc <= nzb_local(j*inc,i*inc) ) THEN |
---|
[114] | 1138 | |
---|
[927] | 1139 | flags(k,j,i) = IBSET( flags(k,j,i), 6 ) |
---|
[114] | 1140 | |
---|
[927] | 1141 | ELSE |
---|
[114] | 1142 | ! |
---|
[927] | 1143 | !-- Bottom wall |
---|
| 1144 | IF ( (k-1)*inc <= nzb_local(j*inc,i*inc) ) THEN |
---|
| 1145 | flags(k,j,i) = IBSET( flags(k,j,i), 0 ) |
---|
| 1146 | ENDIF |
---|
[114] | 1147 | ! |
---|
[927] | 1148 | !-- South wall |
---|
| 1149 | IF ( k*inc <= nzb_local((j-1)*inc,i*inc) ) THEN |
---|
| 1150 | flags(k,j,i) = IBSET( flags(k,j,i), 2 ) |
---|
| 1151 | ENDIF |
---|
[114] | 1152 | ! |
---|
[927] | 1153 | !-- North wall |
---|
| 1154 | IF ( k*inc <= nzb_local((j+1)*inc,i*inc) ) THEN |
---|
| 1155 | flags(k,j,i) = IBSET( flags(k,j,i), 3 ) |
---|
| 1156 | ENDIF |
---|
[114] | 1157 | ! |
---|
[927] | 1158 | !-- Left wall |
---|
| 1159 | IF ( k*inc <= nzb_local(j*inc,(i-1)*inc) ) THEN |
---|
| 1160 | flags(k,j,i) = IBSET( flags(k,j,i), 4 ) |
---|
| 1161 | ENDIF |
---|
[114] | 1162 | ! |
---|
[927] | 1163 | !-- Right wall |
---|
| 1164 | IF ( k*inc <= nzb_local(j*inc,(i+1)*inc) ) THEN |
---|
| 1165 | flags(k,j,i) = IBSET( flags(k,j,i), 5 ) |
---|
| 1166 | ENDIF |
---|
| 1167 | |
---|
[114] | 1168 | ENDIF |
---|
| 1169 | |
---|
[927] | 1170 | ENDDO |
---|
[114] | 1171 | ENDDO |
---|
| 1172 | ENDDO |
---|
| 1173 | |
---|
[927] | 1174 | ENDIF |
---|
| 1175 | |
---|
[114] | 1176 | ! |
---|
| 1177 | !-- Test output of flag arrays |
---|
[145] | 1178 | ! i = nxl_l |
---|
| 1179 | ! WRITE (9,*) ' ' |
---|
| 1180 | ! WRITE (9,*) '*** mg level ', l, ' ***', mg_switch_to_pe0_level |
---|
| 1181 | ! WRITE (9,*) ' inc=', inc, ' i =', nxl_l |
---|
| 1182 | ! WRITE (9,*) ' nxl_l',nxl_l,' nxr_l=',nxr_l,' nys_l=',nys_l,' nyn_l=',nyn_l |
---|
| 1183 | ! DO k = nzt_l+1, nzb, -1 |
---|
| 1184 | ! WRITE (9,'(194(1X,I2))') ( flags(k,j,i), j = nys_l-1, nyn_l+1 ) |
---|
| 1185 | ! ENDDO |
---|
[114] | 1186 | |
---|
| 1187 | inc = inc * 2 |
---|
| 1188 | |
---|
| 1189 | ENDDO |
---|
| 1190 | |
---|
| 1191 | ENDIF |
---|
[861] | 1192 | ! |
---|
| 1193 | !-- Allocate flags needed for masking walls. |
---|
[1221] | 1194 | ALLOCATE( wall_flags_0(nzb:nzt,nys:nyn,nxl:nxr), & |
---|
| 1195 | wall_flags_00(nzb:nzt,nys:nyn,nxl:nxr) ) |
---|
| 1196 | wall_flags_0 = 0 |
---|
| 1197 | wall_flags_00 = 0 |
---|
[114] | 1198 | |
---|
[1557] | 1199 | IF ( scalar_advec == 'ws-scheme' .OR. & |
---|
| 1200 | scalar_advec == 'ws-scheme-mono' ) THEN |
---|
[114] | 1201 | ! |
---|
[861] | 1202 | !-- Set flags to steer the degradation of the advection scheme in advec_ws |
---|
| 1203 | !-- near topography, inflow- and outflow boundaries as well as bottom and |
---|
| 1204 | !-- top of model domain. wall_flags_0 remains zero for all non-prognostic |
---|
| 1205 | !-- grid points. |
---|
| 1206 | DO i = nxl, nxr |
---|
| 1207 | DO j = nys, nyn |
---|
| 1208 | DO k = nzb_s_inner(j,i)+1, nzt |
---|
| 1209 | ! |
---|
| 1210 | !-- scalar - x-direction |
---|
| 1211 | !-- WS1 (0), WS3 (1), WS5 (2) |
---|
[978] | 1212 | IF ( k <= nzb_s_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )& |
---|
| 1213 | .AND. i == nxl ) .OR. ( ( inflow_r .OR. outflow_r ) & |
---|
| 1214 | .AND. i == nxr ) ) THEN |
---|
[861] | 1215 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 0 ) |
---|
| 1216 | ELSEIF ( k <= nzb_s_inner(j,i+2) .OR. k <= nzb_s_inner(j,i-1) & |
---|
[978] | 1217 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) & |
---|
| 1218 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu ) & |
---|
| 1219 | ) THEN |
---|
[861] | 1220 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 1 ) |
---|
| 1221 | ELSE |
---|
| 1222 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 2 ) |
---|
| 1223 | ENDIF |
---|
| 1224 | ! |
---|
| 1225 | !-- scalar - y-direction |
---|
| 1226 | !-- WS1 (3), WS3 (4), WS5 (5) |
---|
[978] | 1227 | IF ( k <= nzb_s_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )& |
---|
| 1228 | .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n ) & |
---|
| 1229 | .AND. j == nyn ) ) THEN |
---|
[861] | 1230 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 3 ) |
---|
| 1231 | !-- WS3 |
---|
| 1232 | ELSEIF ( k <= nzb_s_inner(j+2,i) .OR. k <= nzb_s_inner(j-1,i) & |
---|
[978] | 1233 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv ) & |
---|
| 1234 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) & |
---|
| 1235 | ) THEN |
---|
[861] | 1236 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 4 ) |
---|
| 1237 | !-- WS5 |
---|
| 1238 | ELSE |
---|
| 1239 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 5 ) |
---|
| 1240 | ENDIF |
---|
| 1241 | ! |
---|
| 1242 | !-- scalar - z-direction |
---|
| 1243 | !-- WS1 (6), WS3 (7), WS5 (8) |
---|
| 1244 | flag_set = .FALSE. |
---|
| 1245 | IF ( k == nzb_s_inner(j,i) + 1 .OR. k == nzt ) THEN |
---|
| 1246 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 6 ) |
---|
| 1247 | flag_set = .TRUE. |
---|
| 1248 | ELSEIF ( k == nzb_s_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
| 1249 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 7 ) |
---|
| 1250 | flag_set = .TRUE. |
---|
| 1251 | ELSEIF ( k > nzb_s_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
| 1252 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 8 ) |
---|
| 1253 | ENDIF |
---|
| 1254 | ENDDO |
---|
| 1255 | ENDDO |
---|
| 1256 | ENDDO |
---|
| 1257 | ENDIF |
---|
| 1258 | |
---|
| 1259 | IF ( momentum_advec == 'ws-scheme' ) THEN |
---|
| 1260 | ! |
---|
| 1261 | !-- Set wall_flags_0 to steer the degradation of the advection scheme in advec_ws |
---|
| 1262 | !-- near topography, inflow- and outflow boundaries as well as bottom and |
---|
| 1263 | !-- top of model domain. wall_flags_0 remains zero for all non-prognostic |
---|
| 1264 | !-- grid points. |
---|
| 1265 | DO i = nxl, nxr |
---|
| 1266 | DO j = nys, nyn |
---|
[1580] | 1267 | DO k = nzb+1, nzt |
---|
[861] | 1268 | ! |
---|
[1580] | 1269 | !-- At first, set flags to WS1. |
---|
| 1270 | !-- Since fluxes are swapped in advec_ws.f90, this is necessary to |
---|
| 1271 | !-- in order to handle the left/south flux. |
---|
| 1272 | !-- near vertical walls. |
---|
| 1273 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 ) |
---|
| 1274 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 ) |
---|
| 1275 | ! |
---|
[861] | 1276 | !-- u component - x-direction |
---|
| 1277 | !-- WS1 (9), WS3 (10), WS5 (11) |
---|
| 1278 | IF ( k <= nzb_u_inner(j,i+1) & |
---|
[1409] | 1279 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i <= nxlu ) & |
---|
[978] | 1280 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr ) & |
---|
| 1281 | ) THEN |
---|
[1580] | 1282 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 9 ) |
---|
[861] | 1283 | ELSEIF ( k <= nzb_u_inner(j,i+2) .OR. k <= nzb_u_inner(j,i-1) & |
---|
[978] | 1284 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 )& |
---|
| 1285 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu+1)& |
---|
| 1286 | ) THEN |
---|
[861] | 1287 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 10 ) |
---|
[1580] | 1288 | ! |
---|
| 1289 | !-- Clear flag for WS1 |
---|
| 1290 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 9 ) |
---|
[861] | 1291 | ELSE |
---|
| 1292 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 11 ) |
---|
[1580] | 1293 | ! |
---|
| 1294 | !-- Clear flag for WS1 |
---|
| 1295 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 9 ) |
---|
[861] | 1296 | ENDIF |
---|
| 1297 | ! |
---|
| 1298 | !-- u component - y-direction |
---|
| 1299 | !-- WS1 (12), WS3 (13), WS5 (14) |
---|
[978] | 1300 | IF ( k <= nzb_u_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )& |
---|
| 1301 | .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n ) & |
---|
| 1302 | .AND. j == nyn ) ) THEN |
---|
[1580] | 1303 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 12 ) |
---|
[861] | 1304 | ELSEIF ( k <= nzb_u_inner(j+2,i) .OR. k <= nzb_u_inner(j-1,i) & |
---|
[978] | 1305 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv ) & |
---|
| 1306 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) & |
---|
| 1307 | ) THEN |
---|
[861] | 1308 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 13 ) |
---|
[1580] | 1309 | ! |
---|
| 1310 | !-- Clear flag for WS1 |
---|
| 1311 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 12 ) |
---|
[861] | 1312 | ELSE |
---|
| 1313 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 14 ) |
---|
[1580] | 1314 | ! |
---|
| 1315 | !-- Clear flag for WS1 |
---|
| 1316 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 12 ) |
---|
[861] | 1317 | ENDIF |
---|
| 1318 | ! |
---|
| 1319 | !-- u component - z-direction |
---|
| 1320 | !-- WS1 (15), WS3 (16), WS5 (17) |
---|
| 1321 | flag_set = .FALSE. |
---|
| 1322 | IF ( k == nzb_u_inner(j,i) + 1 .OR. k == nzt ) THEN |
---|
| 1323 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 15 ) |
---|
| 1324 | flag_set = .TRUE. |
---|
| 1325 | ELSEIF ( k == nzb_u_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
| 1326 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 16 ) |
---|
| 1327 | flag_set = .TRUE. |
---|
| 1328 | ELSEIF ( k > nzb_u_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
| 1329 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 17 ) |
---|
| 1330 | ENDIF |
---|
| 1331 | |
---|
| 1332 | ENDDO |
---|
| 1333 | ENDDO |
---|
| 1334 | ENDDO |
---|
| 1335 | |
---|
| 1336 | DO i = nxl, nxr |
---|
| 1337 | DO j = nys, nyn |
---|
[1580] | 1338 | DO k = nzb+1, nzt |
---|
[861] | 1339 | ! |
---|
[1580] | 1340 | !-- At first, set flags to WS1. |
---|
| 1341 | !-- Since fluxes are swapped in advec_ws.f90, this is necessary to |
---|
| 1342 | !-- in order to handle the left/south flux. |
---|
| 1343 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 ) |
---|
| 1344 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 ) |
---|
| 1345 | ! |
---|
[861] | 1346 | !-- v component - x-direction |
---|
| 1347 | !-- WS1 (18), WS3 (19), WS5 (20) |
---|
[978] | 1348 | IF ( k <= nzb_v_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )& |
---|
| 1349 | .AND. i == nxl ) .OR. (( inflow_r .OR. outflow_r ) & |
---|
| 1350 | .AND. i == nxr ) ) THEN |
---|
[1580] | 1351 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 18 ) |
---|
[861] | 1352 | !-- WS3 |
---|
| 1353 | ELSEIF ( k <= nzb_v_inner(j,i+2) .OR. k <= nzb_v_inner(j,i-1) & |
---|
[978] | 1354 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) & |
---|
| 1355 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu ) & |
---|
| 1356 | ) THEN |
---|
[861] | 1357 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 19 ) |
---|
[1580] | 1358 | ! |
---|
| 1359 | !-- Clear flag for WS1 |
---|
| 1360 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 18 ) |
---|
[861] | 1361 | ELSE |
---|
| 1362 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 20 ) |
---|
[1580] | 1363 | ! |
---|
| 1364 | !-- Clear flag for WS1 |
---|
| 1365 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 18 ) |
---|
[861] | 1366 | ENDIF |
---|
| 1367 | ! |
---|
| 1368 | !-- v component - y-direction |
---|
| 1369 | !-- WS1 (21), WS3 (22), WS5 (23) |
---|
| 1370 | IF ( k <= nzb_v_inner(j+1,i) & |
---|
[1409] | 1371 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j <= nysv ) & |
---|
[978] | 1372 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn ) & |
---|
| 1373 | ) THEN |
---|
[1580] | 1374 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 21 ) |
---|
[861] | 1375 | ELSEIF ( k <= nzb_v_inner(j+2,i) .OR. k <= nzb_v_inner(j-1,i) & |
---|
[978] | 1376 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv+1 )& |
---|
| 1377 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 )& |
---|
| 1378 | ) THEN |
---|
[861] | 1379 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 22 ) |
---|
[1580] | 1380 | ! |
---|
| 1381 | !-- Clear flag for WS1 |
---|
| 1382 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 21 ) |
---|
[861] | 1383 | ELSE |
---|
| 1384 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 23 ) |
---|
[1580] | 1385 | ! |
---|
| 1386 | !-- Clear flag for WS1 |
---|
| 1387 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 21 ) |
---|
[861] | 1388 | ENDIF |
---|
| 1389 | ! |
---|
| 1390 | !-- v component - z-direction |
---|
| 1391 | !-- WS1 (24), WS3 (25), WS5 (26) |
---|
| 1392 | flag_set = .FALSE. |
---|
| 1393 | IF ( k == nzb_v_inner(j,i) + 1 .OR. k == nzt ) THEN |
---|
| 1394 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 24 ) |
---|
| 1395 | flag_set = .TRUE. |
---|
| 1396 | ELSEIF ( k == nzb_v_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
| 1397 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 25 ) |
---|
| 1398 | flag_set = .TRUE. |
---|
| 1399 | ELSEIF ( k > nzb_v_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
| 1400 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 26 ) |
---|
| 1401 | ENDIF |
---|
| 1402 | |
---|
| 1403 | ENDDO |
---|
| 1404 | ENDDO |
---|
| 1405 | ENDDO |
---|
| 1406 | DO i = nxl, nxr |
---|
| 1407 | DO j = nys, nyn |
---|
[1580] | 1408 | DO k = nzb+1, nzt |
---|
[861] | 1409 | ! |
---|
[1580] | 1410 | !-- At first, set flags to WS1. |
---|
| 1411 | !-- Since fluxes are swapped in advec_ws.f90, this is necessary to |
---|
| 1412 | !-- in order to handle the left/south flux. |
---|
| 1413 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 ) |
---|
| 1414 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 ) |
---|
| 1415 | ! |
---|
[861] | 1416 | !-- w component - x-direction |
---|
| 1417 | !-- WS1 (27), WS3 (28), WS5 (29) |
---|
[978] | 1418 | IF ( k <= nzb_w_inner(j,i+1) .OR. ( ( inflow_l .OR. outflow_l )& |
---|
| 1419 | .AND. i == nxl ) .OR. ( ( inflow_r .OR. outflow_r ) & |
---|
| 1420 | .AND. i == nxr ) ) THEN |
---|
[1580] | 1421 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 27 ) |
---|
[861] | 1422 | ELSEIF ( k <= nzb_w_inner(j,i+2) .OR. k <= nzb_w_inner(j,i-1) & |
---|
[978] | 1423 | .OR. ( ( inflow_r .OR. outflow_r ) .AND. i == nxr-1 ) & |
---|
| 1424 | .OR. ( ( inflow_l .OR. outflow_l ) .AND. i == nxlu ) & |
---|
| 1425 | ) THEN |
---|
[861] | 1426 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 28 ) |
---|
[1580] | 1427 | ! |
---|
| 1428 | !-- Clear flag for WS1 |
---|
| 1429 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 27 ) |
---|
[861] | 1430 | ELSE |
---|
| 1431 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i),29 ) |
---|
[1580] | 1432 | ! |
---|
| 1433 | !-- Clear flag for WS1 |
---|
| 1434 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 27 ) |
---|
[861] | 1435 | ENDIF |
---|
| 1436 | ! |
---|
| 1437 | !-- w component - y-direction |
---|
| 1438 | !-- WS1 (30), WS3 (31), WS5 (32) |
---|
[978] | 1439 | IF ( k <= nzb_w_inner(j+1,i) .OR. ( ( inflow_s .OR. outflow_s )& |
---|
| 1440 | .AND. j == nys ) .OR. ( ( inflow_n .OR. outflow_n ) & |
---|
| 1441 | .AND. j == nyn ) ) THEN |
---|
[1580] | 1442 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 30 ) |
---|
[861] | 1443 | ELSEIF ( k <= nzb_w_inner(j+2,i) .OR. k <= nzb_w_inner(j-1,i) & |
---|
[978] | 1444 | .OR. ( ( inflow_s .OR. outflow_s ) .AND. j == nysv ) & |
---|
| 1445 | .OR. ( ( inflow_n .OR. outflow_n ) .AND. j == nyn-1 ) & |
---|
| 1446 | ) THEN |
---|
[861] | 1447 | wall_flags_0(k,j,i) = IBSET( wall_flags_0(k,j,i), 31 ) |
---|
[1580] | 1448 | ! |
---|
| 1449 | !-- Clear flag for WS1 |
---|
| 1450 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 30 ) |
---|
[861] | 1451 | ELSE |
---|
[1221] | 1452 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 0 ) |
---|
[1580] | 1453 | ! |
---|
| 1454 | !-- Clear flag for WS1 |
---|
| 1455 | wall_flags_0(k,j,i) = IBCLR( wall_flags_0(k,j,i), 30 ) |
---|
[861] | 1456 | ENDIF |
---|
| 1457 | ! |
---|
| 1458 | !-- w component - z-direction |
---|
| 1459 | !-- WS1 (33), WS3 (34), WS5 (35) |
---|
| 1460 | flag_set = .FALSE. |
---|
| 1461 | IF ( k == nzb_w_inner(j,i) .OR. k == nzb_w_inner(j,i) + 1 & |
---|
| 1462 | .OR. k == nzt ) THEN |
---|
| 1463 | ! |
---|
| 1464 | !-- Please note, at k == nzb_w_inner(j,i) a flag is explictely |
---|
| 1465 | !-- set, although this is not a prognostic level. However, |
---|
| 1466 | !-- contrary to the advection of u,v and s this is necessary |
---|
| 1467 | !-- because flux_t(nzb_w_inner(j,i)) is used for the tendency |
---|
| 1468 | !-- at k == nzb_w_inner(j,i)+1. |
---|
[1221] | 1469 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 1 ) |
---|
[861] | 1470 | flag_set = .TRUE. |
---|
| 1471 | ELSEIF ( k == nzb_w_inner(j,i) + 2 .OR. k == nzt - 1 ) THEN |
---|
[1221] | 1472 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 2 ) |
---|
[861] | 1473 | flag_set = .TRUE. |
---|
| 1474 | ELSEIF ( k > nzb_w_inner(j,i) .AND. .NOT. flag_set ) THEN |
---|
[1221] | 1475 | wall_flags_00(k,j,i) = IBSET( wall_flags_00(k,j,i), 3 ) |
---|
[861] | 1476 | ENDIF |
---|
| 1477 | |
---|
| 1478 | ENDDO |
---|
| 1479 | ENDDO |
---|
| 1480 | ENDDO |
---|
| 1481 | |
---|
| 1482 | ENDIF |
---|
| 1483 | |
---|
| 1484 | ! |
---|
[1] | 1485 | !-- In case of topography: limit near-wall mixing length l_wall further: |
---|
| 1486 | !-- Go through all points of the subdomain one by one and look for the closest |
---|
| 1487 | !-- surface |
---|
| 1488 | IF ( TRIM(topography) /= 'flat' ) THEN |
---|
| 1489 | DO i = nxl, nxr |
---|
| 1490 | DO j = nys, nyn |
---|
| 1491 | |
---|
| 1492 | nzb_si = nzb_s_inner(j,i) |
---|
| 1493 | vi = vertical_influence(nzb_si) |
---|
| 1494 | |
---|
| 1495 | IF ( wall_n(j,i) > 0 ) THEN |
---|
| 1496 | ! |
---|
| 1497 | !-- North wall (y distance) |
---|
| 1498 | DO k = wall_n(j,i), nzb_si |
---|
[1353] | 1499 | l_wall(k,j+1,i) = MIN( l_wall(k,j+1,i), 0.5_wp * dy ) |
---|
[1] | 1500 | ENDDO |
---|
| 1501 | ! |
---|
| 1502 | !-- Above North wall (yz distance) |
---|
| 1503 | DO k = nzb_si + 1, nzb_si + vi |
---|
[1353] | 1504 | l_wall(k,j+1,i) = MIN( l_wall(k,j+1,i), & |
---|
| 1505 | SQRT( 0.25_wp * dy**2 + & |
---|
[1] | 1506 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
| 1507 | ENDDO |
---|
| 1508 | ! |
---|
| 1509 | !-- Northleft corner (xy distance) |
---|
| 1510 | IF ( corner_nl(j,i) > 0 ) THEN |
---|
| 1511 | DO k = corner_nl(j,i), nzb_si |
---|
| 1512 | l_wall(k,j+1,i-1) = MIN( l_wall(k,j+1,i-1), & |
---|
[1353] | 1513 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
[1] | 1514 | ENDDO |
---|
| 1515 | ! |
---|
| 1516 | !-- Above Northleft corner (xyz distance) |
---|
| 1517 | DO k = nzb_si + 1, nzb_si + vi |
---|
[1353] | 1518 | l_wall(k,j+1,i-1) = MIN( l_wall(k,j+1,i-1), & |
---|
| 1519 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
| 1520 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
[1] | 1521 | ENDDO |
---|
| 1522 | ENDIF |
---|
| 1523 | ! |
---|
| 1524 | !-- Northright corner (xy distance) |
---|
| 1525 | IF ( corner_nr(j,i) > 0 ) THEN |
---|
| 1526 | DO k = corner_nr(j,i), nzb_si |
---|
[1353] | 1527 | l_wall(k,j+1,i+1) = MIN( l_wall(k,j+1,i+1), & |
---|
| 1528 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
[1] | 1529 | ENDDO |
---|
| 1530 | ! |
---|
| 1531 | !-- Above northright corner (xyz distance) |
---|
| 1532 | DO k = nzb_si + 1, nzb_si + vi |
---|
[1353] | 1533 | l_wall(k,j+1,i+1) = MIN( l_wall(k,j+1,i+1), & |
---|
| 1534 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
| 1535 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
[1] | 1536 | ENDDO |
---|
| 1537 | ENDIF |
---|
| 1538 | ENDIF |
---|
| 1539 | |
---|
| 1540 | IF ( wall_s(j,i) > 0 ) THEN |
---|
| 1541 | ! |
---|
| 1542 | !-- South wall (y distance) |
---|
| 1543 | DO k = wall_s(j,i), nzb_si |
---|
[1353] | 1544 | l_wall(k,j-1,i) = MIN( l_wall(k,j-1,i), 0.5_wp * dy ) |
---|
[1] | 1545 | ENDDO |
---|
| 1546 | ! |
---|
| 1547 | !-- Above south wall (yz distance) |
---|
[1353] | 1548 | DO k = nzb_si + 1, nzb_si + vi |
---|
| 1549 | l_wall(k,j-1,i) = MIN( l_wall(k,j-1,i), & |
---|
| 1550 | SQRT( 0.25_wp * dy**2 + & |
---|
[1] | 1551 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
| 1552 | ENDDO |
---|
| 1553 | ! |
---|
| 1554 | !-- Southleft corner (xy distance) |
---|
| 1555 | IF ( corner_sl(j,i) > 0 ) THEN |
---|
| 1556 | DO k = corner_sl(j,i), nzb_si |
---|
[1353] | 1557 | l_wall(k,j-1,i-1) = MIN( l_wall(k,j-1,i-1), & |
---|
| 1558 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
[1] | 1559 | ENDDO |
---|
| 1560 | ! |
---|
| 1561 | !-- Above southleft corner (xyz distance) |
---|
| 1562 | DO k = nzb_si + 1, nzb_si + vi |
---|
[1353] | 1563 | l_wall(k,j-1,i-1) = MIN( l_wall(k,j-1,i-1), & |
---|
| 1564 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
| 1565 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
[1] | 1566 | ENDDO |
---|
| 1567 | ENDIF |
---|
| 1568 | ! |
---|
| 1569 | !-- Southright corner (xy distance) |
---|
| 1570 | IF ( corner_sr(j,i) > 0 ) THEN |
---|
| 1571 | DO k = corner_sr(j,i), nzb_si |
---|
[1353] | 1572 | l_wall(k,j-1,i+1) = MIN( l_wall(k,j-1,i+1), & |
---|
| 1573 | 0.5_wp * SQRT( dx**2 + dy**2 ) ) |
---|
[1] | 1574 | ENDDO |
---|
| 1575 | ! |
---|
| 1576 | !-- Above southright corner (xyz distance) |
---|
| 1577 | DO k = nzb_si + 1, nzb_si + vi |
---|
[1353] | 1578 | l_wall(k,j-1,i+1) = MIN( l_wall(k,j-1,i+1), & |
---|
| 1579 | SQRT( 0.25_wp * (dx**2 + dy**2) + & |
---|
| 1580 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
[1] | 1581 | ENDDO |
---|
| 1582 | ENDIF |
---|
| 1583 | |
---|
| 1584 | ENDIF |
---|
| 1585 | |
---|
| 1586 | IF ( wall_l(j,i) > 0 ) THEN |
---|
| 1587 | ! |
---|
| 1588 | !-- Left wall (x distance) |
---|
| 1589 | DO k = wall_l(j,i), nzb_si |
---|
[1353] | 1590 | l_wall(k,j,i-1) = MIN( l_wall(k,j,i-1), 0.5_wp * dx ) |
---|
[1] | 1591 | ENDDO |
---|
| 1592 | ! |
---|
| 1593 | !-- Above left wall (xz distance) |
---|
| 1594 | DO k = nzb_si + 1, nzb_si + vi |
---|
[1353] | 1595 | l_wall(k,j,i-1) = MIN( l_wall(k,j,i-1), & |
---|
| 1596 | SQRT( 0.25_wp * dx**2 + & |
---|
| 1597 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
[1] | 1598 | ENDDO |
---|
| 1599 | ENDIF |
---|
| 1600 | |
---|
| 1601 | IF ( wall_r(j,i) > 0 ) THEN |
---|
| 1602 | ! |
---|
| 1603 | !-- Right wall (x distance) |
---|
| 1604 | DO k = wall_r(j,i), nzb_si |
---|
[1353] | 1605 | l_wall(k,j,i+1) = MIN( l_wall(k,j,i+1), 0.5_wp * dx ) |
---|
[1] | 1606 | ENDDO |
---|
| 1607 | ! |
---|
| 1608 | !-- Above right wall (xz distance) |
---|
| 1609 | DO k = nzb_si + 1, nzb_si + vi |
---|
[1353] | 1610 | l_wall(k,j,i+1) = MIN( l_wall(k,j,i+1), & |
---|
| 1611 | SQRT( 0.25_wp * dx**2 + & |
---|
[1] | 1612 | ( zu(k) - zw(nzb_si) )**2 ) ) |
---|
| 1613 | ENDDO |
---|
| 1614 | |
---|
| 1615 | ENDIF |
---|
| 1616 | |
---|
| 1617 | ENDDO |
---|
| 1618 | ENDDO |
---|
| 1619 | |
---|
| 1620 | ENDIF |
---|
| 1621 | |
---|
| 1622 | ! |
---|
| 1623 | !-- Multiplication with wall_adjustment_factor |
---|
| 1624 | l_wall = wall_adjustment_factor * l_wall |
---|
| 1625 | |
---|
| 1626 | ! |
---|
[709] | 1627 | !-- Set lateral boundary conditions for l_wall |
---|
[667] | 1628 | CALL exchange_horiz( l_wall, nbgp ) |
---|
| 1629 | |
---|
[1] | 1630 | DEALLOCATE( corner_nl, corner_nr, corner_sl, corner_sr, nzb_local, & |
---|
| 1631 | nzb_tmp, vertical_influence, wall_l, wall_n, wall_r, wall_s ) |
---|
| 1632 | |
---|
[807] | 1633 | #endif |
---|
[1] | 1634 | |
---|
| 1635 | END SUBROUTINE init_grid |
---|