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