[1873] | 1 | !> @file diffusion_u.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 | ! |
---|
[1818] | 17 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[1] | 21 | ! ----------------- |
---|
[1341] | 22 | ! |
---|
[2001] | 23 | ! |
---|
[1321] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: diffusion_u.f90 2001 2016-08-20 18:41:22Z kanani $ |
---|
| 27 | ! |
---|
[2001] | 28 | ! 2000 2016-08-20 18:09:15Z knoop |
---|
| 29 | ! Forced header and separation lines into 80 columns |
---|
| 30 | ! |
---|
[1874] | 31 | ! 1873 2016-04-18 14:50:06Z maronga |
---|
| 32 | ! Module renamed (removed _mod) |
---|
| 33 | ! |
---|
| 34 | ! |
---|
[1851] | 35 | ! 1850 2016-04-08 13:29:27Z maronga |
---|
| 36 | ! Module renamed |
---|
| 37 | ! |
---|
| 38 | ! |
---|
[1741] | 39 | ! 1740 2016-01-13 08:19:40Z raasch |
---|
| 40 | ! unnecessary calculations of kmzm and kmzp in wall bounded parts removed |
---|
| 41 | ! |
---|
[1692] | 42 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
| 43 | ! Formatting corrections. |
---|
| 44 | ! |
---|
[1683] | 45 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 46 | ! Code annotations made doxygen readable |
---|
| 47 | ! |
---|
[1341] | 48 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 49 | ! REAL constants defined as wp-kind |
---|
| 50 | ! |
---|
[1321] | 51 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 52 | ! ONLY-attribute added to USE-statements, |
---|
| 53 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 54 | ! kinds are defined in new module kinds, |
---|
| 55 | ! revision history before 2012 removed, |
---|
| 56 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 57 | ! all variable declaration statements |
---|
[1321] | 58 | ! |
---|
[1258] | 59 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
| 60 | ! openacc loop and loop vector clauses removed, declare create moved after |
---|
| 61 | ! the FORTRAN declaration statement |
---|
| 62 | ! |
---|
[1132] | 63 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
| 64 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
| 65 | ! j_north |
---|
| 66 | ! |
---|
[1037] | 67 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 68 | ! code put under GPL (PALM 3.9) |
---|
| 69 | ! |
---|
[1017] | 70 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 71 | ! accelerator version (*_acc) added |
---|
| 72 | ! |
---|
[1002] | 73 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 74 | ! arrays comunicated by module instead of parameter list |
---|
| 75 | ! |
---|
[979] | 76 | ! 978 2012-08-09 08:28:32Z fricke |
---|
| 77 | ! outflow damping layer removed |
---|
| 78 | ! kmym_x/_y and kmyp_x/_y change to kmym and kmyp |
---|
| 79 | ! |
---|
[1] | 80 | ! Revision 1.1 1997/09/12 06:23:51 raasch |
---|
| 81 | ! Initial revision |
---|
| 82 | ! |
---|
| 83 | ! |
---|
| 84 | ! Description: |
---|
| 85 | ! ------------ |
---|
[1682] | 86 | !> Diffusion term of the u-component |
---|
| 87 | !> @todo additional damping (needed for non-cyclic bc) causes bad vectorization |
---|
| 88 | !> and slows down the speed on NEC about 5-10% |
---|
[1] | 89 | !------------------------------------------------------------------------------! |
---|
[1682] | 90 | MODULE diffusion_u_mod |
---|
| 91 | |
---|
[1] | 92 | |
---|
[56] | 93 | USE wall_fluxes_mod |
---|
| 94 | |
---|
[1] | 95 | PRIVATE |
---|
[1015] | 96 | PUBLIC diffusion_u, diffusion_u_acc |
---|
[1] | 97 | |
---|
| 98 | INTERFACE diffusion_u |
---|
| 99 | MODULE PROCEDURE diffusion_u |
---|
| 100 | MODULE PROCEDURE diffusion_u_ij |
---|
| 101 | END INTERFACE diffusion_u |
---|
| 102 | |
---|
[1015] | 103 | INTERFACE diffusion_u_acc |
---|
| 104 | MODULE PROCEDURE diffusion_u_acc |
---|
| 105 | END INTERFACE diffusion_u_acc |
---|
| 106 | |
---|
[1] | 107 | CONTAINS |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | !------------------------------------------------------------------------------! |
---|
[1682] | 111 | ! Description: |
---|
| 112 | ! ------------ |
---|
| 113 | !> Call for all grid points |
---|
[1] | 114 | !------------------------------------------------------------------------------! |
---|
[1001] | 115 | SUBROUTINE diffusion_u |
---|
[1] | 116 | |
---|
[1320] | 117 | USE arrays_3d, & |
---|
| 118 | ONLY: ddzu, ddzw, km, tend, u, usws, uswst, v, w |
---|
| 119 | |
---|
| 120 | USE control_parameters, & |
---|
| 121 | ONLY: constant_top_momentumflux, topography, use_surface_fluxes, & |
---|
| 122 | use_top_fluxes |
---|
| 123 | |
---|
| 124 | USE grid_variables, & |
---|
| 125 | ONLY: ddx, ddx2, ddy, fym, fyp, wall_u |
---|
| 126 | |
---|
| 127 | USE indices, & |
---|
| 128 | ONLY: nxl, nxlu, nxr, nyn, nys, nzb, nzb_diff_u, nzb_u_inner, & |
---|
| 129 | nzb_u_outer, nzt, nzt_diff |
---|
| 130 | |
---|
| 131 | USE kinds |
---|
[1] | 132 | |
---|
| 133 | IMPLICIT NONE |
---|
| 134 | |
---|
[1682] | 135 | INTEGER(iwp) :: i !< |
---|
| 136 | INTEGER(iwp) :: j !< |
---|
| 137 | INTEGER(iwp) :: k !< |
---|
| 138 | REAL(wp) :: kmym !< |
---|
| 139 | REAL(wp) :: kmyp !< |
---|
| 140 | REAL(wp) :: kmzm !< |
---|
| 141 | REAL(wp) :: kmzp !< |
---|
[1001] | 142 | |
---|
[1682] | 143 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: usvs !< |
---|
[1] | 144 | |
---|
[56] | 145 | ! |
---|
| 146 | !-- First calculate horizontal momentum flux u'v' at vertical walls, |
---|
| 147 | !-- if neccessary |
---|
| 148 | IF ( topography /= 'flat' ) THEN |
---|
[1320] | 149 | CALL wall_fluxes( usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, nzb_u_inner, & |
---|
[56] | 150 | nzb_u_outer, wall_u ) |
---|
| 151 | ENDIF |
---|
| 152 | |
---|
[106] | 153 | DO i = nxlu, nxr |
---|
[1001] | 154 | DO j = nys, nyn |
---|
[1] | 155 | ! |
---|
| 156 | !-- Compute horizontal diffusion |
---|
| 157 | DO k = nzb_u_outer(j,i)+1, nzt |
---|
| 158 | ! |
---|
| 159 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 160 | kmyp = 0.25_wp * & |
---|
[978] | 161 | ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) |
---|
[1340] | 162 | kmym = 0.25_wp * & |
---|
[978] | 163 | ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) |
---|
[1] | 164 | |
---|
[1320] | 165 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 166 | & + 2.0_wp * ( & |
---|
[1320] | 167 | & km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & |
---|
| 168 | & - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & |
---|
[1340] | 169 | & ) * ddx2 & |
---|
[1320] | 170 | & + ( kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
| 171 | & + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & |
---|
| 172 | & - kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 173 | & - kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
[1] | 174 | & ) * ddy |
---|
| 175 | ENDDO |
---|
| 176 | |
---|
| 177 | ! |
---|
| 178 | !-- Wall functions at the north and south walls, respectively |
---|
[1340] | 179 | IF ( wall_u(j,i) /= 0.0_wp ) THEN |
---|
[51] | 180 | |
---|
[1] | 181 | DO k = nzb_u_inner(j,i)+1, nzb_u_outer(j,i) |
---|
[1340] | 182 | kmyp = 0.25_wp * & |
---|
[978] | 183 | ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) |
---|
[1340] | 184 | kmym = 0.25_wp * & |
---|
[978] | 185 | ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) |
---|
[1] | 186 | |
---|
| 187 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 188 | + 2.0_wp * ( & |
---|
[1] | 189 | km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & |
---|
| 190 | - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & |
---|
[1340] | 191 | ) * ddx2 & |
---|
[1] | 192 | + ( fyp(j,i) * ( & |
---|
[978] | 193 | kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
| 194 | + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & |
---|
[1] | 195 | ) & |
---|
| 196 | - fym(j,i) * ( & |
---|
[978] | 197 | kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 198 | + kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
[1] | 199 | ) & |
---|
[56] | 200 | + wall_u(j,i) * usvs(k,j,i) & |
---|
[1] | 201 | ) * ddy |
---|
| 202 | ENDDO |
---|
| 203 | ENDIF |
---|
| 204 | |
---|
| 205 | ! |
---|
| 206 | !-- Compute vertical diffusion. In case of simulating a Prandtl layer, |
---|
| 207 | !-- index k starts at nzb_u_inner+2. |
---|
[102] | 208 | DO k = nzb_diff_u(j,i), nzt_diff |
---|
[1] | 209 | ! |
---|
| 210 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 211 | kmzp = 0.25_wp * & |
---|
[1] | 212 | ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) |
---|
[1340] | 213 | kmzm = 0.25_wp * & |
---|
[1] | 214 | ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) |
---|
| 215 | |
---|
[1320] | 216 | tend(k,j,i) = tend(k,j,i) & |
---|
| 217 | & + ( kmzp * ( ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
| 218 | & + ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 219 | & ) & |
---|
| 220 | & - kmzm * ( ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & |
---|
| 221 | & + ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & |
---|
| 222 | & ) & |
---|
[1] | 223 | & ) * ddzw(k) |
---|
| 224 | ENDDO |
---|
| 225 | |
---|
| 226 | ! |
---|
| 227 | !-- Vertical diffusion at the first grid point above the surface, |
---|
| 228 | !-- if the momentum flux at the bottom is given by the Prandtl law or |
---|
| 229 | !-- if it is prescribed by the user. |
---|
| 230 | !-- Difference quotient of the momentum flux is not formed over half |
---|
| 231 | !-- of the grid spacing (2.0*ddzw(k)) any more, since the comparison |
---|
[1320] | 232 | !-- with other (LES) models showed that the values of the momentum |
---|
[1] | 233 | !-- flux becomes too large in this case. |
---|
| 234 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
| 235 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
| 236 | IF ( use_surface_fluxes ) THEN |
---|
| 237 | k = nzb_u_inner(j,i)+1 |
---|
| 238 | ! |
---|
| 239 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 240 | kmzp = 0.25_wp * & |
---|
[1] | 241 | ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) |
---|
| 242 | |
---|
[1320] | 243 | tend(k,j,i) = tend(k,j,i) & |
---|
| 244 | & + ( kmzp * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 245 | & ) * ddzw(k) & |
---|
| 246 | & + ( kmzp * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
| 247 | & + usws(j,i) & |
---|
[1] | 248 | & ) * ddzw(k) |
---|
| 249 | ENDIF |
---|
| 250 | |
---|
[102] | 251 | ! |
---|
| 252 | !-- Vertical diffusion at the first gridpoint below the top boundary, |
---|
| 253 | !-- if the momentum flux at the top is prescribed by the user |
---|
[103] | 254 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
[102] | 255 | k = nzt |
---|
| 256 | ! |
---|
| 257 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 258 | kmzm = 0.25_wp * & |
---|
[102] | 259 | ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) |
---|
| 260 | |
---|
[1320] | 261 | tend(k,j,i) = tend(k,j,i) & |
---|
| 262 | & - ( kmzm * ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & |
---|
| 263 | & ) * ddzw(k) & |
---|
| 264 | & + ( -uswst(j,i) & |
---|
| 265 | & - kmzm * ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & |
---|
[102] | 266 | & ) * ddzw(k) |
---|
| 267 | ENDIF |
---|
| 268 | |
---|
[1] | 269 | ENDDO |
---|
| 270 | ENDDO |
---|
| 271 | |
---|
| 272 | END SUBROUTINE diffusion_u |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | !------------------------------------------------------------------------------! |
---|
[1682] | 276 | ! Description: |
---|
| 277 | ! ------------ |
---|
| 278 | !> Call for all grid points - accelerator version |
---|
[1015] | 279 | !------------------------------------------------------------------------------! |
---|
| 280 | SUBROUTINE diffusion_u_acc |
---|
| 281 | |
---|
[1320] | 282 | USE arrays_3d, & |
---|
| 283 | ONLY: ddzu, ddzw, km, tend, u, usws, uswst, v, w |
---|
| 284 | |
---|
| 285 | USE control_parameters, & |
---|
| 286 | ONLY: constant_top_momentumflux, topography, use_surface_fluxes, & |
---|
| 287 | use_top_fluxes |
---|
| 288 | |
---|
| 289 | USE grid_variables, & |
---|
| 290 | ONLY: ddx, ddx2, ddy, fym, fyp, wall_u |
---|
| 291 | |
---|
| 292 | USE indices, & |
---|
| 293 | ONLY: i_left, i_right, j_north, j_south, nxl, nxr, nyn, nys, nzb, & |
---|
| 294 | nzb_diff_u, nzb_u_inner, nzb_u_outer, nzt, nzt_diff |
---|
| 295 | |
---|
| 296 | USE kinds |
---|
[1015] | 297 | |
---|
| 298 | IMPLICIT NONE |
---|
| 299 | |
---|
[1682] | 300 | INTEGER(iwp) :: i !< |
---|
| 301 | INTEGER(iwp) :: j !< |
---|
| 302 | INTEGER(iwp) :: k !< |
---|
| 303 | REAL(wp) :: kmym !< |
---|
| 304 | REAL(wp) :: kmyp !< |
---|
| 305 | REAL(wp) :: kmzm !< |
---|
| 306 | REAL(wp) :: kmzp !< |
---|
[1015] | 307 | |
---|
[1682] | 308 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: usvs !< |
---|
[1015] | 309 | !$acc declare create ( usvs ) |
---|
| 310 | |
---|
| 311 | ! |
---|
| 312 | !-- First calculate horizontal momentum flux u'v' at vertical walls, |
---|
| 313 | !-- if neccessary |
---|
| 314 | IF ( topography /= 'flat' ) THEN |
---|
[1320] | 315 | CALL wall_fluxes_acc( usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, & |
---|
| 316 | nzb_u_inner, nzb_u_outer, wall_u ) |
---|
[1015] | 317 | ENDIF |
---|
| 318 | |
---|
[1320] | 319 | !$acc kernels present ( u, v, w, km, tend, usws, uswst ) & |
---|
| 320 | !$acc present ( ddzu, ddzw, fym, fyp, wall_u ) & |
---|
[1015] | 321 | !$acc present ( nzb_u_inner, nzb_u_outer, nzb_diff_u ) |
---|
[1128] | 322 | DO i = i_left, i_right |
---|
| 323 | DO j = j_south, j_north |
---|
[1015] | 324 | ! |
---|
| 325 | !-- Compute horizontal diffusion |
---|
| 326 | DO k = 1, nzt |
---|
| 327 | IF ( k > nzb_u_outer(j,i) ) THEN |
---|
| 328 | ! |
---|
| 329 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 330 | kmyp = 0.25_wp * & |
---|
[1015] | 331 | ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) |
---|
[1340] | 332 | kmym = 0.25_wp * & |
---|
[1015] | 333 | ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) |
---|
| 334 | |
---|
| 335 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 336 | & + 2.0_wp * ( & |
---|
[1015] | 337 | & km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & |
---|
| 338 | & - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & |
---|
[1340] | 339 | & ) * ddx2 & |
---|
[1015] | 340 | & + ( kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
| 341 | & + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & |
---|
| 342 | & - kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 343 | & - kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 344 | & ) * ddy |
---|
| 345 | ENDIF |
---|
| 346 | ENDDO |
---|
| 347 | |
---|
| 348 | ! |
---|
| 349 | !-- Wall functions at the north and south walls, respectively |
---|
| 350 | DO k = 1, nzt |
---|
[1320] | 351 | IF( k > nzb_u_inner(j,i) .AND. k <= nzb_u_outer(j,i) .AND. & |
---|
[1340] | 352 | wall_u(j,i) /= 0.0_wp ) THEN |
---|
[1015] | 353 | |
---|
[1340] | 354 | kmyp = 0.25_wp * & |
---|
[1015] | 355 | ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) |
---|
[1340] | 356 | kmym = 0.25_wp * & |
---|
[1015] | 357 | ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) |
---|
| 358 | |
---|
| 359 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 360 | + 2.0_wp * ( & |
---|
[1015] | 361 | km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & |
---|
| 362 | - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & |
---|
[1340] | 363 | ) * ddx2 & |
---|
[1015] | 364 | + ( fyp(j,i) * ( & |
---|
| 365 | kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
| 366 | + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & |
---|
| 367 | ) & |
---|
| 368 | - fym(j,i) * ( & |
---|
| 369 | kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 370 | + kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 371 | ) & |
---|
| 372 | + wall_u(j,i) * usvs(k,j,i) & |
---|
| 373 | ) * ddy |
---|
| 374 | ENDIF |
---|
| 375 | ENDDO |
---|
| 376 | |
---|
| 377 | ! |
---|
| 378 | !-- Compute vertical diffusion. In case of simulating a Prandtl layer, |
---|
| 379 | !-- index k starts at nzb_u_inner+2. |
---|
| 380 | DO k = 1, nzt_diff |
---|
| 381 | IF ( k >= nzb_diff_u(j,i) ) THEN |
---|
| 382 | ! |
---|
| 383 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 384 | kmzp = 0.25_wp * & |
---|
[1015] | 385 | ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) |
---|
[1340] | 386 | kmzm = 0.25_wp * & |
---|
[1015] | 387 | ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) |
---|
| 388 | |
---|
| 389 | tend(k,j,i) = tend(k,j,i) & |
---|
| 390 | & + ( kmzp * ( ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1)& |
---|
| 391 | & + ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 392 | & ) & |
---|
| 393 | & - kmzm * ( ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k)& |
---|
| 394 | & + ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & |
---|
| 395 | & ) & |
---|
| 396 | & ) * ddzw(k) |
---|
| 397 | ENDIF |
---|
| 398 | ENDDO |
---|
| 399 | |
---|
| 400 | ENDDO |
---|
| 401 | ENDDO |
---|
| 402 | |
---|
| 403 | ! |
---|
| 404 | !-- Vertical diffusion at the first grid point above the surface, |
---|
| 405 | !-- if the momentum flux at the bottom is given by the Prandtl law or |
---|
| 406 | !-- if it is prescribed by the user. |
---|
| 407 | !-- Difference quotient of the momentum flux is not formed over half |
---|
| 408 | !-- of the grid spacing (2.0*ddzw(k)) any more, since the comparison |
---|
[1320] | 409 | !-- with other (LES) models showed that the values of the momentum |
---|
[1015] | 410 | !-- flux becomes too large in this case. |
---|
| 411 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
| 412 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
| 413 | IF ( use_surface_fluxes ) THEN |
---|
| 414 | |
---|
[1128] | 415 | DO i = i_left, i_right |
---|
| 416 | DO j = j_south, j_north |
---|
[1015] | 417 | |
---|
| 418 | k = nzb_u_inner(j,i)+1 |
---|
| 419 | ! |
---|
| 420 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 421 | kmzp = 0.25_wp * & |
---|
[1015] | 422 | ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) |
---|
| 423 | |
---|
[1320] | 424 | tend(k,j,i) = tend(k,j,i) & |
---|
| 425 | & + ( kmzp * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 426 | & ) * ddzw(k) & |
---|
| 427 | & + ( kmzp * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
| 428 | & + usws(j,i) & |
---|
[1015] | 429 | & ) * ddzw(k) |
---|
| 430 | ENDDO |
---|
| 431 | ENDDO |
---|
| 432 | |
---|
| 433 | ENDIF |
---|
| 434 | |
---|
| 435 | ! |
---|
| 436 | !-- Vertical diffusion at the first gridpoint below the top boundary, |
---|
| 437 | !-- if the momentum flux at the top is prescribed by the user |
---|
| 438 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
| 439 | |
---|
| 440 | k = nzt |
---|
| 441 | |
---|
[1128] | 442 | DO i = i_left, i_right |
---|
| 443 | DO j = j_south, j_north |
---|
[1015] | 444 | |
---|
| 445 | ! |
---|
| 446 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 447 | kmzm = 0.25_wp * & |
---|
[1015] | 448 | ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) |
---|
| 449 | |
---|
[1320] | 450 | tend(k,j,i) = tend(k,j,i) & |
---|
| 451 | & - ( kmzm * ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & |
---|
| 452 | & ) * ddzw(k) & |
---|
| 453 | & + ( -uswst(j,i) & |
---|
| 454 | & - kmzm * ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & |
---|
[1015] | 455 | & ) * ddzw(k) |
---|
| 456 | ENDDO |
---|
| 457 | ENDDO |
---|
| 458 | |
---|
| 459 | ENDIF |
---|
| 460 | !$acc end kernels |
---|
| 461 | |
---|
| 462 | END SUBROUTINE diffusion_u_acc |
---|
| 463 | |
---|
| 464 | |
---|
| 465 | !------------------------------------------------------------------------------! |
---|
[1682] | 466 | ! Description: |
---|
| 467 | ! ------------ |
---|
| 468 | !> Call for grid point i,j |
---|
[1] | 469 | !------------------------------------------------------------------------------! |
---|
[1001] | 470 | SUBROUTINE diffusion_u_ij( i, j ) |
---|
[1] | 471 | |
---|
[1320] | 472 | USE arrays_3d, & |
---|
| 473 | ONLY: ddzu, ddzw, km, tend, u, usws, uswst, v, w |
---|
| 474 | |
---|
| 475 | USE control_parameters, & |
---|
| 476 | ONLY: constant_top_momentumflux, use_surface_fluxes, use_top_fluxes |
---|
| 477 | |
---|
| 478 | USE grid_variables, & |
---|
| 479 | ONLY: ddx, ddx2, ddy, fym, fyp, wall_u |
---|
| 480 | |
---|
| 481 | USE indices, & |
---|
| 482 | ONLY: nzb, nzb_diff_u, nzb_u_inner, nzb_u_outer, nzt, nzt_diff |
---|
| 483 | |
---|
| 484 | USE kinds |
---|
[1] | 485 | |
---|
| 486 | IMPLICIT NONE |
---|
| 487 | |
---|
[1682] | 488 | INTEGER(iwp) :: i !< |
---|
| 489 | INTEGER(iwp) :: j !< |
---|
| 490 | INTEGER(iwp) :: k !< |
---|
| 491 | REAL(wp) :: kmym !< |
---|
| 492 | REAL(wp) :: kmyp !< |
---|
| 493 | REAL(wp) :: kmzm !< |
---|
| 494 | REAL(wp) :: kmzp !< |
---|
[1] | 495 | |
---|
[1682] | 496 | REAL(wp), DIMENSION(nzb:nzt+1) :: usvs !< |
---|
[1001] | 497 | |
---|
[1] | 498 | ! |
---|
| 499 | !-- Compute horizontal diffusion |
---|
| 500 | DO k = nzb_u_outer(j,i)+1, nzt |
---|
| 501 | ! |
---|
| 502 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 503 | kmyp = 0.25_wp * ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) |
---|
| 504 | kmym = 0.25_wp * ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) |
---|
[1] | 505 | |
---|
[1320] | 506 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 507 | & + 2.0_wp * ( & |
---|
[1320] | 508 | & km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & |
---|
| 509 | & - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & |
---|
[1340] | 510 | & ) * ddx2 & |
---|
[1320] | 511 | & + ( kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
| 512 | & + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & |
---|
| 513 | & - kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 514 | & - kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
[1] | 515 | & ) * ddy |
---|
| 516 | ENDDO |
---|
| 517 | |
---|
| 518 | ! |
---|
| 519 | !-- Wall functions at the north and south walls, respectively |
---|
[1691] | 520 | IF ( wall_u(j,i) /= 0.0_wp ) THEN |
---|
[51] | 521 | |
---|
| 522 | ! |
---|
| 523 | !-- Calculate the horizontal momentum flux u'v' |
---|
[1320] | 524 | CALL wall_fluxes( i, j, nzb_u_inner(j,i)+1, nzb_u_outer(j,i), & |
---|
| 525 | usvs, 1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp ) |
---|
[51] | 526 | |
---|
[1] | 527 | DO k = nzb_u_inner(j,i)+1, nzb_u_outer(j,i) |
---|
[1340] | 528 | kmyp = 0.25_wp * ( km(k,j,i)+km(k,j+1,i)+km(k,j,i-1)+km(k,j+1,i-1) ) |
---|
| 529 | kmym = 0.25_wp * ( km(k,j,i)+km(k,j-1,i)+km(k,j,i-1)+km(k,j-1,i-1) ) |
---|
[1] | 530 | |
---|
| 531 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 532 | + 2.0_wp * ( & |
---|
[1] | 533 | km(k,j,i) * ( u(k,j,i+1) - u(k,j,i) ) & |
---|
| 534 | - km(k,j,i-1) * ( u(k,j,i) - u(k,j,i-1) ) & |
---|
[1340] | 535 | ) * ddx2 & |
---|
[1] | 536 | + ( fyp(j,i) * ( & |
---|
[978] | 537 | kmyp * ( u(k,j+1,i) - u(k,j,i) ) * ddy & |
---|
| 538 | + kmyp * ( v(k,j+1,i) - v(k,j+1,i-1) ) * ddx & |
---|
[1] | 539 | ) & |
---|
| 540 | - fym(j,i) * ( & |
---|
[978] | 541 | kmym * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 542 | + kmym * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
[1] | 543 | ) & |
---|
[51] | 544 | + wall_u(j,i) * usvs(k) & |
---|
[1] | 545 | ) * ddy |
---|
| 546 | ENDDO |
---|
| 547 | ENDIF |
---|
| 548 | |
---|
| 549 | ! |
---|
| 550 | !-- Compute vertical diffusion. In case of simulating a Prandtl layer, |
---|
| 551 | !-- index k starts at nzb_u_inner+2. |
---|
[102] | 552 | DO k = nzb_diff_u(j,i), nzt_diff |
---|
[1] | 553 | ! |
---|
| 554 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 555 | kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) |
---|
| 556 | kmzm = 0.25_wp * ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) |
---|
[1] | 557 | |
---|
[1320] | 558 | tend(k,j,i) = tend(k,j,i) & |
---|
| 559 | & + ( kmzp * ( ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
| 560 | & + ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 561 | & ) & |
---|
| 562 | & - kmzm * ( ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & |
---|
| 563 | & + ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & |
---|
| 564 | & ) & |
---|
[1] | 565 | & ) * ddzw(k) |
---|
| 566 | ENDDO |
---|
| 567 | |
---|
| 568 | ! |
---|
| 569 | !-- Vertical diffusion at the first grid point above the surface, if the |
---|
| 570 | !-- momentum flux at the bottom is given by the Prandtl law or if it is |
---|
| 571 | !-- prescribed by the user. |
---|
| 572 | !-- Difference quotient of the momentum flux is not formed over half of |
---|
| 573 | !-- the grid spacing (2.0*ddzw(k)) any more, since the comparison with |
---|
[1320] | 574 | !-- other (LES) models showed that the values of the momentum flux becomes |
---|
[1] | 575 | !-- too large in this case. |
---|
| 576 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
| 577 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
| 578 | IF ( use_surface_fluxes ) THEN |
---|
| 579 | k = nzb_u_inner(j,i)+1 |
---|
| 580 | ! |
---|
| 581 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 582 | kmzp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j,i-1)+km(k+1,j,i-1) ) |
---|
[1] | 583 | |
---|
[1320] | 584 | tend(k,j,i) = tend(k,j,i) & |
---|
| 585 | & + ( kmzp * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 586 | & ) * ddzw(k) & |
---|
| 587 | & + ( kmzp * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
| 588 | & + usws(j,i) & |
---|
[1] | 589 | & ) * ddzw(k) |
---|
| 590 | ENDIF |
---|
| 591 | |
---|
[102] | 592 | ! |
---|
| 593 | !-- Vertical diffusion at the first gridpoint below the top boundary, |
---|
| 594 | !-- if the momentum flux at the top is prescribed by the user |
---|
[103] | 595 | IF ( use_top_fluxes .AND. constant_top_momentumflux ) THEN |
---|
[102] | 596 | k = nzt |
---|
| 597 | ! |
---|
| 598 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1340] | 599 | kmzm = 0.25_wp * & |
---|
[102] | 600 | ( km(k,j,i)+km(k-1,j,i)+km(k,j,i-1)+km(k-1,j,i-1) ) |
---|
| 601 | |
---|
[1320] | 602 | tend(k,j,i) = tend(k,j,i) & |
---|
| 603 | & - ( kmzm * ( w(k-1,j,i) - w(k-1,j,i-1) ) * ddx & |
---|
| 604 | & ) * ddzw(k) & |
---|
| 605 | & + ( -uswst(j,i) & |
---|
| 606 | & - kmzm * ( u(k,j,i) - u(k-1,j,i) ) * ddzu(k) & |
---|
[102] | 607 | & ) * ddzw(k) |
---|
| 608 | ENDIF |
---|
| 609 | |
---|
[1] | 610 | END SUBROUTINE diffusion_u_ij |
---|
| 611 | |
---|
| 612 | END MODULE diffusion_u_mod |
---|