[56] | 1 | MODULE wall_fluxes_mod |
---|
[1036] | 2 | |
---|
| 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 | ! |
---|
| 17 | ! Copyright 1997-2012 Leibniz University Hannover |
---|
| 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[52] | 21 | ! ----------------- |
---|
[198] | 22 | ! |
---|
[1154] | 23 | ! |
---|
[198] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: wall_fluxes.f90 1154 2013-05-10 14:43:15Z raasch $ |
---|
| 27 | ! |
---|
[1154] | 28 | ! 1153 2013-05-10 14:33:08Z raasch |
---|
| 29 | ! code adjustments of accelerator version required by PGI 12.3 / CUDA 5.0 |
---|
| 30 | ! |
---|
[1132] | 31 | ! 1128 2013-04-12 06:19:32Z raasch |
---|
| 32 | ! loop index bounds in accelerator version replaced by i_left, i_right, j_south, |
---|
| 33 | ! j_north |
---|
| 34 | ! |
---|
[1037] | 35 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 36 | ! code put under GPL (PALM 3.9) |
---|
| 37 | ! |
---|
[1017] | 38 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
| 39 | ! accelerator version (*_acc) added |
---|
| 40 | ! |
---|
[198] | 41 | ! 187 2008-08-06 16:25:09Z letzel |
---|
| 42 | ! Bugfix: Modification of the evaluation of the vertical turbulent momentum |
---|
| 43 | ! fluxes u'w' and v'w (see prandtl_fluxes), this requires the calculation of |
---|
| 44 | ! us_wall (and vel_total, u_i, v_i, ws) also in wall_fluxes_e. |
---|
| 45 | ! Bugfix: change definition of us_wall from 1D to 2D |
---|
[187] | 46 | ! Bugfix: storage of rifs to rifs_wall in wall_fluxes_e removed |
---|
| 47 | ! Change: add 'minus' sign to fluxes produced by subroutine wall_fluxes_e for |
---|
[198] | 48 | ! consistency with subroutine wall_fluxes |
---|
[187] | 49 | ! Change: Modification of the integrated version of the profile function for |
---|
[198] | 50 | ! momentum for unstable stratification |
---|
[52] | 51 | ! |
---|
| 52 | ! Initial version (2007/03/07) |
---|
| 53 | ! |
---|
| 54 | ! Description: |
---|
| 55 | ! ------------ |
---|
| 56 | ! Calculates momentum fluxes at vertical walls assuming Monin-Obukhov |
---|
| 57 | ! similarity. |
---|
| 58 | ! Indices: usvs a=1, vsus b=1, wsvs c1=1, wsus c2=1 (other=0). |
---|
[56] | 59 | ! The all-gridpoint version of wall_fluxes_e is not used so far, because |
---|
| 60 | ! it gives slightly different results from the ij-version for some unknown |
---|
| 61 | ! reason. |
---|
[52] | 62 | !------------------------------------------------------------------------------! |
---|
[56] | 63 | PRIVATE |
---|
[1015] | 64 | PUBLIC wall_fluxes, wall_fluxes_acc, wall_fluxes_e, wall_fluxes_e_acc |
---|
[56] | 65 | |
---|
| 66 | INTERFACE wall_fluxes |
---|
| 67 | MODULE PROCEDURE wall_fluxes |
---|
| 68 | MODULE PROCEDURE wall_fluxes_ij |
---|
| 69 | END INTERFACE wall_fluxes |
---|
| 70 | |
---|
[1015] | 71 | INTERFACE wall_fluxes_acc |
---|
| 72 | MODULE PROCEDURE wall_fluxes_acc |
---|
| 73 | END INTERFACE wall_fluxes_acc |
---|
| 74 | |
---|
[56] | 75 | INTERFACE wall_fluxes_e |
---|
| 76 | MODULE PROCEDURE wall_fluxes_e |
---|
| 77 | MODULE PROCEDURE wall_fluxes_e_ij |
---|
| 78 | END INTERFACE wall_fluxes_e |
---|
| 79 | |
---|
[1015] | 80 | INTERFACE wall_fluxes_e_acc |
---|
| 81 | MODULE PROCEDURE wall_fluxes_e_acc |
---|
| 82 | END INTERFACE wall_fluxes_e_acc |
---|
| 83 | |
---|
[56] | 84 | CONTAINS |
---|
[52] | 85 | |
---|
[56] | 86 | !------------------------------------------------------------------------------! |
---|
| 87 | ! Call for all grid points |
---|
| 88 | !------------------------------------------------------------------------------! |
---|
[75] | 89 | SUBROUTINE wall_fluxes( wall_flux, a, b, c1, c2, nzb_uvw_inner, & |
---|
[56] | 90 | nzb_uvw_outer, wall ) |
---|
[52] | 91 | |
---|
[56] | 92 | USE arrays_3d |
---|
| 93 | USE control_parameters |
---|
| 94 | USE grid_variables |
---|
| 95 | USE indices |
---|
| 96 | USE statistics |
---|
[52] | 97 | |
---|
[56] | 98 | IMPLICIT NONE |
---|
[52] | 99 | |
---|
[75] | 100 | INTEGER :: i, j, k, wall_index |
---|
[52] | 101 | |
---|
[667] | 102 | INTEGER, DIMENSION(nysg:nyng,nxlg:nxrg) :: nzb_uvw_inner, & |
---|
[56] | 103 | nzb_uvw_outer |
---|
| 104 | REAL :: a, b, c1, c2, h1, h2, zp |
---|
| 105 | REAL :: pts, pt_i, rifs, u_i, v_i, us_wall, vel_total, ws, wspts |
---|
[52] | 106 | |
---|
[667] | 107 | REAL, DIMENSION(nysg:nyng,nxlg:nxrg) :: wall |
---|
[75] | 108 | REAL, DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wall_flux |
---|
[52] | 109 | |
---|
| 110 | |
---|
[56] | 111 | zp = 0.5 * ( (a+c1) * dy + (b+c2) * dx ) |
---|
| 112 | wall_flux = 0.0 |
---|
| 113 | wall_index = NINT( a+ 2*b + 3*c1 + 4*c2 ) |
---|
| 114 | |
---|
[75] | 115 | DO i = nxl, nxr |
---|
| 116 | DO j = nys, nyn |
---|
[56] | 117 | |
---|
| 118 | IF ( wall(j,i) /= 0.0 ) THEN |
---|
[52] | 119 | ! |
---|
[56] | 120 | !-- All subsequent variables are computed for the respective |
---|
[187] | 121 | !-- location where the respective flux is defined. |
---|
[56] | 122 | DO k = nzb_uvw_inner(j,i)+1, nzb_uvw_outer(j,i) |
---|
[53] | 123 | |
---|
[52] | 124 | ! |
---|
[56] | 125 | !-- (1) Compute rifs, u_i, v_i, ws, pt' and w'pt' |
---|
| 126 | rifs = rif_wall(k,j,i,wall_index) |
---|
[53] | 127 | |
---|
[56] | 128 | u_i = a * u(k,j,i) + c1 * 0.25 * & |
---|
| 129 | ( u(k+1,j,i+1) + u(k+1,j,i) + u(k,j,i+1) + u(k,j,i) ) |
---|
[53] | 130 | |
---|
[56] | 131 | v_i = b * v(k,j,i) + c2 * 0.25 * & |
---|
| 132 | ( v(k+1,j+1,i) + v(k+1,j,i) + v(k,j+1,i) + v(k,j,i) ) |
---|
[53] | 133 | |
---|
[56] | 134 | ws = ( c1 + c2 ) * w(k,j,i) + 0.25 * ( & |
---|
| 135 | a * ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + w(k,j,i) ) & |
---|
| 136 | + b * ( w(k-1,j-1,i) + w(k-1,j,i) + w(k,j-1,i) + w(k,j,i) ) & |
---|
| 137 | ) |
---|
| 138 | pt_i = 0.5 * ( pt(k,j,i) + a * pt(k,j,i-1) + & |
---|
| 139 | b * pt(k,j-1,i) + ( c1 + c2 ) * pt(k+1,j,i) ) |
---|
[53] | 140 | |
---|
[56] | 141 | pts = pt_i - hom(k,1,4,0) |
---|
| 142 | wspts = ws * pts |
---|
[53] | 143 | |
---|
[52] | 144 | ! |
---|
[56] | 145 | !-- (2) Compute wall-parallel absolute velocity vel_total |
---|
| 146 | vel_total = SQRT( ws**2 + (a+c1) * u_i**2 + (b+c2) * v_i**2 ) |
---|
[53] | 147 | |
---|
[52] | 148 | ! |
---|
[56] | 149 | !-- (3) Compute wall friction velocity us_wall |
---|
| 150 | IF ( rifs >= 0.0 ) THEN |
---|
[53] | 151 | |
---|
[52] | 152 | ! |
---|
[56] | 153 | !-- Stable stratification (and neutral) |
---|
| 154 | us_wall = kappa * vel_total / ( LOG( zp / z0(j,i) ) + & |
---|
| 155 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 156 | ) |
---|
| 157 | ELSE |
---|
[53] | 158 | |
---|
[52] | 159 | ! |
---|
[56] | 160 | !-- Unstable stratification |
---|
[187] | 161 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 162 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
[53] | 163 | |
---|
[187] | 164 | us_wall = kappa * vel_total / ( & |
---|
| 165 | LOG( zp / z0(j,i) ) - & |
---|
| 166 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 167 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 168 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 169 | ) |
---|
[56] | 170 | ENDIF |
---|
[53] | 171 | |
---|
[52] | 172 | ! |
---|
[56] | 173 | !-- (4) Compute zp/L (corresponds to neutral Richardson flux |
---|
| 174 | !-- number rifs) |
---|
| 175 | rifs = -1.0 * zp * kappa * g * wspts / ( pt_i * & |
---|
| 176 | ( us_wall**3 + 1E-30 ) ) |
---|
[53] | 177 | |
---|
[52] | 178 | ! |
---|
[56] | 179 | !-- Limit the value range of the Richardson numbers. |
---|
| 180 | !-- This is necessary for very small velocities (u,w --> 0), |
---|
| 181 | !-- because the absolute value of rif can then become very |
---|
| 182 | !-- large, which in consequence would result in very large |
---|
| 183 | !-- shear stresses and very small momentum fluxes (both are |
---|
| 184 | !-- generally unrealistic). |
---|
| 185 | IF ( rifs < rif_min ) rifs = rif_min |
---|
| 186 | IF ( rifs > rif_max ) rifs = rif_max |
---|
[53] | 187 | |
---|
[52] | 188 | ! |
---|
[56] | 189 | !-- (5) Compute wall_flux (u'v', v'u', w'v', or w'u') |
---|
| 190 | IF ( rifs >= 0.0 ) THEN |
---|
[53] | 191 | |
---|
[52] | 192 | ! |
---|
[56] | 193 | !-- Stable stratification (and neutral) |
---|
| 194 | wall_flux(k,j,i) = kappa * & |
---|
| 195 | ( a*u(k,j,i) + b*v(k,j,i) + (c1+c2)*w(k,j,i) ) / & |
---|
| 196 | ( LOG( zp / z0(j,i) ) + & |
---|
| 197 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 198 | ) |
---|
| 199 | ELSE |
---|
[53] | 200 | |
---|
[52] | 201 | ! |
---|
[56] | 202 | !-- Unstable stratification |
---|
[187] | 203 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 204 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
[53] | 205 | |
---|
[187] | 206 | wall_flux(k,j,i) = kappa * & |
---|
| 207 | ( a*u(k,j,i) + b*v(k,j,i) + (c1+c2)*w(k,j,i) ) / ( & |
---|
| 208 | LOG( zp / z0(j,i) ) - & |
---|
| 209 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 210 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 211 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 212 | ) |
---|
[56] | 213 | ENDIF |
---|
[187] | 214 | wall_flux(k,j,i) = -wall_flux(k,j,i) * us_wall |
---|
[56] | 215 | |
---|
| 216 | ! |
---|
| 217 | !-- store rifs for next time step |
---|
| 218 | rif_wall(k,j,i,wall_index) = rifs |
---|
| 219 | |
---|
| 220 | ENDDO |
---|
| 221 | |
---|
| 222 | ENDIF |
---|
| 223 | |
---|
| 224 | ENDDO |
---|
| 225 | ENDDO |
---|
| 226 | |
---|
| 227 | END SUBROUTINE wall_fluxes |
---|
| 228 | |
---|
| 229 | |
---|
[1015] | 230 | !------------------------------------------------------------------------------! |
---|
| 231 | ! Call for all grid points - accelerator version |
---|
| 232 | !------------------------------------------------------------------------------! |
---|
| 233 | SUBROUTINE wall_fluxes_acc( wall_flux, a, b, c1, c2, nzb_uvw_inner, & |
---|
| 234 | nzb_uvw_outer, wall ) |
---|
[56] | 235 | |
---|
[1015] | 236 | USE arrays_3d |
---|
| 237 | USE control_parameters |
---|
| 238 | USE grid_variables |
---|
| 239 | USE indices |
---|
| 240 | USE statistics |
---|
| 241 | |
---|
| 242 | IMPLICIT NONE |
---|
| 243 | |
---|
| 244 | INTEGER :: i, j, k, max_outer, min_inner, wall_index |
---|
| 245 | |
---|
| 246 | INTEGER, DIMENSION(nysg:nyng,nxlg:nxrg) :: nzb_uvw_inner, & |
---|
| 247 | nzb_uvw_outer |
---|
| 248 | REAL :: a, b, c1, c2, h1, h2, zp |
---|
| 249 | REAL :: pts, pt_i, rifs, u_i, v_i, us_wall, vel_total, ws, wspts |
---|
| 250 | |
---|
| 251 | REAL, DIMENSION(nysg:nyng,nxlg:nxrg) :: wall |
---|
| 252 | REAL, DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wall_flux |
---|
| 253 | |
---|
| 254 | |
---|
| 255 | zp = 0.5 * ( (a+c1) * dy + (b+c2) * dx ) |
---|
| 256 | wall_flux = 0.0 |
---|
| 257 | wall_index = NINT( a+ 2*b + 3*c1 + 4*c2 ) |
---|
| 258 | |
---|
| 259 | min_inner = MINVAL( nzb_uvw_inner(nys:nyn,nxl:nxr) ) + 1 |
---|
| 260 | max_outer = MINVAL( nzb_uvw_outer(nys:nyn,nxl:nxr) ) |
---|
| 261 | |
---|
| 262 | !$acc kernels present( hom, nzb_uvw_inner, nzb_uvw_outer, pt, rif_wall ) & |
---|
| 263 | !$acc present( u, v, w, wall, wall_flux, z0 ) |
---|
[1153] | 264 | !$acc loop independent |
---|
[1128] | 265 | DO i = i_left, i_right |
---|
| 266 | DO j = j_south, j_north |
---|
[1153] | 267 | |
---|
| 268 | IF ( wall(j,i) /= 0.0 ) THEN |
---|
[1015] | 269 | ! |
---|
| 270 | !-- All subsequent variables are computed for the respective |
---|
| 271 | !-- location where the respective flux is defined. |
---|
[1153] | 272 | !$acc loop independent vector( 32 ) |
---|
| 273 | DO k = nzb_uvw_inner(j,i)+1, nzb_uvw_outer(j,i) |
---|
| 274 | |
---|
[1015] | 275 | ! |
---|
| 276 | !-- (1) Compute rifs, u_i, v_i, ws, pt' and w'pt' |
---|
| 277 | rifs = rif_wall(k,j,i,wall_index) |
---|
| 278 | |
---|
| 279 | u_i = a * u(k,j,i) + c1 * 0.25 * & |
---|
| 280 | ( u(k+1,j,i+1) + u(k+1,j,i) + u(k,j,i+1) + u(k,j,i) ) |
---|
| 281 | |
---|
| 282 | v_i = b * v(k,j,i) + c2 * 0.25 * & |
---|
| 283 | ( v(k+1,j+1,i) + v(k+1,j,i) + v(k,j+1,i) + v(k,j,i) ) |
---|
| 284 | |
---|
| 285 | ws = ( c1 + c2 ) * w(k,j,i) + 0.25 * ( & |
---|
| 286 | a * ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + w(k,j,i) ) & |
---|
| 287 | + b * ( w(k-1,j-1,i) + w(k-1,j,i) + w(k,j-1,i) + w(k,j,i) ) & |
---|
| 288 | ) |
---|
| 289 | pt_i = 0.5 * ( pt(k,j,i) + a * pt(k,j,i-1) + & |
---|
| 290 | b * pt(k,j-1,i) + ( c1 + c2 ) * pt(k+1,j,i) ) |
---|
| 291 | |
---|
| 292 | pts = pt_i - hom(k,1,4,0) |
---|
| 293 | wspts = ws * pts |
---|
| 294 | |
---|
| 295 | ! |
---|
| 296 | !-- (2) Compute wall-parallel absolute velocity vel_total |
---|
| 297 | vel_total = SQRT( ws**2 + (a+c1) * u_i**2 + (b+c2) * v_i**2 ) |
---|
| 298 | |
---|
| 299 | ! |
---|
| 300 | !-- (3) Compute wall friction velocity us_wall |
---|
| 301 | IF ( rifs >= 0.0 ) THEN |
---|
| 302 | |
---|
| 303 | ! |
---|
| 304 | !-- Stable stratification (and neutral) |
---|
| 305 | us_wall = kappa * vel_total / ( LOG( zp / z0(j,i) ) + & |
---|
| 306 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 307 | ) |
---|
| 308 | ELSE |
---|
| 309 | |
---|
| 310 | ! |
---|
| 311 | !-- Unstable stratification |
---|
| 312 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 313 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
| 314 | |
---|
| 315 | us_wall = kappa * vel_total / ( & |
---|
| 316 | LOG( zp / z0(j,i) ) - & |
---|
| 317 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 318 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 319 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 320 | ) |
---|
| 321 | ENDIF |
---|
| 322 | |
---|
| 323 | ! |
---|
| 324 | !-- (4) Compute zp/L (corresponds to neutral Richardson flux |
---|
| 325 | !-- number rifs) |
---|
| 326 | rifs = -1.0 * zp * kappa * g * wspts / ( pt_i * & |
---|
| 327 | ( us_wall**3 + 1E-30 ) ) |
---|
| 328 | |
---|
| 329 | ! |
---|
| 330 | !-- Limit the value range of the Richardson numbers. |
---|
| 331 | !-- This is necessary for very small velocities (u,w --> 0), |
---|
| 332 | !-- because the absolute value of rif can then become very |
---|
| 333 | !-- large, which in consequence would result in very large |
---|
| 334 | !-- shear stresses and very small momentum fluxes (both are |
---|
| 335 | !-- generally unrealistic). |
---|
| 336 | IF ( rifs < rif_min ) rifs = rif_min |
---|
| 337 | IF ( rifs > rif_max ) rifs = rif_max |
---|
| 338 | |
---|
| 339 | ! |
---|
| 340 | !-- (5) Compute wall_flux (u'v', v'u', w'v', or w'u') |
---|
| 341 | IF ( rifs >= 0.0 ) THEN |
---|
| 342 | |
---|
| 343 | ! |
---|
| 344 | !-- Stable stratification (and neutral) |
---|
| 345 | wall_flux(k,j,i) = kappa * & |
---|
| 346 | ( a*u(k,j,i) + b*v(k,j,i) + (c1+c2)*w(k,j,i) ) / & |
---|
| 347 | ( LOG( zp / z0(j,i) ) + & |
---|
| 348 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 349 | ) |
---|
| 350 | ELSE |
---|
| 351 | |
---|
| 352 | ! |
---|
| 353 | !-- Unstable stratification |
---|
| 354 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 355 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
| 356 | |
---|
| 357 | wall_flux(k,j,i) = kappa * & |
---|
| 358 | ( a*u(k,j,i) + b*v(k,j,i) + (c1+c2)*w(k,j,i) ) / ( & |
---|
| 359 | LOG( zp / z0(j,i) ) - & |
---|
| 360 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 361 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 362 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 363 | ) |
---|
| 364 | ENDIF |
---|
| 365 | wall_flux(k,j,i) = -wall_flux(k,j,i) * us_wall |
---|
| 366 | |
---|
| 367 | ! |
---|
| 368 | !-- store rifs for next time step |
---|
| 369 | rif_wall(k,j,i,wall_index) = rifs |
---|
| 370 | |
---|
[1153] | 371 | ! ENDIF |
---|
[1015] | 372 | |
---|
[1153] | 373 | ENDDO |
---|
| 374 | |
---|
| 375 | ENDIF |
---|
| 376 | |
---|
[1015] | 377 | ENDDO |
---|
| 378 | ENDDO |
---|
| 379 | !$acc end kernels |
---|
| 380 | |
---|
| 381 | END SUBROUTINE wall_fluxes_acc |
---|
| 382 | |
---|
| 383 | |
---|
[56] | 384 | !------------------------------------------------------------------------------! |
---|
| 385 | ! Call for all grid point i,j |
---|
| 386 | !------------------------------------------------------------------------------! |
---|
| 387 | SUBROUTINE wall_fluxes_ij( i, j, nzb_w, nzt_w, wall_flux, a, b, c1, c2 ) |
---|
| 388 | |
---|
| 389 | USE arrays_3d |
---|
| 390 | USE control_parameters |
---|
| 391 | USE grid_variables |
---|
| 392 | USE indices |
---|
| 393 | USE statistics |
---|
| 394 | |
---|
| 395 | IMPLICIT NONE |
---|
| 396 | |
---|
| 397 | INTEGER :: i, j, k, nzb_w, nzt_w, wall_index |
---|
| 398 | REAL :: a, b, c1, c2, h1, h2, zp |
---|
| 399 | |
---|
| 400 | REAL :: pts, pt_i, rifs, u_i, v_i, us_wall, vel_total, ws, wspts |
---|
| 401 | |
---|
| 402 | REAL, DIMENSION(nzb:nzt+1) :: wall_flux |
---|
| 403 | |
---|
| 404 | |
---|
| 405 | zp = 0.5 * ( (a+c1) * dy + (b+c2) * dx ) |
---|
| 406 | wall_flux = 0.0 |
---|
| 407 | wall_index = NINT( a+ 2*b + 3*c1 + 4*c2 ) |
---|
| 408 | |
---|
| 409 | ! |
---|
| 410 | !-- All subsequent variables are computed for the respective location where |
---|
[187] | 411 | !-- the respective flux is defined. |
---|
[56] | 412 | DO k = nzb_w, nzt_w |
---|
| 413 | |
---|
| 414 | ! |
---|
| 415 | !-- (1) Compute rifs, u_i, v_i, ws, pt' and w'pt' |
---|
| 416 | rifs = rif_wall(k,j,i,wall_index) |
---|
| 417 | |
---|
| 418 | u_i = a * u(k,j,i) + c1 * 0.25 * & |
---|
| 419 | ( u(k+1,j,i+1) + u(k+1,j,i) + u(k,j,i+1) + u(k,j,i) ) |
---|
| 420 | |
---|
| 421 | v_i = b * v(k,j,i) + c2 * 0.25 * & |
---|
| 422 | ( v(k+1,j+1,i) + v(k+1,j,i) + v(k,j+1,i) + v(k,j,i) ) |
---|
| 423 | |
---|
| 424 | ws = ( c1 + c2 ) * w(k,j,i) + 0.25 * ( & |
---|
| 425 | a * ( w(k-1,j,i-1) + w(k-1,j,i) + w(k,j,i-1) + w(k,j,i) ) & |
---|
| 426 | + b * ( w(k-1,j-1,i) + w(k-1,j,i) + w(k,j-1,i) + w(k,j,i) ) & |
---|
| 427 | ) |
---|
| 428 | pt_i = 0.5 * ( pt(k,j,i) + a * pt(k,j,i-1) + b * pt(k,j-1,i) & |
---|
| 429 | + ( c1 + c2 ) * pt(k+1,j,i) ) |
---|
| 430 | |
---|
| 431 | pts = pt_i - hom(k,1,4,0) |
---|
| 432 | wspts = ws * pts |
---|
| 433 | |
---|
| 434 | ! |
---|
| 435 | !-- (2) Compute wall-parallel absolute velocity vel_total |
---|
| 436 | vel_total = SQRT( ws**2 + ( a+c1 ) * u_i**2 + ( b+c2 ) * v_i**2 ) |
---|
| 437 | |
---|
| 438 | ! |
---|
| 439 | !-- (3) Compute wall friction velocity us_wall |
---|
| 440 | IF ( rifs >= 0.0 ) THEN |
---|
| 441 | |
---|
| 442 | ! |
---|
| 443 | !-- Stable stratification (and neutral) |
---|
| 444 | us_wall = kappa * vel_total / ( LOG( zp / z0(j,i) ) + & |
---|
| 445 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 446 | ) |
---|
| 447 | ELSE |
---|
| 448 | |
---|
| 449 | ! |
---|
| 450 | !-- Unstable stratification |
---|
[187] | 451 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 452 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
[56] | 453 | |
---|
[187] | 454 | us_wall = kappa * vel_total / ( & |
---|
| 455 | LOG( zp / z0(j,i) ) - & |
---|
| 456 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 457 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 458 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 459 | ) |
---|
[56] | 460 | ENDIF |
---|
| 461 | |
---|
| 462 | ! |
---|
| 463 | !-- (4) Compute zp/L (corresponds to neutral Richardson flux number |
---|
| 464 | !-- rifs) |
---|
| 465 | rifs = -1.0 * zp * kappa * g * wspts / ( pt_i * (us_wall**3 + 1E-30) ) |
---|
| 466 | |
---|
| 467 | ! |
---|
| 468 | !-- Limit the value range of the Richardson numbers. |
---|
| 469 | !-- This is necessary for very small velocities (u,w --> 0), because |
---|
| 470 | !-- the absolute value of rif can then become very large, which in |
---|
| 471 | !-- consequence would result in very large shear stresses and very |
---|
| 472 | !-- small momentum fluxes (both are generally unrealistic). |
---|
| 473 | IF ( rifs < rif_min ) rifs = rif_min |
---|
| 474 | IF ( rifs > rif_max ) rifs = rif_max |
---|
| 475 | |
---|
| 476 | ! |
---|
| 477 | !-- (5) Compute wall_flux (u'v', v'u', w'v', or w'u') |
---|
| 478 | IF ( rifs >= 0.0 ) THEN |
---|
| 479 | |
---|
| 480 | ! |
---|
| 481 | !-- Stable stratification (and neutral) |
---|
[53] | 482 | wall_flux(k) = kappa * & |
---|
| 483 | ( a*u(k,j,i) + b*v(k,j,i) + (c1+c2)*w(k,j,i) ) / & |
---|
[56] | 484 | ( LOG( zp / z0(j,i) ) + & |
---|
| 485 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
[53] | 486 | ) |
---|
[52] | 487 | ELSE |
---|
[53] | 488 | |
---|
[56] | 489 | ! |
---|
| 490 | !-- Unstable stratification |
---|
[187] | 491 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 492 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
[52] | 493 | |
---|
[187] | 494 | wall_flux(k) = kappa * & |
---|
| 495 | ( a*u(k,j,i) + b*v(k,j,i) + (c1+c2)*w(k,j,i) ) / ( & |
---|
| 496 | LOG( zp / z0(j,i) ) - & |
---|
| 497 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 498 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 499 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 500 | ) |
---|
[56] | 501 | ENDIF |
---|
[187] | 502 | wall_flux(k) = -wall_flux(k) * us_wall |
---|
[53] | 503 | |
---|
[56] | 504 | ! |
---|
| 505 | !-- store rifs for next time step |
---|
| 506 | rif_wall(k,j,i,wall_index) = rifs |
---|
[53] | 507 | |
---|
[56] | 508 | ENDDO |
---|
[53] | 509 | |
---|
[56] | 510 | END SUBROUTINE wall_fluxes_ij |
---|
[53] | 511 | |
---|
[56] | 512 | |
---|
| 513 | |
---|
[53] | 514 | !------------------------------------------------------------------------------! |
---|
[56] | 515 | ! Call for all grid points |
---|
| 516 | !------------------------------------------------------------------------------! |
---|
| 517 | SUBROUTINE wall_fluxes_e( wall_flux, a, b, c1, c2, wall ) |
---|
| 518 | |
---|
| 519 | !------------------------------------------------------------------------------! |
---|
[53] | 520 | ! Description: |
---|
| 521 | ! ------------ |
---|
| 522 | ! Calculates momentum fluxes at vertical walls for routine production_e |
---|
| 523 | ! assuming Monin-Obukhov similarity. |
---|
| 524 | ! Indices: usvs a=1, vsus b=1, wsvs c1=1, wsus c2=1 (other=0). |
---|
| 525 | !------------------------------------------------------------------------------! |
---|
| 526 | |
---|
[56] | 527 | USE arrays_3d |
---|
| 528 | USE control_parameters |
---|
| 529 | USE grid_variables |
---|
| 530 | USE indices |
---|
| 531 | USE statistics |
---|
[53] | 532 | |
---|
[56] | 533 | IMPLICIT NONE |
---|
[53] | 534 | |
---|
[56] | 535 | INTEGER :: i, j, k, kk, wall_index |
---|
[187] | 536 | REAL :: a, b, c1, c2, h1, h2, u_i, v_i, us_wall, vel_total, vel_zp, & |
---|
| 537 | ws, zp |
---|
[53] | 538 | |
---|
[56] | 539 | REAL :: rifs |
---|
[53] | 540 | |
---|
[667] | 541 | REAL, DIMENSION(nysg:nyng,nxlg:nxrg) :: wall |
---|
[56] | 542 | REAL, DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wall_flux |
---|
[53] | 543 | |
---|
| 544 | |
---|
[56] | 545 | zp = 0.5 * ( (a+c1) * dy + (b+c2) * dx ) |
---|
| 546 | wall_flux = 0.0 |
---|
| 547 | wall_index = NINT( a+ 2*b + 3*c1 + 4*c2 ) |
---|
[53] | 548 | |
---|
[56] | 549 | DO i = nxl, nxr |
---|
| 550 | DO j = nys, nyn |
---|
| 551 | |
---|
| 552 | IF ( wall(j,i) /= 0.0 ) THEN |
---|
[53] | 553 | ! |
---|
[187] | 554 | !-- All subsequent variables are computed for scalar locations. |
---|
[56] | 555 | DO k = nzb_diff_s_inner(j,i)-1, nzb_diff_s_outer(j,i)-2 |
---|
[53] | 556 | ! |
---|
[187] | 557 | !-- (1) Compute rifs, u_i, v_i, and ws |
---|
[56] | 558 | IF ( k == nzb_diff_s_inner(j,i)-1 ) THEN |
---|
| 559 | kk = nzb_diff_s_inner(j,i)-1 |
---|
| 560 | ELSE |
---|
| 561 | kk = k-1 |
---|
| 562 | ENDIF |
---|
| 563 | rifs = 0.5 * ( rif_wall(k,j,i,wall_index) + & |
---|
| 564 | a * rif_wall(k,j,i+1,1) + b * rif_wall(k,j+1,i,2) + & |
---|
| 565 | c1 * rif_wall(kk,j,i,3) + c2 * rif_wall(kk,j,i,4) & |
---|
| 566 | ) |
---|
[53] | 567 | |
---|
[187] | 568 | u_i = 0.5 * ( u(k,j,i) + u(k,j,i+1) ) |
---|
| 569 | v_i = 0.5 * ( v(k,j,i) + v(k,j+1,i) ) |
---|
| 570 | ws = 0.5 * ( w(k,j,i) + w(k-1,j,i) ) |
---|
[53] | 571 | ! |
---|
[187] | 572 | !-- (2) Compute wall-parallel absolute velocity vel_total and |
---|
| 573 | !-- interpolate appropriate velocity component vel_zp. |
---|
| 574 | vel_total = SQRT( ws**2 + (a+c1) * u_i**2 + (b+c2) * v_i**2 ) |
---|
| 575 | vel_zp = 0.5 * ( a * u_i + b * v_i + (c1+c2) * ws ) |
---|
| 576 | ! |
---|
| 577 | !-- (3) Compute wall friction velocity us_wall |
---|
| 578 | IF ( rifs >= 0.0 ) THEN |
---|
[53] | 579 | |
---|
| 580 | ! |
---|
[187] | 581 | !-- Stable stratification (and neutral) |
---|
| 582 | us_wall = kappa * vel_total / ( LOG( zp / z0(j,i) ) + & |
---|
| 583 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 584 | ) |
---|
| 585 | ELSE |
---|
| 586 | |
---|
| 587 | ! |
---|
| 588 | !-- Unstable stratification |
---|
| 589 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 590 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
| 591 | |
---|
| 592 | us_wall = kappa * vel_total / ( & |
---|
| 593 | LOG( zp / z0(j,i) ) - & |
---|
| 594 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 595 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 596 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 597 | ) |
---|
| 598 | ENDIF |
---|
| 599 | |
---|
| 600 | ! |
---|
| 601 | !-- Skip step (4) of wall_fluxes, because here rifs is already |
---|
| 602 | !-- available from (1) |
---|
| 603 | ! |
---|
[56] | 604 | !-- (5) Compute wall_flux (u'v', v'u', w'v', or w'u') |
---|
[55] | 605 | |
---|
[56] | 606 | IF ( rifs >= 0.0 ) THEN |
---|
[53] | 607 | |
---|
| 608 | ! |
---|
[56] | 609 | !-- Stable stratification (and neutral) |
---|
| 610 | wall_flux(k,j,i) = kappa * vel_zp / & |
---|
| 611 | ( LOG( zp/z0(j,i) ) + 5.0*rifs * ( zp-z0(j,i) ) / zp ) |
---|
| 612 | ELSE |
---|
[53] | 613 | |
---|
| 614 | ! |
---|
[56] | 615 | !-- Unstable stratification |
---|
[187] | 616 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 617 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
[53] | 618 | |
---|
[187] | 619 | wall_flux(k,j,i) = kappa * vel_zp / ( & |
---|
| 620 | LOG( zp / z0(j,i) ) - & |
---|
| 621 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 622 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 623 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 624 | ) |
---|
[56] | 625 | ENDIF |
---|
[187] | 626 | wall_flux(k,j,i) = - wall_flux(k,j,i) * us_wall |
---|
[56] | 627 | |
---|
| 628 | ENDDO |
---|
| 629 | |
---|
| 630 | ENDIF |
---|
| 631 | |
---|
| 632 | ENDDO |
---|
| 633 | ENDDO |
---|
| 634 | |
---|
| 635 | END SUBROUTINE wall_fluxes_e |
---|
| 636 | |
---|
| 637 | |
---|
[1015] | 638 | !------------------------------------------------------------------------------! |
---|
| 639 | ! Call for all grid points - accelerator version |
---|
| 640 | !------------------------------------------------------------------------------! |
---|
| 641 | SUBROUTINE wall_fluxes_e_acc( wall_flux, a, b, c1, c2, wall ) |
---|
[56] | 642 | |
---|
| 643 | !------------------------------------------------------------------------------! |
---|
[1015] | 644 | ! Description: |
---|
| 645 | ! ------------ |
---|
| 646 | ! Calculates momentum fluxes at vertical walls for routine production_e |
---|
| 647 | ! assuming Monin-Obukhov similarity. |
---|
| 648 | ! Indices: usvs a=1, vsus b=1, wsvs c1=1, wsus c2=1 (other=0). |
---|
| 649 | !------------------------------------------------------------------------------! |
---|
| 650 | |
---|
| 651 | USE arrays_3d |
---|
| 652 | USE control_parameters |
---|
| 653 | USE grid_variables |
---|
| 654 | USE indices |
---|
| 655 | USE statistics |
---|
| 656 | |
---|
| 657 | IMPLICIT NONE |
---|
| 658 | |
---|
| 659 | INTEGER :: i, j, k, kk, max_outer, min_inner, wall_index |
---|
| 660 | REAL :: a, b, c1, c2, h1, h2, u_i, v_i, us_wall, vel_total, vel_zp, & |
---|
| 661 | ws, zp |
---|
| 662 | |
---|
| 663 | REAL :: rifs |
---|
| 664 | |
---|
| 665 | REAL, DIMENSION(nysg:nyng,nxlg:nxrg) :: wall |
---|
| 666 | REAL, DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: wall_flux |
---|
| 667 | |
---|
| 668 | |
---|
| 669 | zp = 0.5 * ( (a+c1) * dy + (b+c2) * dx ) |
---|
| 670 | wall_flux = 0.0 |
---|
| 671 | wall_index = NINT( a+ 2*b + 3*c1 + 4*c2 ) |
---|
| 672 | |
---|
| 673 | min_inner = MINVAL( nzb_diff_s_inner(nys:nyn,nxl:nxr) ) - 1 |
---|
| 674 | max_outer = MAXVAL( nzb_diff_s_outer(nys:nyn,nxl:nxr) ) - 2 |
---|
| 675 | |
---|
| 676 | !$acc kernels present( nzb_diff_s_inner, nzb_diff_s_outer, pt, rif_wall ) & |
---|
| 677 | !$acc present( u, v, w, wall, wall_flux, z0 ) |
---|
| 678 | !$acc loop |
---|
[1128] | 679 | DO i = i_left, i_right |
---|
| 680 | DO j = j_south, j_north |
---|
[1015] | 681 | !$acc loop vector(32) |
---|
| 682 | DO k = min_inner, max_outer |
---|
| 683 | ! |
---|
| 684 | !-- All subsequent variables are computed for scalar locations |
---|
| 685 | IF ( k >= nzb_diff_s_inner(j,i)-1 .AND. & |
---|
| 686 | k <= nzb_diff_s_outer(j,i)-2 .AND. wall(j,i) /= 0.0 ) THEN |
---|
| 687 | ! |
---|
| 688 | !-- (1) Compute rifs, u_i, v_i, and ws |
---|
| 689 | IF ( k == nzb_diff_s_inner(j,i)-1 ) THEN |
---|
| 690 | kk = nzb_diff_s_inner(j,i)-1 |
---|
| 691 | ELSE |
---|
| 692 | kk = k-1 |
---|
| 693 | ENDIF |
---|
| 694 | rifs = 0.5 * ( rif_wall(k,j,i,wall_index) + & |
---|
| 695 | a * rif_wall(k,j,i+1,1) + b * rif_wall(k,j+1,i,2) + & |
---|
| 696 | c1 * rif_wall(kk,j,i,3) + c2 * rif_wall(kk,j,i,4) & |
---|
| 697 | ) |
---|
| 698 | |
---|
| 699 | u_i = 0.5 * ( u(k,j,i) + u(k,j,i+1) ) |
---|
| 700 | v_i = 0.5 * ( v(k,j,i) + v(k,j+1,i) ) |
---|
| 701 | ws = 0.5 * ( w(k,j,i) + w(k-1,j,i) ) |
---|
| 702 | ! |
---|
| 703 | !-- (2) Compute wall-parallel absolute velocity vel_total and |
---|
| 704 | !-- interpolate appropriate velocity component vel_zp. |
---|
| 705 | vel_total = SQRT( ws**2 + (a+c1) * u_i**2 + (b+c2) * v_i**2 ) |
---|
| 706 | vel_zp = 0.5 * ( a * u_i + b * v_i + (c1+c2) * ws ) |
---|
| 707 | ! |
---|
| 708 | !-- (3) Compute wall friction velocity us_wall |
---|
| 709 | IF ( rifs >= 0.0 ) THEN |
---|
| 710 | |
---|
| 711 | ! |
---|
| 712 | !-- Stable stratification (and neutral) |
---|
| 713 | us_wall = kappa * vel_total / ( LOG( zp / z0(j,i) ) + & |
---|
| 714 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 715 | ) |
---|
| 716 | ELSE |
---|
| 717 | |
---|
| 718 | ! |
---|
| 719 | !-- Unstable stratification |
---|
| 720 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 721 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
| 722 | |
---|
| 723 | us_wall = kappa * vel_total / ( & |
---|
| 724 | LOG( zp / z0(j,i) ) - & |
---|
| 725 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 726 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 727 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 728 | ) |
---|
| 729 | ENDIF |
---|
| 730 | |
---|
| 731 | ! |
---|
| 732 | !-- Skip step (4) of wall_fluxes, because here rifs is already |
---|
| 733 | !-- available from (1) |
---|
| 734 | ! |
---|
| 735 | !-- (5) Compute wall_flux (u'v', v'u', w'v', or w'u') |
---|
| 736 | |
---|
| 737 | IF ( rifs >= 0.0 ) THEN |
---|
| 738 | |
---|
| 739 | ! |
---|
| 740 | !-- Stable stratification (and neutral) |
---|
| 741 | wall_flux(k,j,i) = kappa * vel_zp / & |
---|
| 742 | ( LOG( zp/z0(j,i) ) + 5.0*rifs * ( zp-z0(j,i) ) / zp ) |
---|
| 743 | ELSE |
---|
| 744 | |
---|
| 745 | ! |
---|
| 746 | !-- Unstable stratification |
---|
| 747 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 748 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
| 749 | |
---|
| 750 | wall_flux(k,j,i) = kappa * vel_zp / ( & |
---|
| 751 | LOG( zp / z0(j,i) ) - & |
---|
| 752 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 753 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 754 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 755 | ) |
---|
| 756 | ENDIF |
---|
| 757 | wall_flux(k,j,i) = - wall_flux(k,j,i) * us_wall |
---|
| 758 | |
---|
| 759 | ENDIF |
---|
| 760 | |
---|
| 761 | ENDDO |
---|
| 762 | ENDDO |
---|
| 763 | ENDDO |
---|
| 764 | !$acc end kernels |
---|
| 765 | |
---|
| 766 | END SUBROUTINE wall_fluxes_e_acc |
---|
| 767 | |
---|
| 768 | |
---|
| 769 | !------------------------------------------------------------------------------! |
---|
[56] | 770 | ! Call for grid point i,j |
---|
| 771 | !------------------------------------------------------------------------------! |
---|
| 772 | SUBROUTINE wall_fluxes_e_ij( i, j, nzb_w, nzt_w, wall_flux, a, b, c1, c2 ) |
---|
| 773 | |
---|
| 774 | USE arrays_3d |
---|
| 775 | USE control_parameters |
---|
| 776 | USE grid_variables |
---|
| 777 | USE indices |
---|
| 778 | USE statistics |
---|
| 779 | |
---|
| 780 | IMPLICIT NONE |
---|
| 781 | |
---|
| 782 | INTEGER :: i, j, k, kk, nzb_w, nzt_w, wall_index |
---|
[187] | 783 | REAL :: a, b, c1, c2, h1, h2, u_i, v_i, us_wall, vel_total, vel_zp, & |
---|
| 784 | ws, zp |
---|
[56] | 785 | |
---|
| 786 | REAL :: rifs |
---|
| 787 | |
---|
| 788 | REAL, DIMENSION(nzb:nzt+1) :: wall_flux |
---|
| 789 | |
---|
| 790 | |
---|
| 791 | zp = 0.5 * ( (a+c1) * dy + (b+c2) * dx ) |
---|
| 792 | wall_flux = 0.0 |
---|
| 793 | wall_index = NINT( a+ 2*b + 3*c1 + 4*c2 ) |
---|
| 794 | |
---|
| 795 | ! |
---|
[187] | 796 | !-- All subsequent variables are computed for scalar locations. |
---|
[56] | 797 | DO k = nzb_w, nzt_w |
---|
| 798 | |
---|
| 799 | ! |
---|
[187] | 800 | !-- (1) Compute rifs, u_i, v_i, and ws |
---|
[56] | 801 | IF ( k == nzb_w ) THEN |
---|
| 802 | kk = nzb_w |
---|
[53] | 803 | ELSE |
---|
[56] | 804 | kk = k-1 |
---|
| 805 | ENDIF |
---|
| 806 | rifs = 0.5 * ( rif_wall(k,j,i,wall_index) + & |
---|
| 807 | a * rif_wall(k,j,i+1,1) + b * rif_wall(k,j+1,i,2) + & |
---|
| 808 | c1 * rif_wall(kk,j,i,3) + c2 * rif_wall(kk,j,i,4) & |
---|
| 809 | ) |
---|
| 810 | |
---|
[187] | 811 | u_i = 0.5 * ( u(k,j,i) + u(k,j,i+1) ) |
---|
| 812 | v_i = 0.5 * ( v(k,j,i) + v(k,j+1,i) ) |
---|
| 813 | ws = 0.5 * ( w(k,j,i) + w(k-1,j,i) ) |
---|
[56] | 814 | ! |
---|
[187] | 815 | !-- (2) Compute wall-parallel absolute velocity vel_total and |
---|
| 816 | !-- interpolate appropriate velocity component vel_zp. |
---|
| 817 | vel_total = SQRT( ws**2 + (a+c1) * u_i**2 + (b+c2) * v_i**2 ) |
---|
| 818 | vel_zp = 0.5 * ( a * u_i + b * v_i + (c1+c2) * ws ) |
---|
| 819 | ! |
---|
| 820 | !-- (3) Compute wall friction velocity us_wall |
---|
| 821 | IF ( rifs >= 0.0 ) THEN |
---|
[56] | 822 | |
---|
| 823 | ! |
---|
[187] | 824 | !-- Stable stratification (and neutral) |
---|
| 825 | us_wall = kappa * vel_total / ( LOG( zp / z0(j,i) ) + & |
---|
| 826 | 5.0 * rifs * ( zp - z0(j,i) ) / zp & |
---|
| 827 | ) |
---|
| 828 | ELSE |
---|
| 829 | |
---|
| 830 | ! |
---|
| 831 | !-- Unstable stratification |
---|
| 832 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 833 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
| 834 | |
---|
| 835 | us_wall = kappa * vel_total / ( & |
---|
| 836 | LOG( zp / z0(j,i) ) - & |
---|
| 837 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 838 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 839 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 840 | ) |
---|
| 841 | ENDIF |
---|
| 842 | |
---|
| 843 | ! |
---|
| 844 | !-- Skip step (4) of wall_fluxes, because here rifs is already |
---|
| 845 | !-- available from (1) |
---|
| 846 | ! |
---|
[56] | 847 | !-- (5) Compute wall_flux (u'v', v'u', w'v', or w'u') |
---|
[187] | 848 | !-- First interpolate the velocity (this is different from |
---|
| 849 | !-- subroutine wall_fluxes because fluxes in subroutine |
---|
| 850 | !-- wall_fluxes_e are defined at scalar locations). |
---|
[56] | 851 | vel_zp = 0.5 * ( a * ( u(k,j,i) + u(k,j,i+1) ) + & |
---|
| 852 | b * ( v(k,j,i) + v(k,j+1,i) ) + & |
---|
| 853 | (c1+c2) * ( w(k,j,i) + w(k-1,j,i) ) & |
---|
| 854 | ) |
---|
| 855 | |
---|
| 856 | IF ( rifs >= 0.0 ) THEN |
---|
| 857 | |
---|
| 858 | ! |
---|
| 859 | !-- Stable stratification (and neutral) |
---|
| 860 | wall_flux(k) = kappa * vel_zp / & |
---|
| 861 | ( LOG( zp/z0(j,i) ) + 5.0*rifs * ( zp-z0(j,i) ) / zp ) |
---|
| 862 | ELSE |
---|
| 863 | |
---|
| 864 | ! |
---|
| 865 | !-- Unstable stratification |
---|
[187] | 866 | h1 = SQRT( SQRT( 1.0 - 16.0 * rifs ) ) |
---|
| 867 | h2 = SQRT( SQRT( 1.0 - 16.0 * rifs * z0(j,i) / zp ) ) |
---|
[56] | 868 | |
---|
[187] | 869 | wall_flux(k) = kappa * vel_zp / ( & |
---|
| 870 | LOG( zp / z0(j,i) ) - & |
---|
| 871 | LOG( ( 1.0 + h1 )**2 * ( 1.0 + h1**2 ) / ( & |
---|
| 872 | ( 1.0 + h2 )**2 * ( 1.0 + h2**2 ) ) ) + & |
---|
| 873 | 2.0 * ( ATAN( h1 ) - ATAN( h2 ) ) & |
---|
| 874 | ) |
---|
[53] | 875 | ENDIF |
---|
[187] | 876 | wall_flux(k) = - wall_flux(k) * us_wall |
---|
[53] | 877 | |
---|
[56] | 878 | ENDDO |
---|
[53] | 879 | |
---|
[56] | 880 | END SUBROUTINE wall_fluxes_e_ij |
---|
| 881 | |
---|
| 882 | END MODULE wall_fluxes_mod |
---|