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