[1682] | 1 | !> @file diffusion_w.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1818] | 16 | ! Copyright 1997-2016 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1] | 20 | ! ----------------- |
---|
[1341] | 21 | ! |
---|
[1683] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: diffusion_w.f90 1818 2016-04-06 15:53:27Z hoffmann $ |
---|
| 26 | ! |
---|
[1683] | 27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 28 | ! Code annotations made doxygen readable |
---|
| 29 | ! |
---|
[1375] | 30 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 31 | ! vsws + vswst removed from acc-present-list |
---|
| 32 | ! |
---|
[1354] | 33 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 34 | ! REAL constants provided with KIND-attribute |
---|
| 35 | ! |
---|
[1341] | 36 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 37 | ! REAL constants defined as wp-kind |
---|
| 38 | ! |
---|
[1323] | 39 | ! 1322 2014-03-20 16:38:49Z raasch |
---|
| 40 | ! REAL constants defined as wp-kind |
---|
| 41 | ! |
---|
[1321] | 42 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 43 | ! ONLY-attribute added to USE-statements, |
---|
| 44 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 45 | ! kinds are defined in new module kinds, |
---|
| 46 | ! revision history before 2012 removed, |
---|
| 47 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 48 | ! all variable declaration statements |
---|
[1] | 49 | ! |
---|
[1258] | 50 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
| 51 | ! openacc loop and loop vector clauses removed, declare create moved after |
---|
| 52 | ! the FORTRAN declaration statement |
---|
| 53 | ! |
---|
[1132] | 54 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
| 55 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
| 56 | ! j_north |
---|
| 57 | ! |
---|
[1037] | 58 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 59 | ! code put under GPL (PALM 3.9) |
---|
| 60 | ! |
---|
[1017] | 61 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 62 | ! accelerator version (*_acc) added |
---|
| 63 | ! |
---|
[1002] | 64 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 65 | ! arrays comunicated by module instead of parameter list |
---|
| 66 | ! |
---|
[979] | 67 | ! 978 2012-08-09 08:28:32Z fricke |
---|
| 68 | ! outflow damping layer removed |
---|
| 69 | ! kmxm_x/_z and kmxp_x/_z change to kmxm and kmxp |
---|
| 70 | ! kmym_y/_z and kmyp_y/_z change to kmym and kmyp |
---|
| 71 | ! |
---|
[1] | 72 | ! Revision 1.1 1997/09/12 06:24:11 raasch |
---|
| 73 | ! Initial revision |
---|
| 74 | ! |
---|
| 75 | ! |
---|
| 76 | ! Description: |
---|
| 77 | ! ------------ |
---|
[1682] | 78 | !> Diffusion term of the w-component |
---|
[1] | 79 | !------------------------------------------------------------------------------! |
---|
[1682] | 80 | MODULE diffusion_w_mod |
---|
| 81 | |
---|
[1] | 82 | |
---|
[1320] | 83 | USE wall_fluxes_mod, & |
---|
| 84 | ONLY : wall_fluxes, wall_fluxes_acc |
---|
[56] | 85 | |
---|
[1] | 86 | PRIVATE |
---|
[1015] | 87 | PUBLIC diffusion_w, diffusion_w_acc |
---|
[1] | 88 | |
---|
| 89 | INTERFACE diffusion_w |
---|
| 90 | MODULE PROCEDURE diffusion_w |
---|
| 91 | MODULE PROCEDURE diffusion_w_ij |
---|
| 92 | END INTERFACE diffusion_w |
---|
| 93 | |
---|
[1015] | 94 | INTERFACE diffusion_w_acc |
---|
| 95 | MODULE PROCEDURE diffusion_w_acc |
---|
| 96 | END INTERFACE diffusion_w_acc |
---|
| 97 | |
---|
[1] | 98 | CONTAINS |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | !------------------------------------------------------------------------------! |
---|
[1682] | 102 | ! Description: |
---|
| 103 | ! ------------ |
---|
| 104 | !> Call for all grid points |
---|
[1] | 105 | !------------------------------------------------------------------------------! |
---|
[1001] | 106 | SUBROUTINE diffusion_w |
---|
[1] | 107 | |
---|
[1320] | 108 | USE arrays_3d, & |
---|
| 109 | ONLY : ddzu, ddzw, km, tend, u, v, w |
---|
| 110 | |
---|
| 111 | USE control_parameters, & |
---|
| 112 | ONLY : topography |
---|
| 113 | |
---|
| 114 | USE grid_variables, & |
---|
| 115 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
| 116 | |
---|
| 117 | USE indices, & |
---|
| 118 | ONLY : nxl, nxr, nyn, nys, nzb, nzb_w_inner, nzb_w_outer, nzt |
---|
| 119 | |
---|
| 120 | USE kinds |
---|
[1] | 121 | |
---|
| 122 | IMPLICIT NONE |
---|
| 123 | |
---|
[1682] | 124 | INTEGER(iwp) :: i !< |
---|
| 125 | INTEGER(iwp) :: j !< |
---|
| 126 | INTEGER(iwp) :: k !< |
---|
[1320] | 127 | |
---|
[1682] | 128 | REAL(wp) :: kmxm !< |
---|
| 129 | REAL(wp) :: kmxp !< |
---|
| 130 | REAL(wp) :: kmym !< |
---|
| 131 | REAL(wp) :: kmyp !< |
---|
[1001] | 132 | |
---|
[1682] | 133 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsus !< |
---|
| 134 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsvs !< |
---|
[1] | 135 | |
---|
| 136 | |
---|
[56] | 137 | ! |
---|
| 138 | !-- First calculate horizontal momentum flux w'u' and/or w'v' at vertical |
---|
| 139 | !-- walls, if neccessary |
---|
| 140 | IF ( topography /= 'flat' ) THEN |
---|
[1320] | 141 | CALL wall_fluxes( wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, nzb_w_inner, & |
---|
[56] | 142 | nzb_w_outer, wall_w_x ) |
---|
[1320] | 143 | CALL wall_fluxes( wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, nzb_w_inner, & |
---|
[56] | 144 | nzb_w_outer, wall_w_y ) |
---|
| 145 | ENDIF |
---|
| 146 | |
---|
[1] | 147 | DO i = nxl, nxr |
---|
| 148 | DO j = nys, nyn |
---|
| 149 | DO k = nzb_w_outer(j,i)+1, nzt-1 |
---|
| 150 | ! |
---|
| 151 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1322] | 152 | kmxp = 0.25_wp * & |
---|
[978] | 153 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
[1322] | 154 | kmxm = 0.25_wp * & |
---|
[978] | 155 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
[1322] | 156 | kmyp = 0.25_wp * & |
---|
[978] | 157 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
[1322] | 158 | kmym = 0.25_wp * & |
---|
[978] | 159 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
[1] | 160 | |
---|
| 161 | tend(k,j,i) = tend(k,j,i) & |
---|
[978] | 162 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 163 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
| 164 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 165 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 166 | & ) * ddx & |
---|
[978] | 167 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 168 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
| 169 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 170 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 171 | & ) * ddy & |
---|
[1322] | 172 | & + 2.0_wp * ( & |
---|
[1] | 173 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 174 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
[1340] | 175 | & ) * ddzu(k+1) |
---|
[1] | 176 | ENDDO |
---|
| 177 | |
---|
| 178 | ! |
---|
| 179 | !-- Wall functions at all vertical walls, where necessary |
---|
[1340] | 180 | IF ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
[51] | 181 | |
---|
[1] | 182 | DO k = nzb_w_inner(j,i)+1, nzb_w_outer(j,i) |
---|
| 183 | ! |
---|
| 184 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1322] | 185 | kmxp = 0.25_wp * & |
---|
[978] | 186 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
[1322] | 187 | kmxm = 0.25_wp * & |
---|
[978] | 188 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
[1322] | 189 | kmyp = 0.25_wp * & |
---|
[978] | 190 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
[1322] | 191 | kmym = 0.25_wp * & |
---|
[978] | 192 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
[1] | 193 | |
---|
| 194 | tend(k,j,i) = tend(k,j,i) & |
---|
| 195 | + ( fwxp(j,i) * ( & |
---|
[978] | 196 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 197 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
[1] | 198 | ) & |
---|
| 199 | - fwxm(j,i) * ( & |
---|
[978] | 200 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 201 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 202 | ) & |
---|
[56] | 203 | + wall_w_x(j,i) * wsus(k,j,i) & |
---|
[1] | 204 | ) * ddx & |
---|
| 205 | + ( fwyp(j,i) * ( & |
---|
[978] | 206 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 207 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
[1] | 208 | ) & |
---|
| 209 | - fwym(j,i) * ( & |
---|
[978] | 210 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 211 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 212 | ) & |
---|
[56] | 213 | + wall_w_y(j,i) * wsvs(k,j,i) & |
---|
[1] | 214 | ) * ddy & |
---|
[1340] | 215 | + 2.0_wp * ( & |
---|
[1] | 216 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 217 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
[1340] | 218 | ) * ddzu(k+1) |
---|
[1] | 219 | ENDDO |
---|
| 220 | ENDIF |
---|
| 221 | |
---|
| 222 | ENDDO |
---|
| 223 | ENDDO |
---|
| 224 | |
---|
| 225 | END SUBROUTINE diffusion_w |
---|
| 226 | |
---|
| 227 | |
---|
| 228 | !------------------------------------------------------------------------------! |
---|
[1682] | 229 | ! Description: |
---|
| 230 | ! ------------ |
---|
| 231 | !> Call for all grid points - accelerator version |
---|
[1015] | 232 | !------------------------------------------------------------------------------! |
---|
| 233 | SUBROUTINE diffusion_w_acc |
---|
| 234 | |
---|
[1320] | 235 | USE arrays_3d, & |
---|
| 236 | ONLY : ddzu, ddzw, km, tend, u, v, w |
---|
| 237 | |
---|
| 238 | USE control_parameters, & |
---|
| 239 | ONLY : topography |
---|
| 240 | |
---|
| 241 | USE grid_variables, & |
---|
| 242 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
| 243 | |
---|
| 244 | USE indices, & |
---|
| 245 | ONLY : i_left, i_right, j_north, j_south, nxl, nxr, nyn, nys, nzb, & |
---|
| 246 | nzb_w_inner, nzb_w_outer, nzt |
---|
| 247 | |
---|
| 248 | USE kinds |
---|
[1015] | 249 | |
---|
| 250 | IMPLICIT NONE |
---|
| 251 | |
---|
[1682] | 252 | INTEGER(iwp) :: i !< |
---|
| 253 | INTEGER(iwp) :: j !< |
---|
| 254 | INTEGER(iwp) :: k !< |
---|
[1320] | 255 | |
---|
[1682] | 256 | REAL(wp) :: kmxm !< |
---|
| 257 | REAL(wp) :: kmxp !< |
---|
| 258 | REAL(wp) :: kmym !< |
---|
| 259 | REAL(wp) :: kmyp !< |
---|
[1015] | 260 | |
---|
[1682] | 261 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsus !< |
---|
| 262 | REAL(wp), DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wsvs !< |
---|
[1015] | 263 | !$acc declare create ( wsus, wsvs ) |
---|
| 264 | |
---|
| 265 | ! |
---|
| 266 | !-- First calculate horizontal momentum flux w'u' and/or w'v' at vertical |
---|
| 267 | !-- walls, if neccessary |
---|
| 268 | IF ( topography /= 'flat' ) THEN |
---|
[1320] | 269 | CALL wall_fluxes_acc( wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, & |
---|
| 270 | nzb_w_inner, nzb_w_outer, wall_w_x ) |
---|
| 271 | CALL wall_fluxes_acc( wsvs, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, & |
---|
| 272 | nzb_w_inner, nzb_w_outer, wall_w_y ) |
---|
[1015] | 273 | ENDIF |
---|
| 274 | |
---|
[1374] | 275 | !$acc kernels present ( u, v, w, km, tend ) & |
---|
[1015] | 276 | !$acc present ( ddzu, ddzw, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y ) & |
---|
| 277 | !$acc present ( nzb_w_inner, nzb_w_outer ) |
---|
[1128] | 278 | DO i = i_left, i_right |
---|
| 279 | DO j = j_south, j_north |
---|
[1015] | 280 | DO k = 1, nzt |
---|
| 281 | IF ( k > nzb_w_outer(j,i) ) THEN |
---|
| 282 | ! |
---|
| 283 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1322] | 284 | kmxp = 0.25_wp * & |
---|
[1015] | 285 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
[1322] | 286 | kmxm = 0.25_wp * & |
---|
[1015] | 287 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
[1322] | 288 | kmyp = 0.25_wp * & |
---|
[1015] | 289 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
[1322] | 290 | kmym = 0.25_wp * & |
---|
[1015] | 291 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
| 292 | |
---|
| 293 | tend(k,j,i) = tend(k,j,i) & |
---|
| 294 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 295 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
| 296 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 297 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
| 298 | & ) * ddx & |
---|
| 299 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 300 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
| 301 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 302 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 303 | & ) * ddy & |
---|
[1322] | 304 | & + 2.0_wp * ( & |
---|
[1015] | 305 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 306 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
[1340] | 307 | & ) * ddzu(k+1) |
---|
[1015] | 308 | ENDIF |
---|
| 309 | ENDDO |
---|
| 310 | |
---|
| 311 | ! |
---|
| 312 | !-- Wall functions at all vertical walls, where necessary |
---|
| 313 | DO k = 1,nzt |
---|
| 314 | |
---|
| 315 | IF ( k > nzb_w_inner(j,i) .AND. k <= nzb_w_outer(j,i) .AND. & |
---|
[1340] | 316 | wall_w_x(j,i) /= 0.0_wp .AND. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
[1015] | 317 | ! |
---|
| 318 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1322] | 319 | kmxp = 0.25_wp * & |
---|
[1015] | 320 | ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
[1322] | 321 | kmxm = 0.25_wp * & |
---|
[1015] | 322 | ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
[1322] | 323 | kmyp = 0.25_wp * & |
---|
[1015] | 324 | ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
[1322] | 325 | kmym = 0.25_wp * & |
---|
[1015] | 326 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
| 327 | |
---|
| 328 | tend(k,j,i) = tend(k,j,i) & |
---|
| 329 | + ( fwxp(j,i) * ( & |
---|
| 330 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 331 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
| 332 | ) & |
---|
| 333 | - fwxm(j,i) * ( & |
---|
| 334 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 335 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
| 336 | ) & |
---|
| 337 | + wall_w_x(j,i) * wsus(k,j,i) & |
---|
| 338 | ) * ddx & |
---|
| 339 | + ( fwyp(j,i) * ( & |
---|
| 340 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 341 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
| 342 | ) & |
---|
| 343 | - fwym(j,i) * ( & |
---|
| 344 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 345 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 346 | ) & |
---|
| 347 | + wall_w_y(j,i) * wsvs(k,j,i) & |
---|
| 348 | ) * ddy & |
---|
[1340] | 349 | + 2.0_wp * ( & |
---|
[1015] | 350 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 351 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
[1340] | 352 | ) * ddzu(k+1) |
---|
[1015] | 353 | ENDIF |
---|
| 354 | ENDDO |
---|
| 355 | |
---|
| 356 | ENDDO |
---|
| 357 | ENDDO |
---|
| 358 | !$acc end kernels |
---|
| 359 | |
---|
| 360 | END SUBROUTINE diffusion_w_acc |
---|
| 361 | |
---|
| 362 | |
---|
| 363 | !------------------------------------------------------------------------------! |
---|
[1682] | 364 | ! Description: |
---|
| 365 | ! ------------ |
---|
| 366 | !> Call for grid point i,j |
---|
[1] | 367 | !------------------------------------------------------------------------------! |
---|
[1001] | 368 | SUBROUTINE diffusion_w_ij( i, j ) |
---|
[1] | 369 | |
---|
[1320] | 370 | USE arrays_3d, & |
---|
| 371 | ONLY : ddzu, ddzw, km, tend, u, v, w |
---|
| 372 | |
---|
| 373 | USE control_parameters, & |
---|
| 374 | ONLY : topography |
---|
| 375 | |
---|
| 376 | USE grid_variables, & |
---|
| 377 | ONLY : ddx, ddy, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
| 378 | |
---|
| 379 | USE indices, & |
---|
| 380 | ONLY : nxl, nxr, nyn, nys, nzb, nzb_w_inner, nzb_w_outer, nzt |
---|
| 381 | |
---|
| 382 | USE kinds |
---|
[1] | 383 | |
---|
| 384 | IMPLICIT NONE |
---|
| 385 | |
---|
[1682] | 386 | INTEGER(iwp) :: i !< |
---|
| 387 | INTEGER(iwp) :: j !< |
---|
| 388 | INTEGER(iwp) :: k !< |
---|
[1320] | 389 | |
---|
[1682] | 390 | REAL(wp) :: kmxm !< |
---|
| 391 | REAL(wp) :: kmxp !< |
---|
| 392 | REAL(wp) :: kmym !< |
---|
| 393 | REAL(wp) :: kmyp !< |
---|
[1] | 394 | |
---|
[1320] | 395 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsus |
---|
| 396 | REAL(wp), DIMENSION(nzb:nzt+1) :: wsvs |
---|
[1] | 397 | |
---|
[1001] | 398 | |
---|
[1] | 399 | DO k = nzb_w_outer(j,i)+1, nzt-1 |
---|
| 400 | ! |
---|
| 401 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1322] | 402 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
| 403 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
| 404 | kmyp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
| 405 | kmym = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
[1] | 406 | |
---|
| 407 | tend(k,j,i) = tend(k,j,i) & |
---|
[978] | 408 | & + ( kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 409 | & + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
| 410 | & - kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 411 | & - kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 412 | & ) * ddx & |
---|
[978] | 413 | & + ( kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 414 | & + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
| 415 | & - kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 416 | & - kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 417 | & ) * ddy & |
---|
[1322] | 418 | & + 2.0_wp * ( & |
---|
[1] | 419 | & km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 420 | & - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
[1340] | 421 | & ) * ddzu(k+1) |
---|
[1] | 422 | ENDDO |
---|
| 423 | |
---|
| 424 | ! |
---|
| 425 | !-- Wall functions at all vertical walls, where necessary |
---|
[1340] | 426 | IF ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
[51] | 427 | |
---|
| 428 | ! |
---|
| 429 | !-- Calculate the horizontal momentum fluxes w'u' and/or w'v' |
---|
[1340] | 430 | IF ( wall_w_x(j,i) /= 0.0_wp ) THEN |
---|
[1320] | 431 | CALL wall_fluxes( i, j, nzb_w_inner(j,i)+1, nzb_w_outer(j,i), & |
---|
| 432 | wsus, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp ) |
---|
[51] | 433 | ELSE |
---|
[1340] | 434 | wsus = 0.0_wp |
---|
[51] | 435 | ENDIF |
---|
| 436 | |
---|
[1340] | 437 | IF ( wall_w_y(j,i) /= 0.0_wp ) THEN |
---|
[1320] | 438 | CALL wall_fluxes( i, j, nzb_w_inner(j,i)+1, nzb_w_outer(j,i), & |
---|
| 439 | wsvs, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp ) |
---|
[51] | 440 | ELSE |
---|
[1340] | 441 | wsvs = 0.0_wp |
---|
[51] | 442 | ENDIF |
---|
| 443 | |
---|
[1] | 444 | DO k = nzb_w_inner(j,i)+1, nzb_w_outer(j,i) |
---|
| 445 | ! |
---|
| 446 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
[1322] | 447 | kmxp = 0.25_wp * ( km(k,j,i)+km(k,j,i+1)+km(k+1,j,i)+km(k+1,j,i+1) ) |
---|
| 448 | kmxm = 0.25_wp * ( km(k,j,i)+km(k,j,i-1)+km(k+1,j,i)+km(k+1,j,i-1) ) |
---|
| 449 | kmyp = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j+1,i)+km(k+1,j+1,i) ) |
---|
| 450 | kmym = 0.25_wp * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
[1] | 451 | |
---|
| 452 | tend(k,j,i) = tend(k,j,i) & |
---|
| 453 | + ( fwxp(j,i) * ( & |
---|
[978] | 454 | kmxp * ( w(k,j,i+1) - w(k,j,i) ) * ddx & |
---|
| 455 | + kmxp * ( u(k+1,j,i+1) - u(k,j,i+1) ) * ddzu(k+1) & |
---|
[1] | 456 | ) & |
---|
| 457 | - fwxm(j,i) * ( & |
---|
[978] | 458 | kmxm * ( w(k,j,i) - w(k,j,i-1) ) * ddx & |
---|
| 459 | + kmxm * ( u(k+1,j,i) - u(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 460 | ) & |
---|
[51] | 461 | + wall_w_x(j,i) * wsus(k) & |
---|
[1] | 462 | ) * ddx & |
---|
| 463 | + ( fwyp(j,i) * ( & |
---|
[978] | 464 | kmyp * ( w(k,j+1,i) - w(k,j,i) ) * ddy & |
---|
| 465 | + kmyp * ( v(k+1,j+1,i) - v(k,j+1,i) ) * ddzu(k+1) & |
---|
[1] | 466 | ) & |
---|
| 467 | - fwym(j,i) * ( & |
---|
[978] | 468 | kmym * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 469 | + kmym * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
[1] | 470 | ) & |
---|
[51] | 471 | + wall_w_y(j,i) * wsvs(k) & |
---|
[1] | 472 | ) * ddy & |
---|
[1340] | 473 | + 2.0_wp * ( & |
---|
[1] | 474 | km(k+1,j,i) * ( w(k+1,j,i) - w(k,j,i) ) * ddzw(k+1) & |
---|
| 475 | - km(k,j,i) * ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) & |
---|
[1340] | 476 | ) * ddzu(k+1) |
---|
[1] | 477 | ENDDO |
---|
| 478 | ENDIF |
---|
| 479 | |
---|
| 480 | END SUBROUTINE diffusion_w_ij |
---|
| 481 | |
---|
[1323] | 482 | END MODULE diffusion_w_mod |
---|