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