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