1 | SUBROUTINE init_1d_model |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Current revisions: |
---|
5 | ! ----------------- |
---|
6 | ! all actions concerning leapfrog scheme removed |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: init_1d_model.f90 1001 2012-09-13 14:08:46Z raasch $ |
---|
11 | ! |
---|
12 | ! 996 2012-09-07 10:41:47Z raasch |
---|
13 | ! little reformatting |
---|
14 | ! |
---|
15 | ! 978 2012-08-09 08:28:32Z fricke |
---|
16 | ! roughness length for scalar quantities z0h1d added |
---|
17 | ! |
---|
18 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
19 | ! replaced mirror boundary conditions for u and v at the ground |
---|
20 | ! by dirichlet boundary conditions |
---|
21 | ! |
---|
22 | ! 254 2009-03-05 15:33:42Z heinze |
---|
23 | ! Output of messages replaced by message handling routine. |
---|
24 | ! |
---|
25 | ! 184 2008-08-04 15:53:39Z letzel |
---|
26 | ! provisional solution for run_control_1d output: add 'CALL check_open( 15 )' |
---|
27 | ! |
---|
28 | ! 135 2007-11-22 12:24:23Z raasch |
---|
29 | ! Bugfix: absolute value of f must be used when calculating the Blackadar |
---|
30 | ! mixing length |
---|
31 | ! |
---|
32 | ! 82 2007-04-16 15:40:52Z raasch |
---|
33 | ! Preprocessor strings for different linux clusters changed to "lc", |
---|
34 | ! routine local_flush is used for buffer flushing |
---|
35 | ! |
---|
36 | ! 75 2007-03-22 09:54:05Z raasch |
---|
37 | ! Bugfix: preset of tendencies te_em, te_um, te_vm, |
---|
38 | ! moisture renamed humidity |
---|
39 | ! |
---|
40 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
41 | ! |
---|
42 | ! Revision 1.21 2006/06/02 15:19:57 raasch |
---|
43 | ! cpp-directives extended for lctit |
---|
44 | ! |
---|
45 | ! Revision 1.1 1998/03/09 16:22:10 raasch |
---|
46 | ! Initial revision |
---|
47 | ! |
---|
48 | ! |
---|
49 | ! Description: |
---|
50 | ! ------------ |
---|
51 | ! 1D-model to initialize the 3D-arrays. |
---|
52 | ! The temperature profile is set as steady and a corresponding steady solution |
---|
53 | ! of the wind profile is being computed. |
---|
54 | ! All subroutines required can be found within this file. |
---|
55 | !------------------------------------------------------------------------------! |
---|
56 | |
---|
57 | USE arrays_3d |
---|
58 | USE indices |
---|
59 | USE model_1d |
---|
60 | USE control_parameters |
---|
61 | |
---|
62 | IMPLICIT NONE |
---|
63 | |
---|
64 | CHARACTER (LEN=9) :: time_to_string |
---|
65 | INTEGER :: k |
---|
66 | REAL :: lambda |
---|
67 | |
---|
68 | ! |
---|
69 | !-- Allocate required 1D-arrays |
---|
70 | ALLOCATE( e1d(nzb:nzt+1), e1d_p(nzb:nzt+1), & |
---|
71 | kh1d(nzb:nzt+1), km1d(nzb:nzt+1), & |
---|
72 | l_black(nzb:nzt+1), l1d(nzb:nzt+1), & |
---|
73 | rif1d(nzb:nzt+1), te_e(nzb:nzt+1), & |
---|
74 | te_em(nzb:nzt+1), te_u(nzb:nzt+1), te_um(nzb:nzt+1), & |
---|
75 | te_v(nzb:nzt+1), te_vm(nzb:nzt+1), u1d(nzb:nzt+1), & |
---|
76 | u1d_p(nzb:nzt+1), v1d(nzb:nzt+1), & |
---|
77 | v1d_p(nzb:nzt+1) ) |
---|
78 | |
---|
79 | ! |
---|
80 | !-- Initialize arrays |
---|
81 | IF ( constant_diffusion ) THEN |
---|
82 | km1d = km_constant |
---|
83 | kh1d = km_constant / prandtl_number |
---|
84 | ELSE |
---|
85 | e1d = 0.0; e1d_p = 0.0 |
---|
86 | kh1d = 0.0; km1d = 0.0 |
---|
87 | rif1d = 0.0 |
---|
88 | ! |
---|
89 | !-- Compute the mixing length |
---|
90 | l_black(nzb) = 0.0 |
---|
91 | |
---|
92 | IF ( TRIM( mixing_length_1d ) == 'blackadar' ) THEN |
---|
93 | ! |
---|
94 | !-- Blackadar mixing length |
---|
95 | IF ( f /= 0.0 ) THEN |
---|
96 | lambda = 2.7E-4 * SQRT( ug(nzt+1)**2 + vg(nzt+1)**2 ) / & |
---|
97 | ABS( f ) + 1E-10 |
---|
98 | ELSE |
---|
99 | lambda = 30.0 |
---|
100 | ENDIF |
---|
101 | |
---|
102 | DO k = nzb+1, nzt+1 |
---|
103 | l_black(k) = kappa * zu(k) / ( 1.0 + kappa * zu(k) / lambda ) |
---|
104 | ENDDO |
---|
105 | |
---|
106 | ELSEIF ( TRIM( mixing_length_1d ) == 'as_in_3d_model' ) THEN |
---|
107 | ! |
---|
108 | !-- Use the same mixing length as in 3D model |
---|
109 | l_black(1:nzt) = l_grid |
---|
110 | l_black(nzt+1) = l_black(nzt) |
---|
111 | |
---|
112 | ENDIF |
---|
113 | |
---|
114 | ! |
---|
115 | !-- Adjust mixing length to the prandtl mixing length (within the prandtl |
---|
116 | !-- layer) |
---|
117 | IF ( adjust_mixing_length .AND. prandtl_layer ) THEN |
---|
118 | k = nzb+1 |
---|
119 | l_black(k) = MIN( l_black(k), kappa * zu(k) ) |
---|
120 | ENDIF |
---|
121 | ENDIF |
---|
122 | l1d = l_black |
---|
123 | u1d = u_init |
---|
124 | u1d_p = u_init |
---|
125 | v1d = v_init |
---|
126 | v1d_p = v_init |
---|
127 | |
---|
128 | ! |
---|
129 | !-- Set initial horizontal velocities at the lowest grid levels to a very small |
---|
130 | !-- value in order to avoid too small time steps caused by the diffusion limit |
---|
131 | !-- in the initial phase of a run (at k=1, dz/2 occurs in the limiting formula!) |
---|
132 | u1d(0:1) = 0.1 |
---|
133 | u1d_p(0:1) = 0.1 |
---|
134 | v1d(0:1) = 0.1 |
---|
135 | v1d_p(0:1) = 0.1 |
---|
136 | |
---|
137 | ! |
---|
138 | !-- For u*, theta* and the momentum fluxes plausible values are set |
---|
139 | IF ( prandtl_layer ) THEN |
---|
140 | us1d = 0.1 ! without initial friction the flow would not change |
---|
141 | ELSE |
---|
142 | e1d(nzb+1) = 1.0 |
---|
143 | km1d(nzb+1) = 1.0 |
---|
144 | us1d = 0.0 |
---|
145 | ENDIF |
---|
146 | ts1d = 0.0 |
---|
147 | usws1d = 0.0 |
---|
148 | vsws1d = 0.0 |
---|
149 | z01d = roughness_length |
---|
150 | z0h1d = z0h_factor * z01d |
---|
151 | IF ( humidity .OR. passive_scalar ) qs1d = 0.0 |
---|
152 | |
---|
153 | ! |
---|
154 | !-- Tendencies must be preset in order to avoid runtime errors within the |
---|
155 | !-- first Runge-Kutta step |
---|
156 | te_em = 0.0 |
---|
157 | te_um = 0.0 |
---|
158 | te_vm = 0.0 |
---|
159 | |
---|
160 | ! |
---|
161 | !-- Set start time in hh:mm:ss - format |
---|
162 | simulated_time_chr = time_to_string( simulated_time_1d ) |
---|
163 | |
---|
164 | ! |
---|
165 | !-- Integrate the 1D-model equations using the leap-frog scheme |
---|
166 | CALL time_integration_1d |
---|
167 | |
---|
168 | |
---|
169 | END SUBROUTINE init_1d_model |
---|
170 | |
---|
171 | |
---|
172 | |
---|
173 | SUBROUTINE time_integration_1d |
---|
174 | |
---|
175 | !------------------------------------------------------------------------------! |
---|
176 | ! Description: |
---|
177 | ! ------------ |
---|
178 | ! Leap-frog time differencing scheme for the 1D-model. |
---|
179 | !------------------------------------------------------------------------------! |
---|
180 | |
---|
181 | USE arrays_3d |
---|
182 | USE control_parameters |
---|
183 | USE indices |
---|
184 | USE model_1d |
---|
185 | USE pegrid |
---|
186 | |
---|
187 | IMPLICIT NONE |
---|
188 | |
---|
189 | CHARACTER (LEN=9) :: time_to_string |
---|
190 | INTEGER :: k |
---|
191 | REAL :: a, b, dissipation, dpt_dz, flux, kmzm, kmzp, l_stable, pt_0, & |
---|
192 | uv_total |
---|
193 | |
---|
194 | ! |
---|
195 | !-- Determine the time step at the start of a 1D-simulation and |
---|
196 | !-- determine and printout quantities used for run control |
---|
197 | CALL timestep_1d |
---|
198 | CALL run_control_1d |
---|
199 | |
---|
200 | ! |
---|
201 | !-- Start of time loop |
---|
202 | DO WHILE ( simulated_time_1d < end_time_1d .AND. .NOT. stop_dt_1d ) |
---|
203 | |
---|
204 | ! |
---|
205 | !-- Depending on the timestep scheme, carry out one or more intermediate |
---|
206 | !-- timesteps |
---|
207 | |
---|
208 | intermediate_timestep_count = 0 |
---|
209 | DO WHILE ( intermediate_timestep_count < & |
---|
210 | intermediate_timestep_count_max ) |
---|
211 | |
---|
212 | intermediate_timestep_count = intermediate_timestep_count + 1 |
---|
213 | |
---|
214 | CALL timestep_scheme_steering |
---|
215 | |
---|
216 | ! |
---|
217 | !-- Compute all tendency terms. If a Prandtl-layer is simulated, k starts |
---|
218 | !-- at nzb+2. |
---|
219 | DO k = nzb_diff, nzt |
---|
220 | |
---|
221 | kmzm = 0.5 * ( km1d(k-1) + km1d(k) ) |
---|
222 | kmzp = 0.5 * ( km1d(k) + km1d(k+1) ) |
---|
223 | ! |
---|
224 | !-- u-component |
---|
225 | te_u(k) = f * ( v1d(k) - vg(k) ) + ( & |
---|
226 | kmzp * ( u1d(k+1) - u1d(k) ) * ddzu(k+1) & |
---|
227 | - kmzm * ( u1d(k) - u1d(k-1) ) * ddzu(k) & |
---|
228 | ) * ddzw(k) |
---|
229 | ! |
---|
230 | !-- v-component |
---|
231 | te_v(k) = -f * ( u1d(k) - ug(k) ) + ( & |
---|
232 | kmzp * ( v1d(k+1) - v1d(k) ) * ddzu(k+1) & |
---|
233 | - kmzm * ( v1d(k) - v1d(k-1) ) * ddzu(k) & |
---|
234 | ) * ddzw(k) |
---|
235 | ENDDO |
---|
236 | IF ( .NOT. constant_diffusion ) THEN |
---|
237 | DO k = nzb_diff, nzt |
---|
238 | ! |
---|
239 | !-- TKE |
---|
240 | kmzm = 0.5 * ( km1d(k-1) + km1d(k) ) |
---|
241 | kmzp = 0.5 * ( km1d(k) + km1d(k+1) ) |
---|
242 | IF ( .NOT. humidity ) THEN |
---|
243 | pt_0 = pt_init(k) |
---|
244 | flux = ( pt_init(k+1)-pt_init(k-1) ) * dd2zu(k) |
---|
245 | ELSE |
---|
246 | pt_0 = pt_init(k) * ( 1.0 + 0.61 * q_init(k) ) |
---|
247 | flux = ( ( pt_init(k+1) - pt_init(k-1) ) + & |
---|
248 | 0.61 * pt_init(k) * ( q_init(k+1) - q_init(k-1) ) & |
---|
249 | ) * dd2zu(k) |
---|
250 | ENDIF |
---|
251 | |
---|
252 | IF ( dissipation_1d == 'detering' ) THEN |
---|
253 | ! |
---|
254 | !-- According to Detering, c_e=0.064 |
---|
255 | dissipation = 0.064 * e1d(k) * SQRT( e1d(k) ) / l1d(k) |
---|
256 | ELSEIF ( dissipation_1d == 'as_in_3d_model' ) THEN |
---|
257 | dissipation = ( 0.19 + 0.74 * l1d(k) / l_grid(k) ) & |
---|
258 | * e1d(k) * SQRT( e1d(k) ) / l1d(k) |
---|
259 | ENDIF |
---|
260 | |
---|
261 | te_e(k) = km1d(k) * ( ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2& |
---|
262 | + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2& |
---|
263 | ) & |
---|
264 | - g / pt_0 * kh1d(k) * flux & |
---|
265 | + ( & |
---|
266 | kmzp * ( e1d(k+1) - e1d(k) ) * ddzu(k+1) & |
---|
267 | - kmzm * ( e1d(k) - e1d(k-1) ) * ddzu(k) & |
---|
268 | ) * ddzw(k) & |
---|
269 | - dissipation |
---|
270 | ENDDO |
---|
271 | ENDIF |
---|
272 | |
---|
273 | ! |
---|
274 | !-- Tendency terms at the top of the Prandtl-layer. |
---|
275 | !-- Finite differences of the momentum fluxes are computed using half the |
---|
276 | !-- normal grid length (2.0*ddzw(k)) for the sake of enhanced accuracy |
---|
277 | IF ( prandtl_layer ) THEN |
---|
278 | |
---|
279 | k = nzb+1 |
---|
280 | kmzm = 0.5 * ( km1d(k-1) + km1d(k) ) |
---|
281 | kmzp = 0.5 * ( km1d(k) + km1d(k+1) ) |
---|
282 | IF ( .NOT. humidity ) THEN |
---|
283 | pt_0 = pt_init(k) |
---|
284 | flux = ( pt_init(k+1)-pt_init(k-1) ) * dd2zu(k) |
---|
285 | ELSE |
---|
286 | pt_0 = pt_init(k) * ( 1.0 + 0.61 * q_init(k) ) |
---|
287 | flux = ( ( pt_init(k+1) - pt_init(k-1) ) + & |
---|
288 | 0.61 * pt_init(k) * ( q_init(k+1) - q_init(k-1) ) & |
---|
289 | ) * dd2zu(k) |
---|
290 | ENDIF |
---|
291 | |
---|
292 | IF ( dissipation_1d == 'detering' ) THEN |
---|
293 | ! |
---|
294 | !-- According to Detering, c_e=0.064 |
---|
295 | dissipation = 0.064 * e1d(k) * SQRT( e1d(k) ) / l1d(k) |
---|
296 | ELSEIF ( dissipation_1d == 'as_in_3d_model' ) THEN |
---|
297 | dissipation = ( 0.19 + 0.74 * l1d(k) / l_grid(k) ) & |
---|
298 | * e1d(k) * SQRT( e1d(k) ) / l1d(k) |
---|
299 | ENDIF |
---|
300 | |
---|
301 | ! |
---|
302 | !-- u-component |
---|
303 | te_u(k) = f * ( v1d(k) - vg(k) ) + ( & |
---|
304 | kmzp * ( u1d(k+1) - u1d(k) ) * ddzu(k+1) + usws1d & |
---|
305 | ) * 2.0 * ddzw(k) |
---|
306 | ! |
---|
307 | !-- v-component |
---|
308 | te_v(k) = -f * ( u1d(k) - ug(k) ) + ( & |
---|
309 | kmzp * ( v1d(k+1) - v1d(k) ) * ddzu(k+1) + vsws1d & |
---|
310 | ) * 2.0 * ddzw(k) |
---|
311 | ! |
---|
312 | !-- TKE |
---|
313 | te_e(k) = km1d(k) * ( ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2 & |
---|
314 | + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2 & |
---|
315 | ) & |
---|
316 | - g / pt_0 * kh1d(k) * flux & |
---|
317 | + ( & |
---|
318 | kmzp * ( e1d(k+1) - e1d(k) ) * ddzu(k+1) & |
---|
319 | - kmzm * ( e1d(k) - e1d(k-1) ) * ddzu(k) & |
---|
320 | ) * ddzw(k) & |
---|
321 | - dissipation |
---|
322 | ENDIF |
---|
323 | |
---|
324 | ! |
---|
325 | !-- Prognostic equations for all 1D variables |
---|
326 | DO k = nzb+1, nzt |
---|
327 | |
---|
328 | u1d_p(k) = u1d(k) + dt_1d * ( tsc(2) * te_u(k) + & |
---|
329 | tsc(3) * te_um(k) ) |
---|
330 | v1d_p(k) = v1d(k) + dt_1d * ( tsc(2) * te_v(k) + & |
---|
331 | tsc(3) * te_vm(k) ) |
---|
332 | |
---|
333 | ENDDO |
---|
334 | IF ( .NOT. constant_diffusion ) THEN |
---|
335 | DO k = nzb+1, nzt |
---|
336 | |
---|
337 | e1d_p(k) = e1d(k) + dt_1d * ( tsc(2) * te_e(k) + & |
---|
338 | tsc(3) * te_em(k) ) |
---|
339 | |
---|
340 | ENDDO |
---|
341 | ! |
---|
342 | !-- Eliminate negative TKE values, which can result from the |
---|
343 | !-- integration due to numerical inaccuracies. In such cases the TKE |
---|
344 | !-- value is reduced to 10 percent of its old value. |
---|
345 | WHERE ( e1d_p < 0.0 ) e1d_p = 0.1 * e1d |
---|
346 | ENDIF |
---|
347 | |
---|
348 | ! |
---|
349 | !-- Calculate tendencies for the next Runge-Kutta step |
---|
350 | IF ( timestep_scheme(1:5) == 'runge' ) THEN |
---|
351 | IF ( intermediate_timestep_count == 1 ) THEN |
---|
352 | |
---|
353 | DO k = nzb+1, nzt |
---|
354 | te_um(k) = te_u(k) |
---|
355 | te_vm(k) = te_v(k) |
---|
356 | ENDDO |
---|
357 | |
---|
358 | IF ( .NOT. constant_diffusion ) THEN |
---|
359 | DO k = nzb+1, nzt |
---|
360 | te_em(k) = te_e(k) |
---|
361 | ENDDO |
---|
362 | ENDIF |
---|
363 | |
---|
364 | ELSEIF ( intermediate_timestep_count < & |
---|
365 | intermediate_timestep_count_max ) THEN |
---|
366 | |
---|
367 | DO k = nzb+1, nzt |
---|
368 | te_um(k) = -9.5625 * te_u(k) + 5.3125 * te_um(k) |
---|
369 | te_vm(k) = -9.5625 * te_v(k) + 5.3125 * te_vm(k) |
---|
370 | ENDDO |
---|
371 | |
---|
372 | IF ( .NOT. constant_diffusion ) THEN |
---|
373 | DO k = nzb+1, nzt |
---|
374 | te_em(k) = -9.5625 * te_e(k) + 5.3125 * te_em(k) |
---|
375 | ENDDO |
---|
376 | ENDIF |
---|
377 | |
---|
378 | ENDIF |
---|
379 | ENDIF |
---|
380 | |
---|
381 | |
---|
382 | ! |
---|
383 | !-- Boundary conditions for the prognostic variables. |
---|
384 | !-- At the top boundary (nzt+1) u,v and e keep their initial values |
---|
385 | !-- (ug(nzt+1), vg(nzt+1), 0), at the bottom boundary the mirror |
---|
386 | !-- boundary condition applies to u and v. |
---|
387 | !-- The boundary condition for e is set further below ( (u*/cm)**2 ). |
---|
388 | ! u1d_p(nzb) = -u1d_p(nzb+1) |
---|
389 | ! v1d_p(nzb) = -v1d_p(nzb+1) |
---|
390 | |
---|
391 | u1d_p(nzb) = 0.0 |
---|
392 | v1d_p(nzb) = 0.0 |
---|
393 | |
---|
394 | ! |
---|
395 | !-- Swap the time levels in preparation for the next time step. |
---|
396 | u1d = u1d_p |
---|
397 | v1d = v1d_p |
---|
398 | IF ( .NOT. constant_diffusion ) THEN |
---|
399 | e1d = e1d_p |
---|
400 | ENDIF |
---|
401 | |
---|
402 | ! |
---|
403 | !-- Compute diffusion quantities |
---|
404 | IF ( .NOT. constant_diffusion ) THEN |
---|
405 | |
---|
406 | ! |
---|
407 | !-- First compute the vertical fluxes in the Prandtl-layer |
---|
408 | IF ( prandtl_layer ) THEN |
---|
409 | ! |
---|
410 | !-- Compute theta* using Rif numbers of the previous time step |
---|
411 | IF ( rif1d(1) >= 0.0 ) THEN |
---|
412 | ! |
---|
413 | !-- Stable stratification |
---|
414 | ts1d = kappa * ( pt_init(nzb+1) - pt_init(nzb) ) / & |
---|
415 | ( LOG( zu(nzb+1) / z0h1d ) + 5.0 * rif1d(nzb+1) * & |
---|
416 | ( zu(nzb+1) - z0h1d ) / zu(nzb+1) & |
---|
417 | ) |
---|
418 | ELSE |
---|
419 | ! |
---|
420 | !-- Unstable stratification |
---|
421 | a = SQRT( 1.0 - 16.0 * rif1d(nzb+1) ) |
---|
422 | b = SQRT( 1.0 - 16.0 * rif1d(nzb+1) / zu(nzb+1) * z0h1d ) |
---|
423 | ! |
---|
424 | !-- In the borderline case the formula for stable stratification |
---|
425 | !-- must be applied, because otherwise a zero division would |
---|
426 | !-- occur in the argument of the logarithm. |
---|
427 | IF ( a == 0.0 .OR. b == 0.0 ) THEN |
---|
428 | ts1d = kappa * ( pt_init(nzb+1) - pt_init(nzb) ) / & |
---|
429 | ( LOG( zu(nzb+1) / z0h1d ) + 5.0 * rif1d(nzb+1) * & |
---|
430 | ( zu(nzb+1) - z0h1d ) / zu(nzb+1) & |
---|
431 | ) |
---|
432 | ELSE |
---|
433 | ts1d = kappa * ( pt_init(nzb+1) - pt_init(nzb) ) / & |
---|
434 | LOG( (a-1.0) / (a+1.0) * (b+1.0) / (b-1.0) ) |
---|
435 | ENDIF |
---|
436 | ENDIF |
---|
437 | |
---|
438 | ENDIF ! prandtl_layer |
---|
439 | |
---|
440 | ! |
---|
441 | !-- Compute the Richardson-flux numbers, |
---|
442 | !-- first at the top of the Prandtl-layer using u* of the previous |
---|
443 | !-- time step (+1E-30, if u* = 0), then in the remaining area. There |
---|
444 | !-- the rif-numbers of the previous time step are used. |
---|
445 | |
---|
446 | IF ( prandtl_layer ) THEN |
---|
447 | IF ( .NOT. humidity ) THEN |
---|
448 | pt_0 = pt_init(nzb+1) |
---|
449 | flux = ts1d |
---|
450 | ELSE |
---|
451 | pt_0 = pt_init(nzb+1) * ( 1.0 + 0.61 * q_init(nzb+1) ) |
---|
452 | flux = ts1d + 0.61 * pt_init(k) * qs1d |
---|
453 | ENDIF |
---|
454 | rif1d(nzb+1) = zu(nzb+1) * kappa * g * flux / & |
---|
455 | ( pt_0 * ( us1d**2 + 1E-30 ) ) |
---|
456 | ENDIF |
---|
457 | |
---|
458 | DO k = nzb_diff, nzt |
---|
459 | IF ( .NOT. humidity ) THEN |
---|
460 | pt_0 = pt_init(k) |
---|
461 | flux = ( pt_init(k+1) - pt_init(k-1) ) * dd2zu(k) |
---|
462 | ELSE |
---|
463 | pt_0 = pt_init(k) * ( 1.0 + 0.61 * q_init(k) ) |
---|
464 | flux = ( ( pt_init(k+1) - pt_init(k-1) ) & |
---|
465 | + 0.61 * pt_init(k) * ( q_init(k+1) - q_init(k-1) )& |
---|
466 | ) * dd2zu(k) |
---|
467 | ENDIF |
---|
468 | IF ( rif1d(k) >= 0.0 ) THEN |
---|
469 | rif1d(k) = g / pt_0 * flux / & |
---|
470 | ( ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2 & |
---|
471 | + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2 & |
---|
472 | + 1E-30 & |
---|
473 | ) |
---|
474 | ELSE |
---|
475 | rif1d(k) = g / pt_0 * flux / & |
---|
476 | ( ( ( u1d(k+1) - u1d(k-1) ) * dd2zu(k) )**2 & |
---|
477 | + ( ( v1d(k+1) - v1d(k-1) ) * dd2zu(k) )**2 & |
---|
478 | + 1E-30 & |
---|
479 | ) * ( 1.0 - 16.0 * rif1d(k) )**0.25 |
---|
480 | ENDIF |
---|
481 | ENDDO |
---|
482 | ! |
---|
483 | !-- Richardson-numbers must remain restricted to a realistic value |
---|
484 | !-- range. It is exceeded excessively for very small velocities |
---|
485 | !-- (u,v --> 0). |
---|
486 | WHERE ( rif1d < rif_min ) rif1d = rif_min |
---|
487 | WHERE ( rif1d > rif_max ) rif1d = rif_max |
---|
488 | |
---|
489 | ! |
---|
490 | !-- Compute u* from the absolute velocity value |
---|
491 | IF ( prandtl_layer ) THEN |
---|
492 | uv_total = SQRT( u1d(nzb+1)**2 + v1d(nzb+1)**2 ) |
---|
493 | |
---|
494 | IF ( rif1d(nzb+1) >= 0.0 ) THEN |
---|
495 | ! |
---|
496 | !-- Stable stratification |
---|
497 | us1d = kappa * uv_total / ( & |
---|
498 | LOG( zu(nzb+1) / z01d ) + 5.0 * rif1d(nzb+1) * & |
---|
499 | ( zu(nzb+1) - z01d ) / zu(nzb+1) & |
---|
500 | ) |
---|
501 | ELSE |
---|
502 | ! |
---|
503 | !-- Unstable stratification |
---|
504 | a = 1.0 / SQRT( SQRT( 1.0 - 16.0 * rif1d(nzb+1) ) ) |
---|
505 | b = 1.0 / SQRT( SQRT( 1.0 - 16.0 * rif1d(nzb+1) / zu(nzb+1) & |
---|
506 | * z01d ) ) |
---|
507 | ! |
---|
508 | !-- In the borderline case the formula for stable stratification |
---|
509 | !-- must be applied, because otherwise a zero division would |
---|
510 | !-- occur in the argument of the logarithm. |
---|
511 | IF ( a == 1.0 .OR. b == 1.0 ) THEN |
---|
512 | us1d = kappa * uv_total / ( & |
---|
513 | LOG( zu(nzb+1) / z01d ) + & |
---|
514 | 5.0 * rif1d(nzb+1) * ( zu(nzb+1) - z01d ) / & |
---|
515 | zu(nzb+1) ) |
---|
516 | ELSE |
---|
517 | us1d = kappa * uv_total / ( & |
---|
518 | LOG( (1.0+b) / (1.0-b) * (1.0-a) / (1.0+a) ) +& |
---|
519 | 2.0 * ( ATAN( b ) - ATAN( a ) ) & |
---|
520 | ) |
---|
521 | ENDIF |
---|
522 | ENDIF |
---|
523 | |
---|
524 | ! |
---|
525 | !-- Compute the momentum fluxes for the diffusion terms |
---|
526 | usws1d = - u1d(nzb+1) / uv_total * us1d**2 |
---|
527 | vsws1d = - v1d(nzb+1) / uv_total * us1d**2 |
---|
528 | |
---|
529 | ! |
---|
530 | !-- Boundary condition for the turbulent kinetic energy at the top |
---|
531 | !-- of the Prandtl-layer. c_m = 0.4 according to Detering. |
---|
532 | !-- Additional Neumann condition de/dz = 0 at nzb is set to ensure |
---|
533 | !-- compatibility with the 3D model. |
---|
534 | IF ( ibc_e_b == 2 ) THEN |
---|
535 | e1d(nzb+1) = ( us1d / 0.1 )**2 |
---|
536 | ! e1d(nzb+1) = ( us1d / 0.4 )**2 !not used so far, see also |
---|
537 | !prandtl_fluxes |
---|
538 | ENDIF |
---|
539 | e1d(nzb) = e1d(nzb+1) |
---|
540 | |
---|
541 | IF ( humidity .OR. passive_scalar ) THEN |
---|
542 | ! |
---|
543 | !-- Compute q* |
---|
544 | IF ( rif1d(1) >= 0.0 ) THEN |
---|
545 | ! |
---|
546 | !-- Stable stratification |
---|
547 | qs1d = kappa * ( q_init(nzb+1) - q_init(nzb) ) / & |
---|
548 | ( LOG( zu(nzb+1) / z0h1d ) + 5.0 * rif1d(nzb+1) * & |
---|
549 | ( zu(nzb+1) - z0h1d ) / zu(nzb+1) & |
---|
550 | ) |
---|
551 | ELSE |
---|
552 | ! |
---|
553 | !-- Unstable stratification |
---|
554 | a = SQRT( 1.0 - 16.0 * rif1d(nzb+1) ) |
---|
555 | b = SQRT( 1.0 - 16.0 * rif1d(nzb+1) / zu(nzb+1) * z0h1d ) |
---|
556 | ! |
---|
557 | !-- In the borderline case the formula for stable stratification |
---|
558 | !-- must be applied, because otherwise a zero division would |
---|
559 | !-- occur in the argument of the logarithm. |
---|
560 | IF ( a == 1.0 .OR. b == 1.0 ) THEN |
---|
561 | qs1d = kappa * ( q_init(nzb+1) - q_init(nzb) ) / & |
---|
562 | ( LOG( zu(nzb+1) / z0h1d ) + 5.0 * rif1d(nzb+1) * & |
---|
563 | ( zu(nzb+1) - z0h1d ) / zu(nzb+1) & |
---|
564 | ) |
---|
565 | ELSE |
---|
566 | qs1d = kappa * ( q_init(nzb+1) - q_init(nzb) ) / & |
---|
567 | LOG( (a-1.0) / (a+1.0) * (b+1.0) / (b-1.0) ) |
---|
568 | ENDIF |
---|
569 | ENDIF |
---|
570 | ELSE |
---|
571 | qs1d = 0.0 |
---|
572 | ENDIF |
---|
573 | |
---|
574 | ENDIF ! prandtl_layer |
---|
575 | |
---|
576 | ! |
---|
577 | !-- Compute the diabatic mixing length |
---|
578 | IF ( mixing_length_1d == 'blackadar' ) THEN |
---|
579 | DO k = nzb+1, nzt |
---|
580 | IF ( rif1d(k) >= 0.0 ) THEN |
---|
581 | l1d(k) = l_black(k) / ( 1.0 + 5.0 * rif1d(k) ) |
---|
582 | ELSE |
---|
583 | l1d(k) = l_black(k) * ( 1.0 - 16.0 * rif1d(k) )**0.25 |
---|
584 | ENDIF |
---|
585 | l1d(k) = l_black(k) |
---|
586 | ENDDO |
---|
587 | |
---|
588 | ELSEIF ( mixing_length_1d == 'as_in_3d_model' ) THEN |
---|
589 | DO k = nzb+1, nzt |
---|
590 | dpt_dz = ( pt_init(k+1) - pt_init(k-1) ) * dd2zu(k) |
---|
591 | IF ( dpt_dz > 0.0 ) THEN |
---|
592 | l_stable = 0.76 * SQRT( e1d(k) ) / & |
---|
593 | SQRT( g / pt_init(k) * dpt_dz ) + 1E-5 |
---|
594 | ELSE |
---|
595 | l_stable = l_grid(k) |
---|
596 | ENDIF |
---|
597 | l1d(k) = MIN( l_grid(k), l_stable ) |
---|
598 | ENDDO |
---|
599 | ENDIF |
---|
600 | |
---|
601 | ! |
---|
602 | !-- Adjust mixing length to the prandtl mixing length |
---|
603 | IF ( adjust_mixing_length .AND. prandtl_layer ) THEN |
---|
604 | k = nzb+1 |
---|
605 | IF ( rif1d(k) >= 0.0 ) THEN |
---|
606 | l1d(k) = MIN( l1d(k), kappa * zu(k) / ( 1.0 + 5.0 * & |
---|
607 | rif1d(k) ) ) |
---|
608 | ELSE |
---|
609 | l1d(k) = MIN( l1d(k), kappa * zu(k) * & |
---|
610 | SQRT( SQRT( 1.0 - 16.0 * rif1d(k) ) ) ) |
---|
611 | ENDIF |
---|
612 | ENDIF |
---|
613 | |
---|
614 | ! |
---|
615 | !-- Compute the diffusion coefficients for momentum via the |
---|
616 | !-- corresponding Prandtl-layer relationship and according to |
---|
617 | !-- Prandtl-Kolmogorov, respectively. The unstable stratification is |
---|
618 | !-- computed via the adiabatic mixing length, for the unstability has |
---|
619 | !-- already been taken account of via the TKE (cf. also Diss.). |
---|
620 | IF ( prandtl_layer ) THEN |
---|
621 | IF ( rif1d(nzb+1) >= 0.0 ) THEN |
---|
622 | km1d(nzb+1) = us1d * kappa * zu(nzb+1) / & |
---|
623 | ( 1.0 + 5.0 * rif1d(nzb+1) ) |
---|
624 | ELSE |
---|
625 | km1d(nzb+1) = us1d * kappa * zu(nzb+1) * & |
---|
626 | ( 1.0 - 16.0 * rif1d(nzb+1) )**0.25 |
---|
627 | ENDIF |
---|
628 | ENDIF |
---|
629 | DO k = nzb_diff, nzt |
---|
630 | ! km1d(k) = 0.4 * SQRT( e1d(k) ) !changed: adjustment to 3D-model |
---|
631 | km1d(k) = 0.1 * SQRT( e1d(k) ) |
---|
632 | IF ( rif1d(k) >= 0.0 ) THEN |
---|
633 | km1d(k) = km1d(k) * l1d(k) |
---|
634 | ELSE |
---|
635 | km1d(k) = km1d(k) * l_black(k) |
---|
636 | ENDIF |
---|
637 | ENDDO |
---|
638 | |
---|
639 | ! |
---|
640 | !-- Add damping layer |
---|
641 | DO k = damp_level_ind_1d+1, nzt+1 |
---|
642 | km1d(k) = 1.1 * km1d(k-1) |
---|
643 | km1d(k) = MIN( km1d(k), 10.0 ) |
---|
644 | ENDDO |
---|
645 | |
---|
646 | ! |
---|
647 | !-- Compute the diffusion coefficient for heat via the relationship |
---|
648 | !-- kh = phim / phih * km |
---|
649 | DO k = nzb+1, nzt |
---|
650 | IF ( rif1d(k) >= 0.0 ) THEN |
---|
651 | kh1d(k) = km1d(k) |
---|
652 | ELSE |
---|
653 | kh1d(k) = km1d(k) * ( 1.0 - 16.0 * rif1d(k) )**0.25 |
---|
654 | ENDIF |
---|
655 | ENDDO |
---|
656 | |
---|
657 | ENDIF ! .NOT. constant_diffusion |
---|
658 | |
---|
659 | ENDDO ! intermediate step loop |
---|
660 | |
---|
661 | ! |
---|
662 | !-- Increment simulated time and output times |
---|
663 | current_timestep_number_1d = current_timestep_number_1d + 1 |
---|
664 | simulated_time_1d = simulated_time_1d + dt_1d |
---|
665 | simulated_time_chr = time_to_string( simulated_time_1d ) |
---|
666 | time_pr_1d = time_pr_1d + dt_1d |
---|
667 | time_run_control_1d = time_run_control_1d + dt_1d |
---|
668 | |
---|
669 | ! |
---|
670 | !-- Determine and print out quantities for run control |
---|
671 | IF ( time_run_control_1d >= dt_run_control_1d ) THEN |
---|
672 | CALL run_control_1d |
---|
673 | time_run_control_1d = time_run_control_1d - dt_run_control_1d |
---|
674 | ENDIF |
---|
675 | |
---|
676 | ! |
---|
677 | !-- Profile output on file |
---|
678 | IF ( time_pr_1d >= dt_pr_1d ) THEN |
---|
679 | CALL print_1d_model |
---|
680 | time_pr_1d = time_pr_1d - dt_pr_1d |
---|
681 | ENDIF |
---|
682 | |
---|
683 | ! |
---|
684 | !-- Determine size of next time step |
---|
685 | CALL timestep_1d |
---|
686 | |
---|
687 | ENDDO ! time loop |
---|
688 | |
---|
689 | |
---|
690 | END SUBROUTINE time_integration_1d |
---|
691 | |
---|
692 | |
---|
693 | SUBROUTINE run_control_1d |
---|
694 | |
---|
695 | !------------------------------------------------------------------------------! |
---|
696 | ! Description: |
---|
697 | ! ------------ |
---|
698 | ! Compute and print out quantities for run control of the 1D model. |
---|
699 | !------------------------------------------------------------------------------! |
---|
700 | |
---|
701 | USE constants |
---|
702 | USE indices |
---|
703 | USE model_1d |
---|
704 | USE pegrid |
---|
705 | USE control_parameters |
---|
706 | |
---|
707 | IMPLICIT NONE |
---|
708 | |
---|
709 | INTEGER :: k |
---|
710 | REAL :: alpha, energy, umax, uv_total, vmax |
---|
711 | |
---|
712 | ! |
---|
713 | !-- Output |
---|
714 | IF ( myid == 0 ) THEN |
---|
715 | ! |
---|
716 | !-- If necessary, write header |
---|
717 | IF ( .NOT. run_control_header_1d ) THEN |
---|
718 | CALL check_open( 15 ) |
---|
719 | WRITE ( 15, 100 ) |
---|
720 | run_control_header_1d = .TRUE. |
---|
721 | ENDIF |
---|
722 | |
---|
723 | ! |
---|
724 | !-- Compute control quantities |
---|
725 | !-- grid level nzp is excluded due to mirror boundary condition |
---|
726 | umax = 0.0; vmax = 0.0; energy = 0.0 |
---|
727 | DO k = nzb+1, nzt+1 |
---|
728 | umax = MAX( ABS( umax ), ABS( u1d(k) ) ) |
---|
729 | vmax = MAX( ABS( vmax ), ABS( v1d(k) ) ) |
---|
730 | energy = energy + 0.5 * ( u1d(k)**2 + v1d(k)**2 ) |
---|
731 | ENDDO |
---|
732 | energy = energy / REAL( nzt - nzb + 1 ) |
---|
733 | |
---|
734 | uv_total = SQRT( u1d(nzb+1)**2 + v1d(nzb+1)**2 ) |
---|
735 | IF ( ABS( v1d(nzb+1) ) .LT. 1.0E-5 ) THEN |
---|
736 | alpha = ACOS( SIGN( 1.0 , u1d(nzb+1) ) ) |
---|
737 | ELSE |
---|
738 | alpha = ACOS( u1d(nzb+1) / uv_total ) |
---|
739 | IF ( v1d(nzb+1) <= 0.0 ) alpha = 2.0 * pi - alpha |
---|
740 | ENDIF |
---|
741 | alpha = alpha / ( 2.0 * pi ) * 360.0 |
---|
742 | |
---|
743 | WRITE ( 15, 101 ) current_timestep_number_1d, simulated_time_chr, & |
---|
744 | dt_1d, umax, vmax, us1d, alpha, energy |
---|
745 | ! |
---|
746 | !-- Write buffer contents to disc immediately |
---|
747 | CALL local_flush( 15 ) |
---|
748 | |
---|
749 | ENDIF |
---|
750 | |
---|
751 | ! |
---|
752 | !-- formats |
---|
753 | 100 FORMAT (///'1D-Zeitschrittkontrollausgaben:'/ & |
---|
754 | &'------------------------------'// & |
---|
755 | &'ITER. HH:MM:SS DT UMAX VMAX U* ALPHA ENERG.'/ & |
---|
756 | &'-------------------------------------------------------------') |
---|
757 | 101 FORMAT (I5,2X,A9,1X,F6.2,2X,F6.2,1X,F6.2,2X,F5.3,2X,F5.1,2X,F7.2) |
---|
758 | |
---|
759 | |
---|
760 | END SUBROUTINE run_control_1d |
---|
761 | |
---|
762 | |
---|
763 | |
---|
764 | SUBROUTINE timestep_1d |
---|
765 | |
---|
766 | !------------------------------------------------------------------------------! |
---|
767 | ! Description: |
---|
768 | ! ------------ |
---|
769 | ! Compute the time step w.r.t. the diffusion criterion |
---|
770 | !------------------------------------------------------------------------------! |
---|
771 | |
---|
772 | USE arrays_3d |
---|
773 | USE indices |
---|
774 | USE model_1d |
---|
775 | USE pegrid |
---|
776 | USE control_parameters |
---|
777 | |
---|
778 | IMPLICIT NONE |
---|
779 | |
---|
780 | INTEGER :: k |
---|
781 | REAL :: div, dt_diff, fac, value |
---|
782 | |
---|
783 | |
---|
784 | ! |
---|
785 | !-- Compute the currently feasible time step according to the diffusion |
---|
786 | !-- criterion. At nzb+1 the half grid length is used. |
---|
787 | fac = 0.35 |
---|
788 | dt_diff = dt_max_1d |
---|
789 | DO k = nzb+2, nzt |
---|
790 | value = fac * dzu(k) * dzu(k) / ( km1d(k) + 1E-20 ) |
---|
791 | dt_diff = MIN( value, dt_diff ) |
---|
792 | ENDDO |
---|
793 | value = fac * zu(nzb+1) * zu(nzb+1) / ( km1d(nzb+1) + 1E-20 ) |
---|
794 | dt_1d = MIN( value, dt_diff ) |
---|
795 | |
---|
796 | ! |
---|
797 | !-- Set flag when the time step becomes too small |
---|
798 | IF ( dt_1d < ( 0.00001 * dt_max_1d ) ) THEN |
---|
799 | stop_dt_1d = .TRUE. |
---|
800 | |
---|
801 | WRITE( message_string, * ) 'timestep has exceeded the lower limit &', & |
---|
802 | 'dt_1d = ',dt_1d,' s simulation stopped!' |
---|
803 | CALL message( 'timestep_1d', 'PA0192', 1, 2, 0, 6, 0 ) |
---|
804 | |
---|
805 | ENDIF |
---|
806 | |
---|
807 | ! |
---|
808 | !-- A more or less simple new time step value is obtained taking only the |
---|
809 | !-- first two significant digits |
---|
810 | div = 1000.0 |
---|
811 | DO WHILE ( dt_1d < div ) |
---|
812 | div = div / 10.0 |
---|
813 | ENDDO |
---|
814 | dt_1d = NINT( dt_1d * 100.0 / div ) * div / 100.0 |
---|
815 | |
---|
816 | old_dt_1d = dt_1d |
---|
817 | |
---|
818 | |
---|
819 | END SUBROUTINE timestep_1d |
---|
820 | |
---|
821 | |
---|
822 | |
---|
823 | SUBROUTINE print_1d_model |
---|
824 | |
---|
825 | !------------------------------------------------------------------------------! |
---|
826 | ! Description: |
---|
827 | ! ------------ |
---|
828 | ! List output of profiles from the 1D-model |
---|
829 | !------------------------------------------------------------------------------! |
---|
830 | |
---|
831 | USE arrays_3d |
---|
832 | USE indices |
---|
833 | USE model_1d |
---|
834 | USE pegrid |
---|
835 | USE control_parameters |
---|
836 | |
---|
837 | IMPLICIT NONE |
---|
838 | |
---|
839 | |
---|
840 | INTEGER :: k |
---|
841 | |
---|
842 | |
---|
843 | IF ( myid == 0 ) THEN |
---|
844 | ! |
---|
845 | !-- Open list output file for profiles from the 1D-model |
---|
846 | CALL check_open( 17 ) |
---|
847 | |
---|
848 | ! |
---|
849 | !-- Write Header |
---|
850 | WRITE ( 17, 100 ) TRIM( run_description_header ), & |
---|
851 | TRIM( simulated_time_chr ) |
---|
852 | WRITE ( 17, 101 ) |
---|
853 | |
---|
854 | ! |
---|
855 | !-- Write the values |
---|
856 | WRITE ( 17, 102 ) |
---|
857 | WRITE ( 17, 101 ) |
---|
858 | DO k = nzt+1, nzb, -1 |
---|
859 | WRITE ( 17, 103) k, zu(k), u1d(k), v1d(k), pt_init(k), e1d(k), & |
---|
860 | rif1d(k), km1d(k), kh1d(k), l1d(k), zu(k), k |
---|
861 | ENDDO |
---|
862 | WRITE ( 17, 101 ) |
---|
863 | WRITE ( 17, 102 ) |
---|
864 | WRITE ( 17, 101 ) |
---|
865 | |
---|
866 | ! |
---|
867 | !-- Write buffer contents to disc immediately |
---|
868 | CALL local_flush( 17 ) |
---|
869 | |
---|
870 | ENDIF |
---|
871 | |
---|
872 | ! |
---|
873 | !-- Formats |
---|
874 | 100 FORMAT (//1X,A/1X,10('-')/' 1d-model profiles'/ & |
---|
875 | ' Time: ',A) |
---|
876 | 101 FORMAT (1X,79('-')) |
---|
877 | 102 FORMAT (' k zu u v pt e rif Km Kh ', & |
---|
878 | 'l zu k') |
---|
879 | 103 FORMAT (1X,I4,1X,F7.1,1X,F6.2,1X,F6.2,1X,F6.2,1X,F6.2,1X,F5.2,1X,F5.2, & |
---|
880 | 1X,F5.2,1X,F6.2,1X,F7.1,2X,I4) |
---|
881 | |
---|
882 | |
---|
883 | END SUBROUTINE print_1d_model |
---|