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