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