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