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