[1] | 1 | MODULE diffusion_v_mod |
---|
| 2 | |
---|
| 3 | !------------------------------------------------------------------------------! |
---|
| 4 | ! Actual revisions: |
---|
| 5 | ! ----------------- |
---|
[77] | 6 | ! |
---|
[1] | 7 | ! |
---|
| 8 | ! Former revisions: |
---|
| 9 | ! ----------------- |
---|
[3] | 10 | ! $Id: diffusion_v.f90 77 2007-03-29 04:26:56Z raasch $ |
---|
[39] | 11 | ! |
---|
[77] | 12 | ! 75 2007-03-22 09:54:05Z raasch |
---|
| 13 | ! Wall functions now include diabatic conditions, call of routine wall_fluxes, |
---|
| 14 | ! z0 removed from argument list, vynp eliminated |
---|
| 15 | ! |
---|
[39] | 16 | ! 20 2007-02-26 00:12:32Z raasch |
---|
| 17 | ! Bugfix: ddzw dimensioned 1:nzt"+1" |
---|
| 18 | ! |
---|
[3] | 19 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
| 20 | ! |
---|
[1] | 21 | ! Revision 1.15 2006/02/23 10:36:00 raasch |
---|
| 22 | ! nzb_2d replaced by nzb_v_outer in horizontal diffusion and by nzb_v_inner |
---|
| 23 | ! or nzb_diff_v, respectively, in vertical diffusion, |
---|
| 24 | ! wall functions added for north and south walls, +z0 in argument list, |
---|
| 25 | ! terms containing w(k-1,..) are removed from the Prandtl-layer equation |
---|
| 26 | ! because they cause errors at the edges of topography |
---|
| 27 | ! WARNING: loops containing the MAX function are still not properly vectorized! |
---|
| 28 | ! |
---|
| 29 | ! Revision 1.1 1997/09/12 06:24:01 raasch |
---|
| 30 | ! Initial revision |
---|
| 31 | ! |
---|
| 32 | ! |
---|
| 33 | ! Description: |
---|
| 34 | ! ------------ |
---|
| 35 | ! Diffusion term of the v-component |
---|
| 36 | !------------------------------------------------------------------------------! |
---|
| 37 | |
---|
[56] | 38 | USE wall_fluxes_mod |
---|
| 39 | |
---|
[1] | 40 | PRIVATE |
---|
| 41 | PUBLIC diffusion_v |
---|
| 42 | |
---|
| 43 | INTERFACE diffusion_v |
---|
| 44 | MODULE PROCEDURE diffusion_v |
---|
| 45 | MODULE PROCEDURE diffusion_v_ij |
---|
| 46 | END INTERFACE diffusion_v |
---|
| 47 | |
---|
| 48 | CONTAINS |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | !------------------------------------------------------------------------------! |
---|
| 52 | ! Call for all grid points |
---|
| 53 | !------------------------------------------------------------------------------! |
---|
[57] | 54 | SUBROUTINE diffusion_v( ddzu, ddzw, km, km_damp_x, tend, u, v, vsws, w ) |
---|
[1] | 55 | |
---|
| 56 | USE control_parameters |
---|
| 57 | USE grid_variables |
---|
| 58 | USE indices |
---|
| 59 | |
---|
| 60 | IMPLICIT NONE |
---|
| 61 | |
---|
| 62 | INTEGER :: i, j, k |
---|
[51] | 63 | REAL :: kmxm_x, kmxm_y, kmxp_x, kmxp_y, kmzm, kmzp |
---|
[20] | 64 | REAL :: ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_x(nxl-1:nxr+1) |
---|
[1] | 65 | REAL :: tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) |
---|
| 66 | REAL, DIMENSION(:,:), POINTER :: vsws |
---|
| 67 | REAL, DIMENSION(:,:,:), POINTER :: km, u, v, w |
---|
[75] | 68 | REAL, DIMENSION(nzb:nzt+1,nys:nyn,nxl:nxr) :: vsus |
---|
[1] | 69 | |
---|
[56] | 70 | ! |
---|
| 71 | !-- First calculate horizontal momentum flux v'u' at vertical walls, |
---|
| 72 | !-- if neccessary |
---|
| 73 | IF ( topography /= 'flat' ) THEN |
---|
[75] | 74 | CALL wall_fluxes( vsus, 0.0, 1.0, 0.0, 0.0, nzb_v_inner, & |
---|
[56] | 75 | nzb_v_outer, wall_v ) |
---|
| 76 | ENDIF |
---|
| 77 | |
---|
[1] | 78 | DO i = nxl, nxr |
---|
[75] | 79 | DO j = nys, nyn |
---|
[1] | 80 | ! |
---|
| 81 | !-- Compute horizontal diffusion |
---|
| 82 | DO k = nzb_v_outer(j,i)+1, nzt |
---|
| 83 | ! |
---|
| 84 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
| 85 | kmxp_x = 0.25 * & |
---|
| 86 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
| 87 | kmxm_x = 0.25 * & |
---|
| 88 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
| 89 | kmxp_y = kmxp_x |
---|
| 90 | kmxm_y = kmxm_x |
---|
| 91 | ! |
---|
| 92 | !-- Increase diffusion at the outflow boundary in case of |
---|
| 93 | !-- non-cyclic lateral boundaries. Damping is only needed for |
---|
| 94 | !-- velocity components parallel to the outflow boundary in |
---|
| 95 | !-- the direction normal to the outflow boundary. |
---|
| 96 | IF ( bc_lr /= 'cyclic' ) THEN |
---|
| 97 | kmxp_x = MAX( kmxp_x, km_damp_x(i) ) |
---|
| 98 | kmxm_x = MAX( kmxm_x, km_damp_x(i) ) |
---|
| 99 | ENDIF |
---|
| 100 | |
---|
| 101 | tend(k,j,i) = tend(k,j,i) & |
---|
| 102 | & + ( kmxp_x * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
| 103 | & + kmxp_y * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
| 104 | & - kmxm_x * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 105 | & - kmxm_y * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 106 | & ) * ddx & |
---|
| 107 | & + 2.0 * ( & |
---|
| 108 | & km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
| 109 | & - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
| 110 | & ) * ddy2 |
---|
| 111 | ENDDO |
---|
| 112 | |
---|
| 113 | ! |
---|
| 114 | !-- Wall functions at the left and right walls, respectively |
---|
| 115 | IF ( wall_v(j,i) /= 0.0 ) THEN |
---|
[51] | 116 | |
---|
[1] | 117 | DO k = nzb_v_inner(j,i)+1, nzb_v_outer(j,i) |
---|
| 118 | kmxp_x = 0.25 * & |
---|
| 119 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
| 120 | kmxm_x = 0.25 * & |
---|
| 121 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
| 122 | kmxp_y = kmxp_x |
---|
| 123 | kmxm_y = kmxm_x |
---|
| 124 | ! |
---|
| 125 | !-- Increase diffusion at the outflow boundary in case of |
---|
| 126 | !-- non-cyclic lateral boundaries. Damping is only needed for |
---|
| 127 | !-- velocity components parallel to the outflow boundary in |
---|
| 128 | !-- the direction normal to the outflow boundary. |
---|
| 129 | IF ( bc_lr /= 'cyclic' ) THEN |
---|
| 130 | kmxp_x = MAX( kmxp_x, km_damp_x(i) ) |
---|
| 131 | kmxm_x = MAX( kmxm_x, km_damp_x(i) ) |
---|
| 132 | ENDIF |
---|
| 133 | |
---|
| 134 | tend(k,j,i) = tend(k,j,i) & |
---|
| 135 | + 2.0 * ( & |
---|
| 136 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
| 137 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
| 138 | ) * ddy2 & |
---|
| 139 | + ( fxp(j,i) * ( & |
---|
| 140 | kmxp_x * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
| 141 | + kmxp_y * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
| 142 | ) & |
---|
| 143 | - fxm(j,i) * ( & |
---|
| 144 | kmxm_x * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 145 | + kmxm_y * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 146 | ) & |
---|
[56] | 147 | + wall_v(j,i) * vsus(k,j,i) & |
---|
[1] | 148 | ) * ddx |
---|
| 149 | ENDDO |
---|
| 150 | ENDIF |
---|
| 151 | |
---|
| 152 | ! |
---|
| 153 | !-- Compute vertical diffusion. In case of simulating a Prandtl |
---|
| 154 | !-- layer, index k starts at nzb_v_inner+2. |
---|
| 155 | DO k = nzb_diff_v(j,i), nzt |
---|
| 156 | ! |
---|
| 157 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
| 158 | kmzp = 0.25 * & |
---|
| 159 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
| 160 | kmzm = 0.25 * & |
---|
| 161 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
| 162 | |
---|
| 163 | tend(k,j,i) = tend(k,j,i) & |
---|
| 164 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 165 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 166 | & ) & |
---|
| 167 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
| 168 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
| 169 | & ) & |
---|
| 170 | & ) * ddzw(k) |
---|
| 171 | ENDDO |
---|
| 172 | |
---|
| 173 | ! |
---|
| 174 | !-- Vertical diffusion at the first grid point above the surface, |
---|
| 175 | !-- if the momentum flux at the bottom is given by the Prandtl law |
---|
| 176 | !-- or if it is prescribed by the user. |
---|
| 177 | !-- Difference quotient of the momentum flux is not formed over |
---|
| 178 | !-- half of the grid spacing (2.0*ddzw(k)) any more, since the |
---|
| 179 | !-- comparison with other (LES) modell showed that the values of |
---|
| 180 | !-- the momentum flux becomes too large in this case. |
---|
| 181 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
| 182 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
| 183 | IF ( use_surface_fluxes ) THEN |
---|
| 184 | k = nzb_v_inner(j,i)+1 |
---|
| 185 | ! |
---|
| 186 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
| 187 | kmzp = 0.25 * & |
---|
| 188 | ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
| 189 | kmzm = 0.25 * & |
---|
| 190 | ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
| 191 | |
---|
| 192 | tend(k,j,i) = tend(k,j,i) & |
---|
| 193 | & + ( kmzp * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 194 | & ) * ddzw(k) & |
---|
| 195 | & + ( kmzp * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 196 | & + vsws(j,i) & |
---|
| 197 | & ) * ddzw(k) |
---|
| 198 | ENDIF |
---|
| 199 | |
---|
| 200 | ENDDO |
---|
| 201 | ENDDO |
---|
| 202 | |
---|
| 203 | END SUBROUTINE diffusion_v |
---|
| 204 | |
---|
| 205 | |
---|
| 206 | !------------------------------------------------------------------------------! |
---|
| 207 | ! Call for grid point i,j |
---|
| 208 | !------------------------------------------------------------------------------! |
---|
| 209 | SUBROUTINE diffusion_v_ij( i, j, ddzu, ddzw, km, km_damp_x, tend, u, v, & |
---|
[57] | 210 | vsws, w ) |
---|
[1] | 211 | |
---|
| 212 | USE control_parameters |
---|
| 213 | USE grid_variables |
---|
| 214 | USE indices |
---|
| 215 | |
---|
| 216 | IMPLICIT NONE |
---|
| 217 | |
---|
| 218 | INTEGER :: i, j, k |
---|
[51] | 219 | REAL :: kmxm_x, kmxm_y, kmxp_x, kmxp_y, kmzm, kmzp |
---|
[20] | 220 | REAL :: ddzu(1:nzt+1), ddzw(1:nzt+1), km_damp_x(nxl-1:nxr+1) |
---|
[1] | 221 | REAL :: tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) |
---|
[51] | 222 | REAL, DIMENSION(nzb:nzt+1) :: vsus |
---|
[1] | 223 | REAL, DIMENSION(:,:), POINTER :: vsws |
---|
| 224 | REAL, DIMENSION(:,:,:), POINTER :: km, u, v, w |
---|
| 225 | |
---|
| 226 | ! |
---|
| 227 | !-- Compute horizontal diffusion |
---|
| 228 | DO k = nzb_v_outer(j,i)+1, nzt |
---|
| 229 | ! |
---|
| 230 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
| 231 | kmxp_x = 0.25 * ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
| 232 | kmxm_x = 0.25 * ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
| 233 | kmxp_y = kmxp_x |
---|
| 234 | kmxm_y = kmxm_x |
---|
| 235 | ! |
---|
| 236 | !-- Increase diffusion at the outflow boundary in case of non-cyclic |
---|
| 237 | !-- lateral boundaries. Damping is only needed for velocity components |
---|
| 238 | !-- parallel to the outflow boundary in the direction normal to the |
---|
| 239 | !-- outflow boundary. |
---|
| 240 | IF ( bc_lr /= 'cyclic' ) THEN |
---|
| 241 | kmxp_x = MAX( kmxp_x, km_damp_x(i) ) |
---|
| 242 | kmxm_x = MAX( kmxm_x, km_damp_x(i) ) |
---|
| 243 | ENDIF |
---|
| 244 | |
---|
| 245 | tend(k,j,i) = tend(k,j,i) & |
---|
| 246 | & + ( kmxp_x * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
| 247 | & + kmxp_y * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
| 248 | & - kmxm_x * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 249 | & - kmxm_y * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 250 | & ) * ddx & |
---|
| 251 | & + 2.0 * ( & |
---|
| 252 | & km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
| 253 | & - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
| 254 | & ) * ddy2 |
---|
| 255 | ENDDO |
---|
| 256 | |
---|
| 257 | ! |
---|
| 258 | !-- Wall functions at the left and right walls, respectively |
---|
| 259 | IF ( wall_v(j,i) /= 0.0 ) THEN |
---|
[51] | 260 | |
---|
| 261 | ! |
---|
| 262 | !-- Calculate the horizontal momentum flux v'u' |
---|
| 263 | CALL wall_fluxes( i, j, nzb_v_inner(j,i)+1, nzb_v_outer(j,i), & |
---|
| 264 | vsus, 0.0, 1.0, 0.0, 0.0 ) |
---|
| 265 | |
---|
[1] | 266 | DO k = nzb_v_inner(j,i)+1, nzb_v_outer(j,i) |
---|
| 267 | kmxp_x = 0.25 * & |
---|
| 268 | ( km(k,j,i)+km(k,j,i+1)+km(k,j-1,i)+km(k,j-1,i+1) ) |
---|
| 269 | kmxm_x = 0.25 * & |
---|
| 270 | ( km(k,j,i)+km(k,j,i-1)+km(k,j-1,i)+km(k,j-1,i-1) ) |
---|
| 271 | kmxp_y = kmxp_x |
---|
| 272 | kmxm_y = kmxm_x |
---|
| 273 | ! |
---|
| 274 | !-- Increase diffusion at the outflow boundary in case of |
---|
| 275 | !-- non-cyclic lateral boundaries. Damping is only needed for |
---|
| 276 | !-- velocity components parallel to the outflow boundary in |
---|
| 277 | !-- the direction normal to the outflow boundary. |
---|
| 278 | IF ( bc_lr /= 'cyclic' ) THEN |
---|
| 279 | kmxp_x = MAX( kmxp_x, km_damp_x(i) ) |
---|
| 280 | kmxm_x = MAX( kmxm_x, km_damp_x(i) ) |
---|
| 281 | ENDIF |
---|
| 282 | |
---|
| 283 | tend(k,j,i) = tend(k,j,i) & |
---|
| 284 | + 2.0 * ( & |
---|
| 285 | km(k,j,i) * ( v(k,j+1,i) - v(k,j,i) ) & |
---|
| 286 | - km(k,j-1,i) * ( v(k,j,i) - v(k,j-1,i) ) & |
---|
| 287 | ) * ddy2 & |
---|
| 288 | + ( fxp(j,i) * ( & |
---|
| 289 | kmxp_x * ( v(k,j,i+1) - v(k,j,i) ) * ddx & |
---|
| 290 | + kmxp_y * ( u(k,j,i+1) - u(k,j-1,i+1) ) * ddy & |
---|
| 291 | ) & |
---|
| 292 | - fxm(j,i) * ( & |
---|
| 293 | kmxm_x * ( v(k,j,i) - v(k,j,i-1) ) * ddx & |
---|
| 294 | + kmxm_y * ( u(k,j,i) - u(k,j-1,i) ) * ddy & |
---|
| 295 | ) & |
---|
[51] | 296 | + wall_v(j,i) * vsus(k) & |
---|
[1] | 297 | ) * ddx |
---|
| 298 | ENDDO |
---|
| 299 | ENDIF |
---|
| 300 | |
---|
| 301 | ! |
---|
| 302 | !-- Compute vertical diffusion. In case of simulating a Prandtl layer, |
---|
| 303 | !-- index k starts at nzb_v_inner+2. |
---|
| 304 | DO k = nzb_diff_v(j,i), nzt |
---|
| 305 | ! |
---|
| 306 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
| 307 | kmzp = 0.25 * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
| 308 | kmzm = 0.25 * ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
| 309 | |
---|
| 310 | tend(k,j,i) = tend(k,j,i) & |
---|
| 311 | & + ( kmzp * ( ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 312 | & + ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 313 | & ) & |
---|
| 314 | & - kmzm * ( ( v(k,j,i) - v(k-1,j,i) ) * ddzu(k) & |
---|
| 315 | & + ( w(k-1,j,i) - w(k-1,j-1,i) ) * ddy & |
---|
| 316 | & ) & |
---|
| 317 | & ) * ddzw(k) |
---|
| 318 | ENDDO |
---|
| 319 | |
---|
| 320 | ! |
---|
| 321 | !-- Vertical diffusion at the first grid point above the surface, if the |
---|
| 322 | !-- momentum flux at the bottom is given by the Prandtl law or if it is |
---|
| 323 | !-- prescribed by the user. |
---|
| 324 | !-- Difference quotient of the momentum flux is not formed over half of |
---|
| 325 | !-- the grid spacing (2.0*ddzw(k)) any more, since the comparison with |
---|
| 326 | !-- other (LES) modell showed that the values of the momentum flux becomes |
---|
| 327 | !-- too large in this case. |
---|
| 328 | !-- The term containing w(k-1,..) (see above equation) is removed here |
---|
| 329 | !-- because the vertical velocity is assumed to be zero at the surface. |
---|
| 330 | IF ( use_surface_fluxes ) THEN |
---|
| 331 | k = nzb_v_inner(j,i)+1 |
---|
| 332 | ! |
---|
| 333 | !-- Interpolate eddy diffusivities on staggered gridpoints |
---|
| 334 | kmzp = 0.25 * ( km(k,j,i)+km(k+1,j,i)+km(k,j-1,i)+km(k+1,j-1,i) ) |
---|
| 335 | kmzm = 0.25 * ( km(k,j,i)+km(k-1,j,i)+km(k,j-1,i)+km(k-1,j-1,i) ) |
---|
| 336 | |
---|
| 337 | tend(k,j,i) = tend(k,j,i) & |
---|
| 338 | & + ( kmzp * ( w(k,j,i) - w(k,j-1,i) ) * ddy & |
---|
| 339 | & ) * ddzw(k) & |
---|
| 340 | & + ( kmzp * ( v(k+1,j,i) - v(k,j,i) ) * ddzu(k+1) & |
---|
| 341 | & + vsws(j,i) & |
---|
| 342 | & ) * ddzw(k) |
---|
| 343 | ENDIF |
---|
| 344 | |
---|
| 345 | END SUBROUTINE diffusion_v_ij |
---|
| 346 | |
---|
| 347 | END MODULE diffusion_v_mod |
---|