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