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