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