1 | SUBROUTINE boundary_conds( range ) |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: boundary_conds.f90 98 2007-06-21 09:36:33Z raasch $ |
---|
11 | ! |
---|
12 | ! 95 2007-06-02 16:48:38Z raasch |
---|
13 | ! Boundary conditions for salinity added |
---|
14 | ! |
---|
15 | ! 75 2007-03-22 09:54:05Z raasch |
---|
16 | ! The "main" part sets conditions for time level t+dt instead of level t, |
---|
17 | ! outflow boundary conditions changed from Neumann to radiation condition, |
---|
18 | ! uxrp, vynp eliminated, moisture renamed humidity |
---|
19 | ! |
---|
20 | ! 19 2007-02-23 04:53:48Z raasch |
---|
21 | ! Boundary conditions for e(nzt), pt(nzt), and q(nzt) removed because these |
---|
22 | ! gridpoints are now calculated by the prognostic equation, |
---|
23 | ! Dirichlet and zero gradient condition for pt established at top boundary |
---|
24 | ! |
---|
25 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
26 | ! |
---|
27 | ! Revision 1.15 2006/02/23 09:54:55 raasch |
---|
28 | ! Surface boundary conditions in case of topography: nzb replaced by |
---|
29 | ! 2d-k-index-arrays (nzb_w_inner, etc.). Conditions for u and v remain |
---|
30 | ! unchanged (still using nzb) because a non-flat topography must use a |
---|
31 | ! Prandtl-layer, which don't requires explicit setting of the surface values. |
---|
32 | ! |
---|
33 | ! Revision 1.1 1997/09/12 06:21:34 raasch |
---|
34 | ! Initial revision |
---|
35 | ! |
---|
36 | ! |
---|
37 | ! Description: |
---|
38 | ! ------------ |
---|
39 | ! Boundary conditions for the prognostic quantities (range='main'). |
---|
40 | ! In case of non-cyclic lateral boundaries the conditions for velocities at |
---|
41 | ! the outflow are set after the pressure solver has been called (range= |
---|
42 | ! 'outflow_uvw'). |
---|
43 | ! One additional bottom boundary condition is applied for the TKE (=(u*)**2) |
---|
44 | ! in prandtl_fluxes. The cyclic lateral boundary conditions are implicitly |
---|
45 | ! handled in routine exchange_horiz. Pressure boundary conditions are |
---|
46 | ! explicitly set in routines pres, poisfft, poismg and sor. |
---|
47 | !------------------------------------------------------------------------------! |
---|
48 | |
---|
49 | USE arrays_3d |
---|
50 | USE control_parameters |
---|
51 | USE grid_variables |
---|
52 | USE indices |
---|
53 | USE pegrid |
---|
54 | |
---|
55 | IMPLICIT NONE |
---|
56 | |
---|
57 | CHARACTER (LEN=*) :: range |
---|
58 | |
---|
59 | INTEGER :: i, j, k |
---|
60 | |
---|
61 | REAL :: c_max, c_u, c_v, c_w, denom |
---|
62 | |
---|
63 | |
---|
64 | IF ( range == 'main') THEN |
---|
65 | ! |
---|
66 | !-- Bottom boundary |
---|
67 | IF ( ibc_uv_b == 0 ) THEN |
---|
68 | ! |
---|
69 | !-- Satisfying the Dirichlet condition with an extra layer below the |
---|
70 | !-- surface where the u and v component change their sign |
---|
71 | u_p(nzb,:,:) = -u_p(nzb+1,:,:) |
---|
72 | v_p(nzb,:,:) = -v_p(nzb+1,:,:) |
---|
73 | ELSE |
---|
74 | u_p(nzb,:,:) = u_p(nzb+1,:,:) |
---|
75 | v_p(nzb,:,:) = v_p(nzb+1,:,:) |
---|
76 | ENDIF |
---|
77 | DO i = nxl-1, nxr+1 |
---|
78 | DO j = nys-1, nyn+1 |
---|
79 | w_p(nzb_w_inner(j,i),j,i) = 0.0 |
---|
80 | ENDDO |
---|
81 | ENDDO |
---|
82 | |
---|
83 | ! |
---|
84 | !-- Top boundary |
---|
85 | IF ( ibc_uv_t == 0 ) THEN |
---|
86 | u_p(nzt+1,:,:) = ug(nzt+1) |
---|
87 | v_p(nzt+1,:,:) = vg(nzt+1) |
---|
88 | ELSE |
---|
89 | u_p(nzt+1,:,:) = u_p(nzt,:,:) |
---|
90 | v_p(nzt+1,:,:) = v_p(nzt,:,:) |
---|
91 | ENDIF |
---|
92 | w_p(nzt:nzt+1,:,:) = 0.0 ! nzt is not a prognostic level (but cf. pres) |
---|
93 | |
---|
94 | ! |
---|
95 | !-- Temperature at bottom boundary |
---|
96 | IF ( ibc_pt_b == 0 ) THEN |
---|
97 | DO i = nxl-1, nxr+1 |
---|
98 | DO j = nys-1, nyn+1 |
---|
99 | pt_p(nzb_s_inner(j,i),j,i) = pt(nzb_s_inner(j,i),j,i) |
---|
100 | ENDDO |
---|
101 | ENDDO |
---|
102 | ELSE |
---|
103 | DO i = nxl-1, nxr+1 |
---|
104 | DO j = nys-1, nyn+1 |
---|
105 | pt_p(nzb_s_inner(j,i),j,i) = pt_p(nzb_s_inner(j,i)+1,j,i) |
---|
106 | ENDDO |
---|
107 | ENDDO |
---|
108 | ENDIF |
---|
109 | |
---|
110 | ! |
---|
111 | !-- Temperature at top boundary |
---|
112 | IF ( ibc_pt_t == 0 ) THEN |
---|
113 | pt_p(nzt+1,:,:) = pt(nzt+1,:,:) |
---|
114 | ELSEIF ( ibc_pt_t == 1 ) THEN |
---|
115 | pt_p(nzt+1,:,:) = pt_p(nzt,:,:) |
---|
116 | ELSEIF ( ibc_pt_t == 2 ) THEN |
---|
117 | pt_p(nzt+1,:,:) = pt_p(nzt,:,:) + bc_pt_t_val * dzu(nzt+1) |
---|
118 | ENDIF |
---|
119 | |
---|
120 | ! |
---|
121 | !-- Boundary conditions for TKE |
---|
122 | !-- Generally Neumann conditions with de/dz=0 are assumed |
---|
123 | IF ( .NOT. constant_diffusion ) THEN |
---|
124 | DO i = nxl-1, nxr+1 |
---|
125 | DO j = nys-1, nyn+1 |
---|
126 | e_p(nzb_s_inner(j,i),j,i) = e_p(nzb_s_inner(j,i)+1,j,i) |
---|
127 | ENDDO |
---|
128 | ENDDO |
---|
129 | e_p(nzt+1,:,:) = e_p(nzt,:,:) |
---|
130 | ENDIF |
---|
131 | |
---|
132 | ! |
---|
133 | !-- Boundary conditions for salinity |
---|
134 | IF ( ocean ) THEN |
---|
135 | ! |
---|
136 | !-- Bottom boundary: Neumann condition because salinity flux is always |
---|
137 | !-- given |
---|
138 | DO i = nxl-1, nxr+1 |
---|
139 | DO j = nys-1, nyn+1 |
---|
140 | sa_p(nzb_s_inner(j,i),j,i) = sa_p(nzb_s_inner(j,i)+1,j,i) |
---|
141 | ENDDO |
---|
142 | ENDDO |
---|
143 | |
---|
144 | ! |
---|
145 | !-- Top boundary: Dirichlet or Neumann |
---|
146 | IF ( ibc_sa_t == 0 ) THEN |
---|
147 | sa_p(nzt+1,:,:) = sa(nzt+1,:,:) |
---|
148 | ELSEIF ( ibc_sa_t == 1 ) THEN |
---|
149 | sa_p(nzt+1,:,:) = sa_p(nzt,:,:) |
---|
150 | ENDIF |
---|
151 | |
---|
152 | ENDIF |
---|
153 | |
---|
154 | ! |
---|
155 | !-- Boundary conditions for total water content or scalar, |
---|
156 | !-- bottom and top boundary (see also temperature) |
---|
157 | IF ( humidity .OR. passive_scalar ) THEN |
---|
158 | ! |
---|
159 | !-- Surface conditions for constant_humidity_flux |
---|
160 | IF ( ibc_q_b == 0 ) THEN |
---|
161 | DO i = nxl-1, nxr+1 |
---|
162 | DO j = nys-1, nyn+1 |
---|
163 | q_p(nzb_s_inner(j,i),j,i) = q(nzb_s_inner(j,i),j,i) |
---|
164 | ENDDO |
---|
165 | ENDDO |
---|
166 | ELSE |
---|
167 | DO i = nxl-1, nxr+1 |
---|
168 | DO j = nys-1, nyn+1 |
---|
169 | q_p(nzb_s_inner(j,i),j,i) = q_p(nzb_s_inner(j,i)+1,j,i) |
---|
170 | ENDDO |
---|
171 | ENDDO |
---|
172 | ENDIF |
---|
173 | ! |
---|
174 | !-- Top boundary |
---|
175 | q_p(nzt+1,:,:) = q_p(nzt,:,:) + bc_q_t_val * dzu(nzt+1) |
---|
176 | ENDIF |
---|
177 | |
---|
178 | ! |
---|
179 | !-- Lateral boundary conditions at the inflow. Quasi Neumann conditions |
---|
180 | !-- are needed for the wall normal velocity in order to ensure zero |
---|
181 | !-- divergence. Dirichlet conditions are used for all other quantities. |
---|
182 | IF ( inflow_s ) THEN |
---|
183 | v_p(:,nys,:) = v_p(:,nys-1,:) |
---|
184 | ELSEIF ( inflow_n ) THEN |
---|
185 | v_p(:,nyn,:) = v_p(:,nyn+1,:) |
---|
186 | ELSEIF ( inflow_l ) THEN |
---|
187 | u_p(:,:,nxl) = u_p(:,:,nxl-1) |
---|
188 | ELSEIF ( inflow_r ) THEN |
---|
189 | u_p(:,:,nxr) = u_p(:,:,nxr+1) |
---|
190 | ENDIF |
---|
191 | |
---|
192 | ! |
---|
193 | !-- Lateral boundary conditions for scalar quantities at the outflow |
---|
194 | IF ( outflow_s ) THEN |
---|
195 | pt_p(:,nys-1,:) = pt_p(:,nys,:) |
---|
196 | IF ( .NOT. constant_diffusion ) e_p(:,nys-1,:) = e_p(:,nys,:) |
---|
197 | IF ( humidity .OR. passive_scalar ) q_p(:,nys-1,:) = q_p(:,nys,:) |
---|
198 | ELSEIF ( outflow_n ) THEN |
---|
199 | pt_p(:,nyn+1,:) = pt_p(:,nyn,:) |
---|
200 | IF ( .NOT. constant_diffusion ) e_p(:,nyn+1,:) = e_p(:,nyn,:) |
---|
201 | IF ( humidity .OR. passive_scalar ) q_p(:,nyn+1,:) = q_p(:,nyn,:) |
---|
202 | ELSEIF ( outflow_l ) THEN |
---|
203 | pt_p(:,:,nxl-1) = pt_p(:,:,nxl) |
---|
204 | IF ( .NOT. constant_diffusion ) e_p(:,:,nxl-1) = e_p(:,:,nxl) |
---|
205 | IF ( humidity .OR. passive_scalar ) q_p(:,:,nxl-1) = q_p(:,:,nxl) |
---|
206 | ELSEIF ( outflow_r ) THEN |
---|
207 | pt_p(:,:,nxr+1) = pt_p(:,:,nxr) |
---|
208 | IF ( .NOT. constant_diffusion ) e_p(:,:,nxr+1) = e_p(:,:,nxr) |
---|
209 | IF ( humidity .OR. passive_scalar ) q_p(:,:,nxr+1) = q_p(:,:,nxr) |
---|
210 | ENDIF |
---|
211 | |
---|
212 | ENDIF |
---|
213 | |
---|
214 | ! |
---|
215 | !-- Radiation boundary condition for the velocities at the respective outflow |
---|
216 | IF ( outflow_s .AND. & |
---|
217 | intermediate_timestep_count == intermediate_timestep_count_max ) & |
---|
218 | THEN |
---|
219 | |
---|
220 | c_max = dy / dt_3d |
---|
221 | |
---|
222 | DO i = nxl-1, nxr+1 |
---|
223 | DO k = nzb+1, nzt+1 |
---|
224 | |
---|
225 | ! |
---|
226 | !-- First calculate the phase speeds for u,v, and w |
---|
227 | denom = u_m_s(k,0,i) - u_m_s(k,1,i) |
---|
228 | |
---|
229 | IF ( denom /= 0.0 ) THEN |
---|
230 | c_u = -c_max * ( u(k,0,i) - u_m_s(k,0,i) ) / denom |
---|
231 | IF ( c_u < 0.0 ) THEN |
---|
232 | c_u = 0.0 |
---|
233 | ELSEIF ( c_u > c_max ) THEN |
---|
234 | c_u = c_max |
---|
235 | ENDIF |
---|
236 | ELSE |
---|
237 | c_u = c_max |
---|
238 | ENDIF |
---|
239 | denom = v_m_s(k,0,i) - v_m_s(k,1,i) |
---|
240 | |
---|
241 | IF ( denom /= 0.0 ) THEN |
---|
242 | c_v = -c_max * ( v(k,0,i) - v_m_s(k,0,i) ) / denom |
---|
243 | IF ( c_v < 0.0 ) THEN |
---|
244 | c_v = 0.0 |
---|
245 | ELSEIF ( c_v > c_max ) THEN |
---|
246 | c_v = c_max |
---|
247 | ENDIF |
---|
248 | ELSE |
---|
249 | c_v = c_max |
---|
250 | ENDIF |
---|
251 | |
---|
252 | denom = w_m_s(k,0,i) - w_m_s(k,1,i) |
---|
253 | |
---|
254 | IF ( denom /= 0.0 ) THEN |
---|
255 | c_w = -c_max * ( w(k,0,i) - w_m_s(k,0,i) ) / denom |
---|
256 | IF ( c_w < 0.0 ) THEN |
---|
257 | c_w = 0.0 |
---|
258 | ELSEIF ( c_w > c_max ) THEN |
---|
259 | c_w = c_max |
---|
260 | ENDIF |
---|
261 | ELSE |
---|
262 | c_w = c_max |
---|
263 | ENDIF |
---|
264 | |
---|
265 | ! |
---|
266 | !-- Calculate the new velocities |
---|
267 | u_p(k,-1,i) = u(k,-1,i) + dt_3d * c_u * & |
---|
268 | ( u(k,-1,i) - u(k,0,i) ) * ddy |
---|
269 | |
---|
270 | v_p(k,-1,i) = v(k,-1,i) + dt_3d * c_v * & |
---|
271 | ( v(k,-1,i) - v_m_s(k,0,i) ) * ddy |
---|
272 | |
---|
273 | w_p(k,-1,i) = w(k,-1,i) + dt_3d * c_w * & |
---|
274 | ( w(k,-1,i) - w(k,0,i) ) * ddy |
---|
275 | |
---|
276 | ! |
---|
277 | !-- Save old timelevels for the next timestep |
---|
278 | u_m_s(k,:,i) = u(k,-1:1,i) |
---|
279 | v_m_s(k,:,i) = v(k,-1:1,i) |
---|
280 | w_m_s(k,:,i) = w(k,-1:1,i) |
---|
281 | |
---|
282 | ENDDO |
---|
283 | ENDDO |
---|
284 | |
---|
285 | ! |
---|
286 | !-- Bottom boundary at the outflow |
---|
287 | IF ( ibc_uv_b == 0 ) THEN |
---|
288 | u_p(nzb,-1,:) = -u_p(nzb+1,-1,:) |
---|
289 | v_p(nzb,-1,:) = -v_p(nzb+1,-1,:) |
---|
290 | ELSE |
---|
291 | u_p(nzb,-1,:) = u_p(nzb+1,-1,:) |
---|
292 | v_p(nzb,-1,:) = v_p(nzb+1,-1,:) |
---|
293 | ENDIF |
---|
294 | w_p(nzb,ny+1,:) = 0.0 |
---|
295 | |
---|
296 | ! |
---|
297 | !-- Top boundary at the outflow |
---|
298 | IF ( ibc_uv_t == 0 ) THEN |
---|
299 | u_p(nzt+1,-1,:) = ug(nzt+1) |
---|
300 | v_p(nzt+1,-1,:) = vg(nzt+1) |
---|
301 | ELSE |
---|
302 | u_p(nzt+1,-1,:) = u(nzt,-1,:) |
---|
303 | v_p(nzt+1,-1,:) = v(nzt,-1,:) |
---|
304 | ENDIF |
---|
305 | w_p(nzt:nzt+1,-1,:) = 0.0 |
---|
306 | |
---|
307 | ENDIF |
---|
308 | |
---|
309 | IF ( outflow_n .AND. & |
---|
310 | intermediate_timestep_count == intermediate_timestep_count_max ) & |
---|
311 | THEN |
---|
312 | |
---|
313 | c_max = dy / dt_3d |
---|
314 | |
---|
315 | DO i = nxl-1, nxr+1 |
---|
316 | DO k = nzb+1, nzt+1 |
---|
317 | |
---|
318 | ! |
---|
319 | !-- First calculate the phase speeds for u,v, and w |
---|
320 | denom = u_m_n(k,ny,i) - u_m_n(k,ny-1,i) |
---|
321 | |
---|
322 | IF ( denom /= 0.0 ) THEN |
---|
323 | c_u = -c_max * ( u(k,ny,i) - u_m_n(k,ny,i) ) / denom |
---|
324 | IF ( c_u < 0.0 ) THEN |
---|
325 | c_u = 0.0 |
---|
326 | ELSEIF ( c_u > c_max ) THEN |
---|
327 | c_u = c_max |
---|
328 | ENDIF |
---|
329 | ELSE |
---|
330 | c_u = c_max |
---|
331 | ENDIF |
---|
332 | |
---|
333 | denom = v_m_n(k,ny,i) - v_m_n(k,ny-1,i) |
---|
334 | |
---|
335 | IF ( denom /= 0.0 ) THEN |
---|
336 | c_v = -c_max * ( v(k,ny,i) - v_m_n(k,ny,i) ) / denom |
---|
337 | IF ( c_v < 0.0 ) THEN |
---|
338 | c_v = 0.0 |
---|
339 | ELSEIF ( c_v > c_max ) THEN |
---|
340 | c_v = c_max |
---|
341 | ENDIF |
---|
342 | ELSE |
---|
343 | c_v = c_max |
---|
344 | ENDIF |
---|
345 | |
---|
346 | denom = w_m_n(k,ny,i) - w_m_n(k,ny-1,i) |
---|
347 | |
---|
348 | IF ( denom /= 0.0 ) THEN |
---|
349 | c_w = -c_max * ( w(k,ny,i) - w_m_n(k,ny,i) ) / denom |
---|
350 | IF ( c_w < 0.0 ) THEN |
---|
351 | c_w = 0.0 |
---|
352 | ELSEIF ( c_w > c_max ) THEN |
---|
353 | c_w = c_max |
---|
354 | ENDIF |
---|
355 | ELSE |
---|
356 | c_w = c_max |
---|
357 | ENDIF |
---|
358 | |
---|
359 | ! |
---|
360 | !-- Calculate the new velocities |
---|
361 | u_p(k,ny+1,i) = u(k,ny+1,i) - dt_3d * c_u * & |
---|
362 | ( u(k,ny+1,i) - u(k,ny,i) ) * ddy |
---|
363 | |
---|
364 | v_p(k,ny+1,i) = v(k,ny+1,i) - dt_3d * c_v * & |
---|
365 | ( v(k,ny+1,i) - v(k,ny,i) ) * ddy |
---|
366 | |
---|
367 | w_p(k,ny+1,i) = w(k,ny+1,i) - dt_3d * c_w * & |
---|
368 | ( w(k,ny+1,i) - w(k,ny,i) ) * ddy |
---|
369 | |
---|
370 | ! |
---|
371 | !-- Swap timelevels for the next timestep |
---|
372 | u_m_n(k,:,i) = u(k,ny-1:ny+1,i) |
---|
373 | v_m_n(k,:,i) = v(k,ny-1:ny+1,i) |
---|
374 | w_m_n(k,:,i) = w(k,ny-1:ny+1,i) |
---|
375 | |
---|
376 | ENDDO |
---|
377 | ENDDO |
---|
378 | |
---|
379 | ! |
---|
380 | !-- Bottom boundary at the outflow |
---|
381 | IF ( ibc_uv_b == 0 ) THEN |
---|
382 | u_p(nzb,ny+1,:) = -u_p(nzb+1,ny+1,:) |
---|
383 | v_p(nzb,ny+1,:) = -v_p(nzb+1,ny+1,:) |
---|
384 | ELSE |
---|
385 | u_p(nzb,ny+1,:) = u_p(nzb+1,ny+1,:) |
---|
386 | v_p(nzb,ny+1,:) = v_p(nzb+1,ny+1,:) |
---|
387 | ENDIF |
---|
388 | w_p(nzb,ny+1,:) = 0.0 |
---|
389 | |
---|
390 | ! |
---|
391 | !-- Top boundary at the outflow |
---|
392 | IF ( ibc_uv_t == 0 ) THEN |
---|
393 | u_p(nzt+1,ny+1,:) = ug(nzt+1) |
---|
394 | v_p(nzt+1,ny+1,:) = vg(nzt+1) |
---|
395 | ELSE |
---|
396 | u_p(nzt+1,ny+1,:) = u_p(nzt,nyn+1,:) |
---|
397 | v_p(nzt+1,ny+1,:) = v_p(nzt,nyn+1,:) |
---|
398 | ENDIF |
---|
399 | w_p(nzt:nzt+1,ny+1,:) = 0.0 |
---|
400 | |
---|
401 | ENDIF |
---|
402 | |
---|
403 | IF ( outflow_l .AND. & |
---|
404 | intermediate_timestep_count == intermediate_timestep_count_max ) & |
---|
405 | THEN |
---|
406 | |
---|
407 | c_max = dx / dt_3d |
---|
408 | |
---|
409 | DO j = nys-1, nyn+1 |
---|
410 | DO k = nzb+1, nzt+1 |
---|
411 | |
---|
412 | ! |
---|
413 | !-- First calculate the phase speeds for u,v, and w |
---|
414 | denom = u_m_l(k,j,0) - u_m_l(k,j,1) |
---|
415 | |
---|
416 | IF ( denom /= 0.0 ) THEN |
---|
417 | c_u = -c_max * ( u(k,j,0) - u_m_r(k,j,0) ) / denom |
---|
418 | IF ( c_u > 0.0 ) THEN |
---|
419 | c_u = 0.0 |
---|
420 | ELSEIF ( c_u < -c_max ) THEN |
---|
421 | c_u = -c_max |
---|
422 | ENDIF |
---|
423 | ELSE |
---|
424 | c_u = -c_max |
---|
425 | ENDIF |
---|
426 | |
---|
427 | denom = v_m_l(k,j,0) - v_m_l(k,j,1) |
---|
428 | |
---|
429 | IF ( denom /= 0.0 ) THEN |
---|
430 | c_v = -c_max * ( v(k,j,0) - v_m_l(k,j,0) ) / denom |
---|
431 | IF ( c_v < 0.0 ) THEN |
---|
432 | c_v = 0.0 |
---|
433 | ELSEIF ( c_v > c_max ) THEN |
---|
434 | c_v = c_max |
---|
435 | ENDIF |
---|
436 | ELSE |
---|
437 | c_v = c_max |
---|
438 | ENDIF |
---|
439 | |
---|
440 | denom = w_m_l(k,j,0) - w_m_l(k,j,1) |
---|
441 | |
---|
442 | IF ( denom /= 0.0 ) THEN |
---|
443 | c_w = -c_max * ( w(k,j,0) - w_m_l(k,j,0) ) / denom |
---|
444 | IF ( c_w < 0.0 ) THEN |
---|
445 | c_w = 0.0 |
---|
446 | ELSEIF ( c_w > c_max ) THEN |
---|
447 | c_w = c_max |
---|
448 | ENDIF |
---|
449 | ELSE |
---|
450 | c_w = c_max |
---|
451 | ENDIF |
---|
452 | |
---|
453 | ! |
---|
454 | !-- Calculate the new velocities |
---|
455 | u_p(k,j,-1) = u(k,j,-1) + dt_3d * c_u * & |
---|
456 | ( u(k,j,-1) - u(k,j,0) ) * ddx |
---|
457 | |
---|
458 | v_p(k,j,-1) = v(k,j,-1) + dt_3d * c_v * & |
---|
459 | ( v(k,j,-1) - v(k,j,0) ) * ddx |
---|
460 | |
---|
461 | w_p(k,j,-1) = w(k,j,-1) + dt_3d * c_w * & |
---|
462 | ( w(k,j,-1) - w(k,j,0) ) * ddx |
---|
463 | |
---|
464 | ! |
---|
465 | !-- Swap timelevels for the next timestep |
---|
466 | u_m_l(k,j,:) = u(k,j,-1:1) |
---|
467 | v_m_l(k,j,:) = v(k,j,-1:1) |
---|
468 | w_m_l(k,j,:) = w(k,j,-1:1) |
---|
469 | |
---|
470 | ENDDO |
---|
471 | ENDDO |
---|
472 | |
---|
473 | ! |
---|
474 | !-- Bottom boundary at the outflow |
---|
475 | IF ( ibc_uv_b == 0 ) THEN |
---|
476 | u_p(nzb,:,-1) = -u_p(nzb+1,:,-1) |
---|
477 | v_p(nzb,:,-1) = -v_p(nzb+1,:,-1) |
---|
478 | ELSE |
---|
479 | u_p(nzb,:,-1) = u_p(nzb+1,:,-1) |
---|
480 | v_p(nzb,:,-1) = v_p(nzb+1,:,-1) |
---|
481 | ENDIF |
---|
482 | w_p(nzb,:,-1) = 0.0 |
---|
483 | |
---|
484 | ! |
---|
485 | !-- Top boundary at the outflow |
---|
486 | IF ( ibc_uv_t == 0 ) THEN |
---|
487 | u_p(nzt+1,:,-1) = ug(nzt+1) |
---|
488 | v_p(nzt+1,:,-1) = vg(nzt+1) |
---|
489 | ELSE |
---|
490 | u_p(nzt+1,:,-1) = u_p(nzt,:,-1) |
---|
491 | v_p(nzt+1,:,-1) = v_p(nzt,:,-1) |
---|
492 | ENDIF |
---|
493 | w_p(nzt:nzt+1,:,-1) = 0.0 |
---|
494 | |
---|
495 | ENDIF |
---|
496 | |
---|
497 | IF ( outflow_r .AND. & |
---|
498 | intermediate_timestep_count == intermediate_timestep_count_max ) & |
---|
499 | THEN |
---|
500 | |
---|
501 | c_max = dx / dt_3d |
---|
502 | |
---|
503 | DO j = nys-1, nyn+1 |
---|
504 | DO k = nzb+1, nzt+1 |
---|
505 | |
---|
506 | ! |
---|
507 | !-- First calculate the phase speeds for u,v, and w |
---|
508 | denom = u_m_r(k,j,nx) - u_m_r(k,j,nx-1) |
---|
509 | |
---|
510 | IF ( denom /= 0.0 ) THEN |
---|
511 | c_u = -c_max * ( u(k,j,nx) - u_m_r(k,j,nx) ) / denom |
---|
512 | IF ( c_u < 0.0 ) THEN |
---|
513 | c_u = 0.0 |
---|
514 | ELSEIF ( c_u > c_max ) THEN |
---|
515 | c_u = c_max |
---|
516 | ENDIF |
---|
517 | ELSE |
---|
518 | c_u = c_max |
---|
519 | ENDIF |
---|
520 | |
---|
521 | denom = v_m_r(k,j,nx) - v_m_r(k,j,nx-1) |
---|
522 | |
---|
523 | IF ( denom /= 0.0 ) THEN |
---|
524 | c_v = -c_max * ( v(k,j,nx) - v_m_r(k,j,nx) ) / denom |
---|
525 | IF ( c_v < 0.0 ) THEN |
---|
526 | c_v = 0.0 |
---|
527 | ELSEIF ( c_v > c_max ) THEN |
---|
528 | c_v = c_max |
---|
529 | ENDIF |
---|
530 | ELSE |
---|
531 | c_v = c_max |
---|
532 | ENDIF |
---|
533 | |
---|
534 | denom = w_m_r(k,j,nx) - w_m_r(k,j,nx-1) |
---|
535 | |
---|
536 | IF ( denom /= 0.0 ) THEN |
---|
537 | c_w = -c_max * ( w(k,j,nx) - w_m_r(k,j,nx) ) / denom |
---|
538 | IF ( c_w < 0.0 ) THEN |
---|
539 | c_w = 0.0 |
---|
540 | ELSEIF ( c_w > c_max ) THEN |
---|
541 | c_w = c_max |
---|
542 | ENDIF |
---|
543 | ELSE |
---|
544 | c_w = c_max |
---|
545 | ENDIF |
---|
546 | |
---|
547 | ! |
---|
548 | !-- Calculate the new velocities |
---|
549 | u_p(k,j,nx+1) = u(k,j,nx+1) - dt_3d * c_u * & |
---|
550 | ( u(k,j,nx+1) - u(k,j,nx) ) * ddx |
---|
551 | |
---|
552 | v_p(k,j,nx+1) = v(k,j,nx+1) - dt_3d * c_v * & |
---|
553 | ( v(k,j,nx+1) - v(k,j,nx) ) * ddx |
---|
554 | |
---|
555 | w_p(k,j,nx+1) = w(k,j,nx+1) - dt_3d * c_w * & |
---|
556 | ( w(k,j,nx+1) - w(k,j,nx) ) * ddx |
---|
557 | |
---|
558 | ! |
---|
559 | !-- Swap timelevels for the next timestep |
---|
560 | u_m_r(k,j,:) = u(k,j,nx-1:nx+1) |
---|
561 | v_m_r(k,j,:) = v(k,j,nx-1:nx+1) |
---|
562 | w_m_r(k,j,:) = w(k,j,nx-1:nx+1) |
---|
563 | |
---|
564 | ENDDO |
---|
565 | ENDDO |
---|
566 | |
---|
567 | ! |
---|
568 | !-- Bottom boundary at the outflow |
---|
569 | IF ( ibc_uv_b == 0 ) THEN |
---|
570 | u_p(nzb,:,nx+1) = -u_p(nzb+1,:,nx+1) |
---|
571 | v_p(nzb,:,nx+1) = -v_p(nzb+1,:,nx+1) |
---|
572 | ELSE |
---|
573 | u_p(nzb,:,nx+1) = u_p(nzb+1,:,nx+1) |
---|
574 | v_p(nzb,:,nx+1) = v_p(nzb+1,:,nx+1) |
---|
575 | ENDIF |
---|
576 | w_p(nzb,:,nx+1) = 0.0 |
---|
577 | |
---|
578 | ! |
---|
579 | !-- Top boundary at the outflow |
---|
580 | IF ( ibc_uv_t == 0 ) THEN |
---|
581 | u_p(nzt+1,:,nx+1) = ug(nzt+1) |
---|
582 | v_p(nzt+1,:,nx+1) = vg(nzt+1) |
---|
583 | ELSE |
---|
584 | u_p(nzt+1,:,nx+1) = u_p(nzt,:,nx+1) |
---|
585 | v_p(nzt+1,:,nx+1) = v_p(nzt,:,nx+1) |
---|
586 | ENDIF |
---|
587 | w(nzt:nzt+1,:,nx+1) = 0.0 |
---|
588 | |
---|
589 | ENDIF |
---|
590 | |
---|
591 | |
---|
592 | END SUBROUTINE boundary_conds |
---|