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