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