[1873] | 1 | !> @file diffusion_v.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 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 | ! |
---|
[2718] | 17 | ! Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1341] | 22 | ! |
---|
[2233] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: diffusion_v.f90 3547 2018-11-21 13:21:24Z suehring $ |
---|
[3547] | 27 | ! variables documented |
---|
| 28 | ! |
---|
| 29 | ! 3241 2018-09-12 15:02:00Z raasch |
---|
[3241] | 30 | ! unused variables removed |
---|
| 31 | ! |
---|
| 32 | ! 2718 2018-01-02 08:49:38Z maronga |
---|
[2716] | 33 | ! Corrected "Former revisions" section |
---|
| 34 | ! |
---|
| 35 | ! 2696 2017-12-14 17:12:51Z kanani |
---|
| 36 | ! Change in file header (GPL part) |
---|
| 37 | ! |
---|
| 38 | ! 2638 2017-11-23 12:44:23Z raasch |
---|
[2638] | 39 | ! bugfix for constant top momentumflux |
---|
| 40 | ! |
---|
| 41 | ! 2233 2017-05-30 18:08:54Z suehring |
---|
[1321] | 42 | ! |
---|
[2233] | 43 | ! 2232 2017-05-30 17:47:52Z suehring |
---|
| 44 | ! Adjustments to new topography and surface concept |
---|
| 45 | ! |
---|
[2119] | 46 | ! 2118 2017-01-17 16:38:49Z raasch |
---|
| 47 | ! OpenACC version of subroutine removed |
---|
| 48 | ! |
---|
[2038] | 49 | ! 2037 2016-10-26 11:15:40Z knoop |
---|
| 50 | ! Anelastic approximation implemented |
---|
| 51 | ! |
---|
[2001] | 52 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 53 | ! Forced header and separation lines into 80 columns |
---|
| 54 | ! |
---|
[1874] | 55 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
| 56 | ! Module renamed (removed _mod) |
---|
| 57 | ! |
---|
[1851] | 58 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 59 | ! Module renamed |
---|
| 60 | ! |
---|
[1741] | 61 | ! 1740 2016-01-13 08:19:40Z raasch |
---|
| 62 | ! unnecessary calculations of kmzm and kmzp in wall bounded parts removed |
---|
| 63 | ! |
---|
[1683] | 64 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 65 | ! Code annotations made doxygen readable |
---|
| 66 | ! |
---|
[1341] | 67 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 68 | ! REAL constants defined as wp-kind |
---|
| 69 | ! |
---|
[1321] | 70 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 71 | ! ONLY-attribute added to USE-statements, |
---|
| 72 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 73 | ! kinds are defined in new module kinds, |
---|
| 74 | ! revision history before 2012 removed, |
---|
| 75 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 76 | ! all variable declaration statements |
---|
[1321] | 77 | ! |
---|
[1258] | 78 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
| 79 | ! openacc loop and loop vector clauses removed, declare create moved after |
---|
| 80 | ! the FORTRAN declaration statement |
---|
| 81 | ! |
---|
[1132] | 82 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
| 83 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
| 84 | ! j_north |
---|
| 85 | ! |
---|
[1037] | 86 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 87 | ! code put under GPL (PALM 3.9) |
---|
| 88 | ! |
---|
[1017] | 89 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 90 | ! accelerator version (*_acc) added |
---|
| 91 | ! |
---|
[1002] | 92 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 93 | ! arrays comunicated by module instead of parameter list |
---|
| 94 | ! |
---|
[979] | 95 | ! 978 2012-08-09 08:28:32Z fricke |
---|
| 96 | ! outflow damping layer removed |
---|
| 97 | ! kmxm_x/_y and kmxp_x/_y change to kmxm and kmxp |
---|
| 98 | ! |
---|
[1] | 99 | ! Revision 1.1 1997/09/12 06:24:01 raasch |
---|
| 100 | ! Initial revision |
---|
| 101 | ! |
---|
| 102 | ! |
---|
| 103 | ! Description: |
---|
| 104 | ! ------------ |
---|
[1682] | 105 | !> Diffusion term of the v-component |
---|
[1] | 106 | !------------------------------------------------------------------------------! |
---|
[1682] | 107 | MODULE diffusion_v_mod |
---|
| 108 | |
---|
[1] | 109 | |
---|
| 110 | PRIVATE |
---|
[2118] | 111 | PUBLIC diffusion_v |
---|
[1] | 112 | |
---|
| 113 | INTERFACE diffusion_v |
---|
| 114 | MODULE PROCEDURE diffusion_v |
---|
| 115 | MODULE PROCEDURE diffusion_v_ij |
---|
| 116 | END INTERFACE diffusion_v |
---|
| 117 | |
---|
| 118 | CONTAINS |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | !------------------------------------------------------------------------------! |
---|
[1682] | 122 | ! Description: |
---|
| 123 | ! ------------ |
---|
| 124 | !> Call for all grid points |
---|
[1] | 125 | !------------------------------------------------------------------------------! |
---|
[1001] | 126 | SUBROUTINE diffusion_v |
---|
[1] | 127 | |
---|
[1320] | 128 | USE arrays_3d, & |
---|
[2232] | 129 | ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw |
---|
[1320] | 130 | |
---|
| 131 | USE control_parameters, & |
---|
[2232] | 132 | ONLY: constant_top_momentumflux, use_surface_fluxes, & |
---|
[1320] | 133 | use_top_fluxes |
---|
| 134 | |
---|
| 135 | USE grid_variables, & |
---|
[2232] | 136 | ONLY: ddx, ddy, ddy2 |
---|
[1320] | 137 | |
---|
| 138 | USE indices, & |
---|
[3241] | 139 | ONLY: nxl, nxr, nyn, nysv, nzb, nzt, wall_flags_0 |
---|
[1320] | 140 | |
---|
| 141 | USE kinds |
---|
[1] | 142 | |
---|
[2232] | 143 | USE surface_mod, & |
---|
| 144 | ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & |
---|
| 145 | surf_usm_v |
---|
| 146 | |
---|
[1] | 147 | IMPLICIT NONE |
---|
| 148 | |
---|
[2232] | 149 | INTEGER(iwp) :: i !< running index x direction |
---|
| 150 | INTEGER(iwp) :: j !< running index y direction |
---|
| 151 | INTEGER(iwp) :: k !< running index z direction |
---|
| 152 | INTEGER(iwp) :: l !< running index of surface type, south- or north-facing wall |
---|
| 153 | INTEGER(iwp) :: m !< running index surface elements |
---|
| 154 | INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint |
---|
| 155 | INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint |
---|
[1001] | 156 | |
---|
[2232] | 157 | REAL(wp) :: flag !< flag to mask topography grid points |
---|
[3547] | 158 | REAL(wp) :: kmxm !< diffusion coefficient on leftward side of the v-gridbox - interpolated onto xu-yv grid |
---|
| 159 | REAL(wp) :: kmxp !< diffusion coefficient on rightward side of the v-gridbox - interpolated onto xu-yv grid |
---|
| 160 | REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto yv-zw grid |
---|
| 161 | REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto yv-zw grid |
---|
[2232] | 162 | REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface |
---|
| 163 | REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point |
---|
| 164 | REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point |
---|
| 165 | REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface |
---|
[1] | 166 | |
---|
| 167 | DO i = nxl, nxr |
---|
[106] | 168 | DO j = nysv, nyn |
---|
[1] | 169 | ! |
---|
| 170 | !-- Compute horizontal diffusion |
---|
[2232] | 171 | DO k = nzb+1, nzt |
---|
| 172 | |
---|
[1] | 173 | ! |
---|
[2232] | 174 | !-- Predetermine flag to mask topography and wall-bounded grid points. |
---|
| 175 | !-- It is sufficient to masked only east- and west-facing surfaces, which |
---|
| 176 | !-- need special treatment for the v-component. |
---|
| 177 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
| 178 | mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i+1), 2 ) ) |
---|
| 179 | mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i-1), 2 ) ) |
---|
| 180 | ! |
---|
[1] | 181 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[2232] | 182 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
| 183 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
[1] | 184 | |
---|
[2232] | 185 | tend(k,j,i) = tend(k,j,i) + ( & |
---|
| 186 | mask_east * kmxp * ( & |
---|
| 187 | ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
| 188 | + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
| 189 | ) & |
---|
| 190 | - mask_west * kmxm * ( & |
---|
| 191 | ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 192 | + ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 193 | ) & |
---|
| 194 | ) * ddx * flag & |
---|
| 195 | + 2.0_wp * ( & |
---|
| 196 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
| 197 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
| 198 | ) * ddy2 * flag |
---|
| 199 | |
---|
[1] | 200 | ENDDO |
---|
| 201 | |
---|
| 202 | ! |
---|
[2232] | 203 | !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) |
---|
| 204 | !-- surfaces. Note, in the the flat case, loops won't be entered as |
---|
| 205 | !-- start_index > end_index. Furtermore, note, no vertical natural surfaces |
---|
| 206 | !-- so far. |
---|
| 207 | !-- Default-type surfaces |
---|
| 208 | DO l = 2, 3 |
---|
| 209 | surf_s = surf_def_v(l)%start_index(j,i) |
---|
| 210 | surf_e = surf_def_v(l)%end_index(j,i) |
---|
| 211 | DO m = surf_s, surf_e |
---|
| 212 | k = surf_def_v(l)%k(m) |
---|
| 213 | tend(k,j,i) = tend(k,j,i) + & |
---|
| 214 | surf_def_v(l)%mom_flux_uv(m) * ddx |
---|
| 215 | ENDDO |
---|
| 216 | ENDDO |
---|
[1] | 217 | ! |
---|
[2232] | 218 | !-- Natural-type surfaces |
---|
| 219 | DO l = 2, 3 |
---|
| 220 | surf_s = surf_lsm_v(l)%start_index(j,i) |
---|
| 221 | surf_e = surf_lsm_v(l)%end_index(j,i) |
---|
| 222 | DO m = surf_s, surf_e |
---|
| 223 | k = surf_lsm_v(l)%k(m) |
---|
| 224 | tend(k,j,i) = tend(k,j,i) + & |
---|
| 225 | surf_lsm_v(l)%mom_flux_uv(m) * ddx |
---|
| 226 | ENDDO |
---|
| 227 | ENDDO |
---|
[1] | 228 | ! |
---|
[2232] | 229 | !-- Urban-type surfaces |
---|
| 230 | DO l = 2, 3 |
---|
| 231 | surf_s = surf_usm_v(l)%start_index(j,i) |
---|
| 232 | surf_e = surf_usm_v(l)%end_index(j,i) |
---|
| 233 | DO m = surf_s, surf_e |
---|
| 234 | k = surf_usm_v(l)%k(m) |
---|
| 235 | tend(k,j,i) = tend(k,j,i) + & |
---|
| 236 | surf_usm_v(l)%mom_flux_uv(m) * ddx |
---|
| 237 | ENDDO |
---|
| 238 | ENDDO |
---|
| 239 | ! |
---|
| 240 | !-- Compute vertical diffusion. In case of simulating a surface layer, |
---|
| 241 | !-- respective grid diffusive fluxes are masked (flag 10) within this |
---|
| 242 | !-- loop, and added further below, else, simple gradient approach is |
---|
| 243 | !-- applied. Model top is also mask if top-momentum flux is given. |
---|
| 244 | DO k = nzb+1, nzt |
---|
| 245 | ! |
---|
| 246 | !-- Determine flags to mask topography below and above. Flag 2 is |
---|
| 247 | !-- used to mask topography in general, while flag 8 implies also |
---|
| 248 | !-- information about use_surface_fluxes. Flag 9 is used to control |
---|
| 249 | !-- momentum flux at model top. |
---|
| 250 | mask_bottom = MERGE( 1.0_wp, 0.0_wp, & |
---|
| 251 | BTEST( wall_flags_0(k-1,j,i), 8 ) ) |
---|
| 252 | mask_top = MERGE( 1.0_wp, 0.0_wp, & |
---|
| 253 | BTEST( wall_flags_0(k+1,j,i), 8 ) ) * & |
---|
| 254 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 255 | BTEST( wall_flags_0(k+1,j,i), 9 ) ) |
---|
| 256 | flag = MERGE( 1.0_wp, 0.0_wp, & |
---|
| 257 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
| 258 | ! |
---|
[1] | 259 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 260 | kmzp = 0.25_wp * & |
---|
[1] | 261 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
[1340] | 262 | kmzm = 0.25_wp * & |
---|
[1] | 263 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
| 264 | |
---|
[1320] | 265 | tend(k,j,i) = tend(k,j,i) & |
---|
| 266 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 267 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
[2232] | 268 | & ) * rho_air_zw(k) * mask_top & |
---|
[1320] | 269 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
| 270 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
[2232] | 271 | & ) * rho_air_zw(k-1) * mask_bottom & |
---|
| 272 | & ) * ddzw(k) * drho_air(k) * flag |
---|
[1] | 273 | ENDDO |
---|
| 274 | |
---|
| 275 | ! |
---|
| 276 | !-- Vertical diffusion at the first grid point above the surface, |
---|
| 277 | !-- if the momentum flux at the bottom is given by the Prandtl law |
---|
| 278 | !-- or if it is prescribed by the user. |
---|
| 279 | !-- Difference quotient of the momentum flux is not formed over |
---|
| 280 | !-- half of the grid spacing (2.0*ddzw(k)) any more, since the |
---|
[1320] | 281 | !-- comparison with other (LES) models showed that the values of |
---|
[1] | 282 | !-- the momentum flux becomes too large in this case. |
---|
| 283 | IF ( use_surface_fluxes ) THEN |
---|
| 284 | ! |
---|
[2232] | 285 | !-- Default-type surfaces, upward-facing |
---|
| 286 | surf_s = surf_def_h(0)%start_index(j,i) |
---|
| 287 | surf_e = surf_def_h(0)%end_index(j,i) |
---|
| 288 | DO m = surf_s, surf_e |
---|
| 289 | k = surf_def_h(0)%k(m) |
---|
[1] | 290 | |
---|
[2232] | 291 | tend(k,j,i) = tend(k,j,i) & |
---|
| 292 | + ( - ( - surf_def_h(0)%vsws(m) ) & |
---|
| 293 | ) * ddzw(k) * drho_air(k) |
---|
| 294 | ENDDO |
---|
| 295 | ! |
---|
| 296 | !-- Default-type surfaces, dowward-facing |
---|
| 297 | surf_s = surf_def_h(1)%start_index(j,i) |
---|
| 298 | surf_e = surf_def_h(1)%end_index(j,i) |
---|
| 299 | DO m = surf_s, surf_e |
---|
| 300 | k = surf_def_h(1)%k(m) |
---|
[1] | 301 | |
---|
[2232] | 302 | tend(k,j,i) = tend(k,j,i) & |
---|
| 303 | + ( - surf_def_h(1)%vsws(m) & |
---|
| 304 | ) * ddzw(k) * drho_air(k) |
---|
| 305 | ENDDO |
---|
[102] | 306 | ! |
---|
[2232] | 307 | !-- Natural-type surfaces, upward-facing |
---|
| 308 | surf_s = surf_lsm_h%start_index(j,i) |
---|
| 309 | surf_e = surf_lsm_h%end_index(j,i) |
---|
| 310 | DO m = surf_s, surf_e |
---|
| 311 | k = surf_lsm_h%k(m) |
---|
| 312 | |
---|
| 313 | tend(k,j,i) = tend(k,j,i) & |
---|
| 314 | + ( - ( - surf_lsm_h%vsws(m) ) & |
---|
| 315 | ) * ddzw(k) * drho_air(k) |
---|
| 316 | |
---|
| 317 | ENDDO |
---|
[102] | 318 | ! |
---|
[2232] | 319 | !-- Urban-type surfaces, upward-facing |
---|
| 320 | surf_s = surf_usm_h%start_index(j,i) |
---|
| 321 | surf_e = surf_usm_h%end_index(j,i) |
---|
| 322 | DO m = surf_s, surf_e |
---|
| 323 | k = surf_usm_h%k(m) |
---|
[102] | 324 | |
---|
[2232] | 325 | tend(k,j,i) = tend(k,j,i) & |
---|
| 326 | + ( - ( - surf_usm_h%vsws(m) ) & |
---|
| 327 | ) * ddzw(k) * drho_air(k) |
---|
| 328 | |
---|
| 329 | ENDDO |
---|
[102] | 330 | ENDIF |
---|
[2232] | 331 | ! |
---|
| 332 | !-- Add momentum flux at model top |
---|
[2638] | 333 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
[2232] | 334 | surf_s = surf_def_h(2)%start_index(j,i) |
---|
| 335 | surf_e = surf_def_h(2)%end_index(j,i) |
---|
| 336 | DO m = surf_s, surf_e |
---|
[102] | 337 | |
---|
[2232] | 338 | k = surf_def_h(2)%k(m) |
---|
| 339 | |
---|
| 340 | tend(k,j,i) = tend(k,j,i) & |
---|
| 341 | + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k) |
---|
| 342 | ENDDO |
---|
| 343 | ENDIF |
---|
| 344 | |
---|
[1] | 345 | ENDDO |
---|
| 346 | ENDDO |
---|
| 347 | |
---|
| 348 | END SUBROUTINE diffusion_v |
---|
| 349 | |
---|
| 350 | |
---|
| 351 | !------------------------------------------------------------------------------! |
---|
[1682] | 352 | ! Description: |
---|
| 353 | ! ------------ |
---|
| 354 | !> Call for grid point i,j |
---|
[1] | 355 | !------------------------------------------------------------------------------! |
---|
[1001] | 356 | SUBROUTINE diffusion_v_ij( i, j ) |
---|
[1] | 357 | |
---|
[1320] | 358 | USE arrays_3d, & |
---|
[2232] | 359 | ONLY: ddzu, ddzw, km, tend, u, v, w, drho_air, rho_air_zw |
---|
[1320] | 360 | |
---|
| 361 | USE control_parameters, & |
---|
[2232] | 362 | ONLY: constant_top_momentumflux, use_surface_fluxes, & |
---|
| 363 | use_top_fluxes |
---|
[1320] | 364 | |
---|
| 365 | USE grid_variables, & |
---|
[2232] | 366 | ONLY: ddx, ddy, ddy2 |
---|
[1320] | 367 | |
---|
| 368 | USE indices, & |
---|
[2232] | 369 | ONLY: nzb, nzt, wall_flags_0 |
---|
[1320] | 370 | |
---|
| 371 | USE kinds |
---|
[1] | 372 | |
---|
[2232] | 373 | USE surface_mod, & |
---|
| 374 | ONLY : surf_def_h, surf_def_v, surf_lsm_h, surf_lsm_v, surf_usm_h, & |
---|
| 375 | surf_usm_v |
---|
| 376 | |
---|
[1] | 377 | IMPLICIT NONE |
---|
| 378 | |
---|
| 379 | |
---|
[2232] | 380 | INTEGER(iwp) :: i !< running index x direction |
---|
| 381 | INTEGER(iwp) :: j !< running index y direction |
---|
| 382 | INTEGER(iwp) :: k !< running index z direction |
---|
| 383 | INTEGER(iwp) :: l !< running index of surface type, south- or north-facing wall |
---|
| 384 | INTEGER(iwp) :: m !< running index surface elements |
---|
| 385 | INTEGER(iwp) :: surf_e !< End index of surface elements at (j,i)-gridpoint |
---|
| 386 | INTEGER(iwp) :: surf_s !< Start index of surface elements at (j,i)-gridpoint |
---|
[1001] | 387 | |
---|
[2232] | 388 | REAL(wp) :: flag !< flag to mask topography grid points |
---|
[3547] | 389 | REAL(wp) :: kmxm !< diffusion coefficient on leftward side of the v-gridbox - interpolated onto xu-yv grid |
---|
| 390 | REAL(wp) :: kmxp !< diffusion coefficient on rightward side of the v-gridbox - interpolated onto xu-yv grid |
---|
| 391 | REAL(wp) :: kmzm !< diffusion coefficient on bottom of the gridbox - interpolated onto xu-zw grid |
---|
| 392 | REAL(wp) :: kmzp !< diffusion coefficient on top of the gridbox - interpolated onto xu-zw grid |
---|
[2232] | 393 | REAL(wp) :: mask_bottom !< flag to mask vertical upward-facing surface |
---|
| 394 | REAL(wp) :: mask_east !< flag to mask vertical surface south of the grid point |
---|
| 395 | REAL(wp) :: mask_west !< flag to mask vertical surface north of the grid point |
---|
| 396 | REAL(wp) :: mask_top !< flag to mask vertical downward-facing surface |
---|
| 397 | |
---|
[1] | 398 | ! |
---|
| 399 | !-- Compute horizontal diffusion |
---|
[2232] | 400 | DO k = nzb+1, nzt |
---|
[1] | 401 | ! |
---|
[2232] | 402 | !-- Predetermine flag to mask topography and wall-bounded grid points. |
---|
| 403 | !-- It is sufficient to masked only east- and west-facing surfaces, which |
---|
| 404 | !-- need special treatment for the v-component. |
---|
| 405 | flag = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
| 406 | mask_east = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i+1), 2 ) ) |
---|
| 407 | mask_west = MERGE( 1.0_wp, 0.0_wp, BTEST( wall_flags_0(k,j,i-1), 2 ) ) |
---|
| 408 | ! |
---|
[1] | 409 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 410 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
| 411 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
[1] | 412 | |
---|
[2232] | 413 | tend(k,j,i) = tend(k,j,i) + ( & |
---|
| 414 | mask_east * kmxp * ( & |
---|
| 415 | ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
| 416 | + ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
| 417 | ) & |
---|
| 418 | - mask_west * kmxm * ( & |
---|
| 419 | ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 420 | + ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 421 | ) & |
---|
| 422 | ) * ddx * flag & |
---|
| 423 | + 2.0_wp * ( & |
---|
| 424 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
| 425 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
| 426 | ) * ddy2 * flag |
---|
[1] | 427 | ENDDO |
---|
| 428 | |
---|
| 429 | ! |
---|
[2232] | 430 | !-- Add horizontal momentum flux v'u' at east- (l=2) and west-facing (l=3) |
---|
| 431 | !-- surfaces. Note, in the the flat case, loops won't be entered as |
---|
| 432 | !-- start_index > end_index. Furtermore, note, no vertical natural surfaces |
---|
| 433 | !-- so far. |
---|
| 434 | !-- Default-type surfaces |
---|
| 435 | DO l = 2, 3 |
---|
| 436 | surf_s = surf_def_v(l)%start_index(j,i) |
---|
| 437 | surf_e = surf_def_v(l)%end_index(j,i) |
---|
| 438 | DO m = surf_s, surf_e |
---|
| 439 | k = surf_def_v(l)%k(m) |
---|
| 440 | tend(k,j,i) = tend(k,j,i) + surf_def_v(l)%mom_flux_uv(m) * ddx |
---|
| 441 | ENDDO |
---|
| 442 | ENDDO |
---|
[51] | 443 | ! |
---|
[2232] | 444 | !-- Natural-type surfaces |
---|
| 445 | DO l = 2, 3 |
---|
| 446 | surf_s = surf_lsm_v(l)%start_index(j,i) |
---|
| 447 | surf_e = surf_lsm_v(l)%end_index(j,i) |
---|
| 448 | DO m = surf_s, surf_e |
---|
| 449 | k = surf_lsm_v(l)%k(m) |
---|
| 450 | tend(k,j,i) = tend(k,j,i) + surf_lsm_v(l)%mom_flux_uv(m) * ddx |
---|
| 451 | ENDDO |
---|
| 452 | ENDDO |
---|
[1] | 453 | ! |
---|
[2232] | 454 | !-- Urban-type surfaces |
---|
| 455 | DO l = 2, 3 |
---|
| 456 | surf_s = surf_usm_v(l)%start_index(j,i) |
---|
| 457 | surf_e = surf_usm_v(l)%end_index(j,i) |
---|
| 458 | DO m = surf_s, surf_e |
---|
| 459 | k = surf_usm_v(l)%k(m) |
---|
| 460 | tend(k,j,i) = tend(k,j,i) + surf_usm_v(l)%mom_flux_uv(m) * ddx |
---|
| 461 | ENDDO |
---|
| 462 | ENDDO |
---|
[1] | 463 | ! |
---|
[2232] | 464 | !-- Compute vertical diffusion. In case of simulating a surface layer, |
---|
| 465 | !-- respective grid diffusive fluxes are masked (flag 8) within this |
---|
| 466 | !-- loop, and added further below, else, simple gradient approach is |
---|
| 467 | !-- applied. Model top is also mask if top-momentum flux is given. |
---|
| 468 | DO k = nzb+1, nzt |
---|
| 469 | ! |
---|
| 470 | !-- Determine flags to mask topography below and above. Flag 2 is |
---|
| 471 | !-- used to mask topography in general, while flag 10 implies also |
---|
| 472 | !-- information about use_surface_fluxes. Flag 9 is used to control |
---|
| 473 | !-- momentum flux at model top. |
---|
| 474 | mask_bottom = MERGE( 1.0_wp, 0.0_wp, & |
---|
| 475 | BTEST( wall_flags_0(k-1,j,i), 8 ) ) |
---|
| 476 | mask_top = MERGE( 1.0_wp, 0.0_wp, & |
---|
| 477 | BTEST( wall_flags_0(k+1,j,i), 8 ) ) * & |
---|
| 478 | MERGE( 1.0_wp, 0.0_wp, & |
---|
| 479 | BTEST( wall_flags_0(k+1,j,i), 9 ) ) |
---|
| 480 | flag = MERGE( 1.0_wp, 0.0_wp, & |
---|
| 481 | BTEST( wall_flags_0(k,j,i), 2 ) ) |
---|
| 482 | ! |
---|
[1] | 483 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 484 | kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
| 485 | kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
[1] | 486 | |
---|
[1320] | 487 | tend(k,j,i) = tend(k,j,i) & |
---|
| 488 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 489 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
[2232] | 490 | & ) * rho_air_zw(k) * mask_top & |
---|
[1320] | 491 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
| 492 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
[2232] | 493 | & ) * rho_air_zw(k-1) * mask_bottom & |
---|
| 494 | & ) * ddzw(k) * drho_air(k) * flag |
---|
[1] | 495 | ENDDO |
---|
| 496 | |
---|
| 497 | ! |
---|
| 498 | !-- Vertical diffusion at the first grid point above the surface, if the |
---|
| 499 | !-- momentum flux at the bottom is given by the Prandtl law or if it is |
---|
| 500 | !-- prescribed by the user. |
---|
| 501 | !-- Difference quotient of the momentum flux is not formed over half of |
---|
| 502 | !-- the grid spacing (2.0*ddzw(k)) any more, since the comparison with |
---|
[1320] | 503 | !-- other (LES) models showed that the values of the momentum flux becomes |
---|
[1] | 504 | !-- too large in this case. |
---|
| 505 | IF ( use_surface_fluxes ) THEN |
---|
| 506 | ! |
---|
[2232] | 507 | !-- Default-type surfaces, upward-facing |
---|
| 508 | surf_s = surf_def_h(0)%start_index(j,i) |
---|
| 509 | surf_e = surf_def_h(0)%end_index(j,i) |
---|
| 510 | DO m = surf_s, surf_e |
---|
| 511 | k = surf_def_h(0)%k(m) |
---|
[1] | 512 | |
---|
[2232] | 513 | tend(k,j,i) = tend(k,j,i) & |
---|
| 514 | + ( - ( - surf_def_h(0)%vsws(m) ) & |
---|
| 515 | ) * ddzw(k) * drho_air(k) |
---|
| 516 | ENDDO |
---|
| 517 | ! |
---|
| 518 | !-- Default-type surfaces, dowward-facing |
---|
| 519 | surf_s = surf_def_h(1)%start_index(j,i) |
---|
| 520 | surf_e = surf_def_h(1)%end_index(j,i) |
---|
| 521 | DO m = surf_s, surf_e |
---|
| 522 | k = surf_def_h(1)%k(m) |
---|
[1] | 523 | |
---|
[2232] | 524 | tend(k,j,i) = tend(k,j,i) & |
---|
| 525 | + ( - surf_def_h(1)%vsws(m) & |
---|
| 526 | ) * ddzw(k) * drho_air(k) |
---|
| 527 | ENDDO |
---|
[102] | 528 | ! |
---|
[2232] | 529 | !-- Natural-type surfaces, upward-facing |
---|
| 530 | surf_s = surf_lsm_h%start_index(j,i) |
---|
| 531 | surf_e = surf_lsm_h%end_index(j,i) |
---|
| 532 | DO m = surf_s, surf_e |
---|
| 533 | k = surf_lsm_h%k(m) |
---|
| 534 | |
---|
| 535 | tend(k,j,i) = tend(k,j,i) & |
---|
| 536 | + ( - ( - surf_lsm_h%vsws(m) ) & |
---|
| 537 | ) * ddzw(k) * drho_air(k) |
---|
| 538 | |
---|
| 539 | ENDDO |
---|
[102] | 540 | ! |
---|
[2232] | 541 | !-- Urban-type surfaces, upward-facing |
---|
| 542 | surf_s = surf_usm_h%start_index(j,i) |
---|
| 543 | surf_e = surf_usm_h%end_index(j,i) |
---|
| 544 | DO m = surf_s, surf_e |
---|
| 545 | k = surf_usm_h%k(m) |
---|
[102] | 546 | |
---|
[2232] | 547 | tend(k,j,i) = tend(k,j,i) & |
---|
| 548 | + ( - ( - surf_usm_h%vsws(m) ) & |
---|
| 549 | ) * ddzw(k) * drho_air(k) |
---|
| 550 | |
---|
| 551 | ENDDO |
---|
[102] | 552 | ENDIF |
---|
[2232] | 553 | ! |
---|
| 554 | !-- Add momentum flux at model top |
---|
[2638] | 555 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
[2232] | 556 | surf_s = surf_def_h(2)%start_index(j,i) |
---|
| 557 | surf_e = surf_def_h(2)%end_index(j,i) |
---|
| 558 | DO m = surf_s, surf_e |
---|
[102] | 559 | |
---|
[2232] | 560 | k = surf_def_h(2)%k(m) |
---|
| 561 | |
---|
| 562 | tend(k,j,i) = tend(k,j,i) & |
---|
| 563 | + ( - surf_def_h(2)%vsws(m) ) * ddzw(k) * drho_air(k) |
---|
| 564 | ENDDO |
---|
| 565 | ENDIF |
---|
| 566 | |
---|
[1] | 567 | END SUBROUTINE diffusion_v_ij |
---|
| 568 | |
---|
[1321] | 569 | END MODULE diffusion_v_mod |
---|