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