[1682] | 1 | !> @file diffusion_s.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 | ! |
---|
[1691] | 16 | ! Copyright 1997-2015 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[1001] | 20 | ! ------------------ |
---|
[1341] | 21 | ! |
---|
[1692] | 22 | ! |
---|
[1321] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: diffusion_s.f90 1692 2015-10-26 16:29:17Z gronemeier $ |
---|
| 26 | ! |
---|
[1692] | 27 | ! 1691 2015-10-26 16:17:44Z maronga |
---|
| 28 | ! Formatting corrections. |
---|
| 29 | ! |
---|
[1683] | 30 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 31 | ! Code annotations made doxygen readable |
---|
| 32 | ! |
---|
[1375] | 33 | ! 1374 2014-04-25 12:55:07Z raasch |
---|
| 34 | ! missing variables added to ONLY list |
---|
| 35 | ! |
---|
[1341] | 36 | ! 1340 2014-03-25 19:45:13Z kanani |
---|
| 37 | ! REAL constants defined as wp-kind |
---|
| 38 | ! |
---|
[1321] | 39 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
[1320] | 40 | ! ONLY-attribute added to USE-statements, |
---|
| 41 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 42 | ! kinds are defined in new module kinds, |
---|
| 43 | ! revision history before 2012 removed, |
---|
| 44 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 45 | ! all variable declaration statements |
---|
[1321] | 46 | ! |
---|
[1258] | 47 | ! 1257 2013-11-08 15:18:40Z raasch |
---|
| 48 | ! openacc loop and loop vector clauses removed |
---|
| 49 | ! |
---|
[1132] | 50 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
| 51 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
| 52 | ! j_north |
---|
| 53 | ! |
---|
[1093] | 54 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 55 | ! unused variables removed |
---|
| 56 | ! |
---|
[1037] | 57 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 58 | ! code put under GPL (PALM 3.9) |
---|
| 59 | ! |
---|
[1017] | 60 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 61 | ! accelerator version (*_acc) added |
---|
| 62 | ! |
---|
[1011] | 63 | ! 1010 2012-09-20 07:59:54Z raasch |
---|
| 64 | ! cpp switch __nopointer added for pointer free version |
---|
| 65 | ! |
---|
[1002] | 66 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
| 67 | ! some arrays comunicated by module instead of parameter list |
---|
| 68 | ! |
---|
[1] | 69 | ! Revision 1.1 2000/04/13 14:54:02 schroeter |
---|
| 70 | ! Initial revision |
---|
| 71 | ! |
---|
| 72 | ! |
---|
| 73 | ! Description: |
---|
| 74 | ! ------------ |
---|
[1682] | 75 | !> Diffusion term of scalar quantities (temperature and water content) |
---|
[1] | 76 | !------------------------------------------------------------------------------! |
---|
[1682] | 77 | MODULE diffusion_s_mod |
---|
| 78 | |
---|
[1] | 79 | |
---|
| 80 | PRIVATE |
---|
[1015] | 81 | PUBLIC diffusion_s, diffusion_s_acc |
---|
[1] | 82 | |
---|
| 83 | INTERFACE diffusion_s |
---|
| 84 | MODULE PROCEDURE diffusion_s |
---|
| 85 | MODULE PROCEDURE diffusion_s_ij |
---|
| 86 | END INTERFACE diffusion_s |
---|
| 87 | |
---|
[1015] | 88 | INTERFACE diffusion_s_acc |
---|
| 89 | MODULE PROCEDURE diffusion_s_acc |
---|
| 90 | END INTERFACE diffusion_s_acc |
---|
| 91 | |
---|
[1] | 92 | CONTAINS |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | !------------------------------------------------------------------------------! |
---|
[1682] | 96 | ! Description: |
---|
| 97 | ! ------------ |
---|
| 98 | !> Call for all grid points |
---|
[1] | 99 | !------------------------------------------------------------------------------! |
---|
[1001] | 100 | SUBROUTINE diffusion_s( s, s_flux_b, s_flux_t, wall_s_flux ) |
---|
[1] | 101 | |
---|
[1320] | 102 | USE arrays_3d, & |
---|
| 103 | ONLY: ddzu, ddzw, kh, tend |
---|
| 104 | |
---|
| 105 | USE control_parameters, & |
---|
| 106 | ONLY: use_surface_fluxes, use_top_fluxes |
---|
| 107 | |
---|
| 108 | USE grid_variables, & |
---|
| 109 | ONLY: ddx2, ddy2, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
| 110 | |
---|
| 111 | USE indices, & |
---|
[1374] | 112 | ONLY: nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, & |
---|
[1320] | 113 | nzb_diff_s_inner, nzb_s_inner, nzb_s_outer, nzt, nzt_diff |
---|
| 114 | |
---|
| 115 | USE kinds |
---|
[1] | 116 | |
---|
| 117 | IMPLICIT NONE |
---|
| 118 | |
---|
[1682] | 119 | INTEGER(iwp) :: i !< |
---|
| 120 | INTEGER(iwp) :: j !< |
---|
| 121 | INTEGER(iwp) :: k !< |
---|
| 122 | REAL(wp) :: wall_s_flux(0:4) !< |
---|
| 123 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_b, s_flux_t !< |
---|
[1010] | 124 | #if defined( __nopointer ) |
---|
[1682] | 125 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: s !< |
---|
[1010] | 126 | #else |
---|
[1682] | 127 | REAL(wp), DIMENSION(:,:,:), POINTER :: s !< |
---|
[1010] | 128 | #endif |
---|
[1] | 129 | |
---|
| 130 | DO i = nxl, nxr |
---|
| 131 | DO j = nys,nyn |
---|
| 132 | ! |
---|
| 133 | !-- Compute horizontal diffusion |
---|
[19] | 134 | DO k = nzb_s_outer(j,i)+1, nzt |
---|
[1] | 135 | |
---|
[1320] | 136 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 137 | + 0.5_wp * ( & |
---|
[1320] | 138 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
| 139 | - ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
[1340] | 140 | ) * ddx2 & |
---|
| 141 | + 0.5_wp * ( & |
---|
[1320] | 142 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
| 143 | - ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
[1340] | 144 | ) * ddy2 |
---|
[1] | 145 | ENDDO |
---|
| 146 | |
---|
| 147 | ! |
---|
| 148 | !-- Apply prescribed horizontal wall heatflux where necessary |
---|
[1691] | 149 | IF ( ( wall_w_x(j,i) /= 0.0_wp ) .OR. ( wall_w_y(j,i) /= 0.0_wp ) & |
---|
| 150 | ) THEN |
---|
[1] | 151 | DO k = nzb_s_inner(j,i)+1, nzb_s_outer(j,i) |
---|
| 152 | |
---|
[1320] | 153 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 154 | + ( fwxp(j,i) * 0.5_wp * & |
---|
[1320] | 155 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
[1340] | 156 | + ( 1.0_wp - fwxp(j,i) ) * wall_s_flux(1) & |
---|
| 157 | -fwxm(j,i) * 0.5_wp * & |
---|
[1320] | 158 | ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
[1340] | 159 | + ( 1.0_wp - fwxm(j,i) ) * wall_s_flux(2) & |
---|
[1320] | 160 | ) * ddx2 & |
---|
[1340] | 161 | + ( fwyp(j,i) * 0.5_wp * & |
---|
[1320] | 162 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
[1340] | 163 | + ( 1.0_wp - fwyp(j,i) ) * wall_s_flux(3) & |
---|
| 164 | -fwym(j,i) * 0.5_wp * & |
---|
[1320] | 165 | ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
[1340] | 166 | + ( 1.0_wp - fwym(j,i) ) * wall_s_flux(4) & |
---|
[1] | 167 | ) * ddy2 |
---|
| 168 | ENDDO |
---|
| 169 | ENDIF |
---|
| 170 | |
---|
| 171 | ! |
---|
| 172 | !-- Compute vertical diffusion. In case that surface fluxes have been |
---|
[19] | 173 | !-- prescribed or computed at bottom and/or top, index k starts/ends at |
---|
| 174 | !-- nzb+2 or nzt-1, respectively. |
---|
| 175 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
[1] | 176 | |
---|
[1320] | 177 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 178 | + 0.5_wp * ( & |
---|
[1320] | 179 | ( kh(k,j,i) + kh(k+1,j,i) ) * ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & |
---|
| 180 | - ( kh(k,j,i) + kh(k-1,j,i) ) * ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & |
---|
[1340] | 181 | ) * ddzw(k) |
---|
[1] | 182 | ENDDO |
---|
| 183 | |
---|
| 184 | ! |
---|
[19] | 185 | !-- Vertical diffusion at the first computational gridpoint along |
---|
[1] | 186 | !-- z-direction |
---|
| 187 | IF ( use_surface_fluxes ) THEN |
---|
| 188 | |
---|
| 189 | k = nzb_s_inner(j,i)+1 |
---|
| 190 | |
---|
[1320] | 191 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 192 | + ( 0.5_wp * ( kh(k,j,i)+kh(k+1,j,i) ) & |
---|
| 193 | * ( s(k+1,j,i)-s(k,j,i) ) & |
---|
| 194 | * ddzu(k+1) & |
---|
[1320] | 195 | + s_flux_b(j,i) & |
---|
[1] | 196 | ) * ddzw(k) |
---|
| 197 | |
---|
| 198 | ENDIF |
---|
| 199 | |
---|
[19] | 200 | ! |
---|
| 201 | !-- Vertical diffusion at the last computational gridpoint along |
---|
| 202 | !-- z-direction |
---|
| 203 | IF ( use_top_fluxes ) THEN |
---|
| 204 | |
---|
| 205 | k = nzt |
---|
| 206 | |
---|
[1320] | 207 | tend(k,j,i) = tend(k,j,i) & |
---|
| 208 | + ( - s_flux_t(j,i) & |
---|
[1340] | 209 | - 0.5_wp * ( kh(k-1,j,i)+kh(k,j,i) )& |
---|
| 210 | * ( s(k,j,i)-s(k-1,j,i) ) & |
---|
| 211 | * ddzu(k) & |
---|
[19] | 212 | ) * ddzw(k) |
---|
| 213 | |
---|
| 214 | ENDIF |
---|
| 215 | |
---|
[1] | 216 | ENDDO |
---|
| 217 | ENDDO |
---|
| 218 | |
---|
| 219 | END SUBROUTINE diffusion_s |
---|
| 220 | |
---|
| 221 | |
---|
| 222 | !------------------------------------------------------------------------------! |
---|
[1682] | 223 | ! Description: |
---|
| 224 | ! ------------ |
---|
| 225 | !> Call for all grid points - accelerator version |
---|
[1015] | 226 | !------------------------------------------------------------------------------! |
---|
| 227 | SUBROUTINE diffusion_s_acc( s, s_flux_b, s_flux_t, wall_s_flux ) |
---|
| 228 | |
---|
[1320] | 229 | USE arrays_3d, & |
---|
| 230 | ONLY: ddzu, ddzw, kh, tend |
---|
| 231 | |
---|
| 232 | USE control_parameters, & |
---|
| 233 | ONLY: use_surface_fluxes, use_top_fluxes |
---|
| 234 | |
---|
| 235 | USE grid_variables, & |
---|
| 236 | ONLY: ddx2, ddy2, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
| 237 | |
---|
| 238 | USE indices, & |
---|
| 239 | ONLY: i_left, i_right, j_north, j_south, nxlg, nxrg, nyng, nysg, & |
---|
[1374] | 240 | nzb, nzb_diff_s_inner, nzb_s_inner, nzb_s_outer, nzt, nzt_diff |
---|
[1320] | 241 | |
---|
| 242 | USE kinds |
---|
[1015] | 243 | |
---|
| 244 | IMPLICIT NONE |
---|
| 245 | |
---|
[1682] | 246 | INTEGER(iwp) :: i !< |
---|
| 247 | INTEGER(iwp) :: j !< |
---|
| 248 | INTEGER(iwp) :: k !< |
---|
| 249 | REAL(wp) :: wall_s_flux(0:4) !< |
---|
| 250 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_b !< |
---|
| 251 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_t !< |
---|
[1015] | 252 | #if defined( __nopointer ) |
---|
[1682] | 253 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: s !< |
---|
[1015] | 254 | #else |
---|
[1682] | 255 | REAL(wp), DIMENSION(:,:,:), POINTER :: s !< |
---|
[1015] | 256 | #endif |
---|
| 257 | |
---|
| 258 | !$acc kernels present( ddzu, ddzw, fwxm, fwxp, fwym, fwyp, kh ) & |
---|
| 259 | !$acc present( nzb_diff_s_inner, nzb_s_inner, nzb_s_outer, s ) & |
---|
| 260 | !$acc present( s_flux_b, s_flux_t, tend, wall_s_flux ) & |
---|
| 261 | !$acc present( wall_w_x, wall_w_y ) |
---|
[1128] | 262 | DO i = i_left, i_right |
---|
| 263 | DO j = j_south, j_north |
---|
[1015] | 264 | ! |
---|
| 265 | !-- Compute horizontal diffusion |
---|
| 266 | DO k = 1, nzt |
---|
| 267 | IF ( k > nzb_s_outer(j,i) ) THEN |
---|
| 268 | |
---|
[1320] | 269 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 270 | + 0.5_wp * ( & |
---|
[1320] | 271 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
| 272 | - ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
[1340] | 273 | ) * ddx2 & |
---|
| 274 | + 0.5_wp * ( & |
---|
[1320] | 275 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
| 276 | - ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
[1340] | 277 | ) * ddy2 |
---|
[1015] | 278 | ENDIF |
---|
| 279 | ENDDO |
---|
| 280 | |
---|
| 281 | ! |
---|
| 282 | !-- Apply prescribed horizontal wall heatflux where necessary |
---|
| 283 | DO k = 1, nzt |
---|
| 284 | IF ( k > nzb_s_inner(j,i) .AND. k <= nzb_s_outer(j,i) .AND. & |
---|
[1340] | 285 | ( wall_w_x(j,i) /= 0.0_wp .OR. wall_w_y(j,i) /= 0.0_wp ) ) & |
---|
[1015] | 286 | THEN |
---|
[1320] | 287 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 288 | + ( fwxp(j,i) * 0.5_wp * & |
---|
[1320] | 289 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
[1340] | 290 | + ( 1.0_wp - fwxp(j,i) ) * wall_s_flux(1) & |
---|
| 291 | -fwxm(j,i) * 0.5_wp * & |
---|
[1320] | 292 | ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
[1340] | 293 | + ( 1.0_wp - fwxm(j,i) ) * wall_s_flux(2) & |
---|
[1320] | 294 | ) * ddx2 & |
---|
[1340] | 295 | + ( fwyp(j,i) * 0.5_wp * & |
---|
[1320] | 296 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
[1340] | 297 | + ( 1.0_wp - fwyp(j,i) ) * wall_s_flux(3) & |
---|
| 298 | -fwym(j,i) * 0.5_wp * & |
---|
[1320] | 299 | ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
[1340] | 300 | + ( 1.0_wp - fwym(j,i) ) * wall_s_flux(4) & |
---|
[1015] | 301 | ) * ddy2 |
---|
| 302 | ENDIF |
---|
| 303 | ENDDO |
---|
| 304 | |
---|
| 305 | ! |
---|
| 306 | !-- Compute vertical diffusion. In case that surface fluxes have been |
---|
| 307 | !-- prescribed or computed at bottom and/or top, index k starts/ends at |
---|
| 308 | !-- nzb+2 or nzt-1, respectively. |
---|
| 309 | DO k = 1, nzt_diff |
---|
| 310 | IF ( k >= nzb_diff_s_inner(j,i) ) THEN |
---|
[1320] | 311 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 312 | + 0.5_wp * ( & |
---|
[1320] | 313 | ( kh(k,j,i) + kh(k+1,j,i) ) * ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & |
---|
| 314 | - ( kh(k,j,i) + kh(k-1,j,i) ) * ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & |
---|
[1340] | 315 | ) * ddzw(k) |
---|
[1015] | 316 | ENDIF |
---|
| 317 | ENDDO |
---|
| 318 | |
---|
| 319 | ! |
---|
| 320 | !-- Vertical diffusion at the first computational gridpoint along |
---|
| 321 | !-- z-direction |
---|
| 322 | DO k = 1, nzt |
---|
| 323 | IF ( use_surface_fluxes .AND. k == nzb_s_inner(j,i)+1 ) THEN |
---|
[1320] | 324 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 325 | + ( 0.5_wp * ( kh(k,j,i)+kh(k+1,j,i) )& |
---|
| 326 | * ( s(k+1,j,i)-s(k,j,i) ) & |
---|
| 327 | * ddzu(k+1) & |
---|
[1320] | 328 | + s_flux_b(j,i) & |
---|
[1015] | 329 | ) * ddzw(k) |
---|
| 330 | ENDIF |
---|
| 331 | |
---|
| 332 | ! |
---|
| 333 | !-- Vertical diffusion at the last computational gridpoint along |
---|
| 334 | !-- z-direction |
---|
| 335 | IF ( use_top_fluxes .AND. k == nzt ) THEN |
---|
| 336 | tend(k,j,i) = tend(k,j,i) & |
---|
| 337 | + ( - s_flux_t(j,i) & |
---|
[1340] | 338 | - 0.5_wp * ( kh(k-1,j,i)+kh(k,j,i) )& |
---|
| 339 | * ( s(k,j,i)-s(k-1,j,i) ) & |
---|
| 340 | * ddzu(k) & |
---|
[1015] | 341 | ) * ddzw(k) |
---|
| 342 | ENDIF |
---|
| 343 | ENDDO |
---|
| 344 | |
---|
| 345 | ENDDO |
---|
| 346 | ENDDO |
---|
| 347 | !$acc end kernels |
---|
| 348 | |
---|
| 349 | END SUBROUTINE diffusion_s_acc |
---|
| 350 | |
---|
| 351 | |
---|
| 352 | !------------------------------------------------------------------------------! |
---|
[1682] | 353 | ! Description: |
---|
| 354 | ! ------------ |
---|
| 355 | !> Call for grid point i,j |
---|
[1] | 356 | !------------------------------------------------------------------------------! |
---|
[1001] | 357 | SUBROUTINE diffusion_s_ij( i, j, s, s_flux_b, s_flux_t, wall_s_flux ) |
---|
[1] | 358 | |
---|
[1320] | 359 | USE arrays_3d, & |
---|
| 360 | ONLY: ddzu, ddzw, kh, tend |
---|
| 361 | |
---|
| 362 | USE control_parameters, & |
---|
| 363 | ONLY: use_surface_fluxes, use_top_fluxes |
---|
| 364 | |
---|
| 365 | USE grid_variables, & |
---|
| 366 | ONLY: ddx2, ddy2, fwxm, fwxp, fwym, fwyp, wall_w_x, wall_w_y |
---|
| 367 | |
---|
| 368 | USE indices, & |
---|
[1374] | 369 | ONLY: nxlg, nxrg, nyng, nysg, nzb, nzb_diff_s_inner, nzb_s_inner, & |
---|
[1320] | 370 | nzb_s_outer, nzt, nzt_diff |
---|
| 371 | |
---|
| 372 | USE kinds |
---|
[1] | 373 | |
---|
| 374 | IMPLICIT NONE |
---|
| 375 | |
---|
[1682] | 376 | INTEGER(iwp) :: i !< |
---|
| 377 | INTEGER(iwp) :: j !< |
---|
| 378 | INTEGER(iwp) :: k !< |
---|
| 379 | REAL(wp) :: wall_s_flux(0:4) !< |
---|
| 380 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_b !< |
---|
| 381 | REAL(wp), DIMENSION(nysg:nyng,nxlg:nxrg) :: s_flux_t !< |
---|
[1010] | 382 | #if defined( __nopointer ) |
---|
[1682] | 383 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,nxlg:nxrg) :: s !< |
---|
[1010] | 384 | #else |
---|
[1682] | 385 | REAL(wp), DIMENSION(:,:,:), POINTER :: s !< |
---|
[1010] | 386 | #endif |
---|
[1] | 387 | |
---|
| 388 | ! |
---|
| 389 | !-- Compute horizontal diffusion |
---|
[19] | 390 | DO k = nzb_s_outer(j,i)+1, nzt |
---|
[1] | 391 | |
---|
[1320] | 392 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 393 | + 0.5_wp * ( & |
---|
[1320] | 394 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
| 395 | - ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
[1340] | 396 | ) * ddx2 & |
---|
| 397 | + 0.5_wp * ( & |
---|
[1320] | 398 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
| 399 | - ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
[1340] | 400 | ) * ddy2 |
---|
[1] | 401 | ENDDO |
---|
| 402 | |
---|
| 403 | ! |
---|
| 404 | !-- Apply prescribed horizontal wall heatflux where necessary |
---|
[1691] | 405 | IF ( ( wall_w_x(j,i) /= 0.0_wp ) .OR. ( wall_w_y(j,i) /= 0.0_wp ) ) & |
---|
[1] | 406 | THEN |
---|
| 407 | DO k = nzb_s_inner(j,i)+1, nzb_s_outer(j,i) |
---|
| 408 | |
---|
[1320] | 409 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 410 | + ( fwxp(j,i) * 0.5_wp * & |
---|
[1320] | 411 | ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) & |
---|
[1340] | 412 | + ( 1.0_wp - fwxp(j,i) ) * wall_s_flux(1) & |
---|
| 413 | -fwxm(j,i) * 0.5_wp * & |
---|
[1320] | 414 | ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) & |
---|
[1340] | 415 | + ( 1.0_wp - fwxm(j,i) ) * wall_s_flux(2) & |
---|
[1320] | 416 | ) * ddx2 & |
---|
[1340] | 417 | + ( fwyp(j,i) * 0.5_wp * & |
---|
[1320] | 418 | ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) & |
---|
[1340] | 419 | + ( 1.0_wp - fwyp(j,i) ) * wall_s_flux(3) & |
---|
| 420 | -fwym(j,i) * 0.5_wp * & |
---|
[1320] | 421 | ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) & |
---|
[1340] | 422 | + ( 1.0_wp - fwym(j,i) ) * wall_s_flux(4) & |
---|
[1] | 423 | ) * ddy2 |
---|
| 424 | ENDDO |
---|
| 425 | ENDIF |
---|
| 426 | |
---|
| 427 | ! |
---|
| 428 | !-- Compute vertical diffusion. In case that surface fluxes have been |
---|
[19] | 429 | !-- prescribed or computed at bottom and/or top, index k starts/ends at |
---|
| 430 | !-- nzb+2 or nzt-1, respectively. |
---|
| 431 | DO k = nzb_diff_s_inner(j,i), nzt_diff |
---|
[1] | 432 | |
---|
[1320] | 433 | tend(k,j,i) = tend(k,j,i) & |
---|
[1340] | 434 | + 0.5_wp * ( & |
---|
[1320] | 435 | ( kh(k,j,i) + kh(k+1,j,i) ) * ( s(k+1,j,i)-s(k,j,i) ) * ddzu(k+1) & |
---|
| 436 | - ( kh(k,j,i) + kh(k-1,j,i) ) * ( s(k,j,i)-s(k-1,j,i) ) * ddzu(k) & |
---|
[1340] | 437 | ) * ddzw(k) |
---|
[1] | 438 | ENDDO |
---|
| 439 | |
---|
| 440 | ! |
---|
[19] | 441 | !-- Vertical diffusion at the first computational gridpoint along z-direction |
---|
[1] | 442 | IF ( use_surface_fluxes ) THEN |
---|
| 443 | |
---|
| 444 | k = nzb_s_inner(j,i)+1 |
---|
| 445 | |
---|
[1340] | 446 | tend(k,j,i) = tend(k,j,i) + ( 0.5_wp * ( kh(k,j,i)+kh(k+1,j,i) ) & |
---|
| 447 | * ( s(k+1,j,i)-s(k,j,i) ) & |
---|
| 448 | * ddzu(k+1) & |
---|
[1320] | 449 | + s_flux_b(j,i) & |
---|
[19] | 450 | ) * ddzw(k) |
---|
[1] | 451 | |
---|
| 452 | ENDIF |
---|
| 453 | |
---|
[19] | 454 | ! |
---|
| 455 | !-- Vertical diffusion at the last computational gridpoint along z-direction |
---|
| 456 | IF ( use_top_fluxes ) THEN |
---|
| 457 | |
---|
| 458 | k = nzt |
---|
| 459 | |
---|
[1320] | 460 | tend(k,j,i) = tend(k,j,i) + ( - s_flux_t(j,i) & |
---|
[1340] | 461 | - 0.5_wp * ( kh(k-1,j,i)+kh(k,j,i) ) & |
---|
| 462 | * ( s(k,j,i)-s(k-1,j,i) ) & |
---|
| 463 | * ddzu(k) & |
---|
[19] | 464 | ) * ddzw(k) |
---|
| 465 | |
---|
| 466 | ENDIF |
---|
| 467 | |
---|
[1] | 468 | END SUBROUTINE diffusion_s_ij |
---|
| 469 | |
---|
| 470 | END MODULE diffusion_s_mod |
---|