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