1 | SUBROUTINE time_integration |
---|
2 | |
---|
3 | !--------------------------------------------------------------------------------! |
---|
4 | ! This file is part of PALM. |
---|
5 | ! |
---|
6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
8 | ! either version 3 of the License, or (at your option) any later version. |
---|
9 | ! |
---|
10 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
11 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
12 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
13 | ! |
---|
14 | ! You should have received a copy of the GNU General Public License along with |
---|
15 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
16 | ! |
---|
17 | ! Copyright 1997-2012 Leibniz University Hannover |
---|
18 | !--------------------------------------------------------------------------------! |
---|
19 | ! |
---|
20 | ! Current revisions: |
---|
21 | ! ------------------ |
---|
22 | ! |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: time_integration.f90 1116 2013-03-26 18:49:55Z suehring $ |
---|
27 | ! |
---|
28 | ! 1115 2013-03-26 18:16:16Z hoffmann |
---|
29 | ! calculation of qr and nr is restricted to precipitation |
---|
30 | ! |
---|
31 | ! 1113 2013-03-10 02:48:14Z raasch |
---|
32 | ! GPU-porting of boundary conditions, |
---|
33 | ! openACC directives updated |
---|
34 | ! formal parameter removed from routine boundary_conds |
---|
35 | ! |
---|
36 | ! 1111 2013-03-08 23:54:10Z raasch |
---|
37 | ! +internal timestep counter for cpu statistics added, |
---|
38 | ! openACC directives updated |
---|
39 | ! |
---|
40 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
41 | ! unused variables removed |
---|
42 | ! |
---|
43 | ! 1065 2012-11-22 17:42:36Z hoffmann |
---|
44 | ! exchange of diss (dissipation rate) in case of turbulence = .TRUE. added |
---|
45 | ! |
---|
46 | ! 1053 2012-11-13 17:11:03Z hoffmann |
---|
47 | ! exchange of ghost points for nr, qr added |
---|
48 | ! |
---|
49 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
50 | ! code put under GPL (PALM 3.9) |
---|
51 | ! |
---|
52 | ! 1019 2012-09-28 06:46:45Z raasch |
---|
53 | ! non-optimized version of prognostic_equations removed |
---|
54 | ! |
---|
55 | ! 1015 2012-09-27 09:23:24Z raasch |
---|
56 | ! +call of prognostic_equations_acc |
---|
57 | ! |
---|
58 | ! 1001 2012-09-13 14:08:46Z raasch |
---|
59 | ! all actions concerning leapfrog- and upstream-spline-scheme removed |
---|
60 | ! |
---|
61 | ! 849 2012-03-15 10:35:09Z raasch |
---|
62 | ! advec_particles renamed lpm, first_call_advec_particles renamed first_call_lpm |
---|
63 | ! |
---|
64 | ! 825 2012-02-19 03:03:44Z raasch |
---|
65 | ! wang_collision_kernel renamed wang_kernel |
---|
66 | ! |
---|
67 | ! 790 2011-11-29 03:11:20Z raasch |
---|
68 | ! exchange of ghostpoints for array diss |
---|
69 | ! |
---|
70 | ! 707 2011-03-29 11:39:40Z raasch |
---|
71 | ! bc_lr/ns replaced by bc_lr/ns_cyc, calls of exchange_horiz are modified, |
---|
72 | ! adaption to sloping surface |
---|
73 | ! |
---|
74 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
75 | ! Calls of exchange_horiz are modified. |
---|
76 | ! Adaption to slooping surface. |
---|
77 | ! |
---|
78 | ! 449 2010-02-02 11:23:59Z raasch |
---|
79 | ! Bugfix: exchange of ghost points for prho included |
---|
80 | ! |
---|
81 | ! 410 2009-12-04 17:05:40Z letzel |
---|
82 | ! masked data output |
---|
83 | ! |
---|
84 | ! 388 2009-09-23 09:40:33Z raasch |
---|
85 | ! Using prho instead of rho in diffusvities. |
---|
86 | ! Coupling with independent precursor runs. |
---|
87 | ! Bugfix: output of particle time series only if particle advection is switched |
---|
88 | ! on |
---|
89 | ! |
---|
90 | ! 151 2008-03-07 13:42:18Z raasch |
---|
91 | ! inflow turbulence is imposed by calling new routine inflow_turbulence |
---|
92 | ! |
---|
93 | ! 108 2007-08-24 15:10:38Z letzel |
---|
94 | ! Call of new routine surface_coupler, |
---|
95 | ! presure solver is called after the first Runge-Kutta substep instead of the |
---|
96 | ! last in case that call_psolver_at_all_substeps = .F.; for this case, the |
---|
97 | ! random perturbation has to be added to the velocity fields also after the |
---|
98 | ! first substep |
---|
99 | ! |
---|
100 | ! 97 2007-06-21 08:23:15Z raasch |
---|
101 | ! diffusivities is called with argument rho in case of ocean runs, |
---|
102 | ! new argument pt_/prho_reference in calls of diffusivities, |
---|
103 | ! ghostpoint exchange for salinity and density |
---|
104 | ! |
---|
105 | ! 87 2007-05-22 15:46:47Z raasch |
---|
106 | ! var_hom renamed pr_palm |
---|
107 | ! |
---|
108 | ! 75 2007-03-22 09:54:05Z raasch |
---|
109 | ! Move call of user_actions( 'after_integration' ) below increment of times |
---|
110 | ! and counters, |
---|
111 | ! calls of prognostic_equations_.. changed to .._noopt, .._cache, and |
---|
112 | ! .._vector, these calls are now controlled by switch loop_optimization, |
---|
113 | ! uxrp, vynp eliminated, 2nd+3rd argument removed from exchange horiz, |
---|
114 | ! moisture renamed humidity |
---|
115 | ! |
---|
116 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
117 | ! |
---|
118 | ! Revision 1.8 2006/08/22 14:16:05 raasch |
---|
119 | ! Disturbances are imposed only for the last Runge-Kutta-substep |
---|
120 | ! |
---|
121 | ! Revision 1.2 2004/04/30 13:03:40 raasch |
---|
122 | ! decalpha-specific warning removed, routine name changed to time_integration, |
---|
123 | ! particle advection is carried out only once during the intermediate steps, |
---|
124 | ! impulse_advec renamed momentum_advec |
---|
125 | ! |
---|
126 | ! Revision 1.1 1997/08/11 06:19:04 raasch |
---|
127 | ! Initial revision |
---|
128 | ! |
---|
129 | ! |
---|
130 | ! Description: |
---|
131 | ! ------------ |
---|
132 | ! Integration in time of the model equations, statistical analysis and graphic |
---|
133 | ! output |
---|
134 | !------------------------------------------------------------------------------! |
---|
135 | |
---|
136 | USE arrays_3d |
---|
137 | USE averaging |
---|
138 | USE control_parameters |
---|
139 | USE cpulog |
---|
140 | #if defined( __dvrp_graphics ) |
---|
141 | USE DVRP |
---|
142 | #endif |
---|
143 | USE grid_variables |
---|
144 | USE indices |
---|
145 | USE interaction_droplets_ptq_mod |
---|
146 | USE interfaces |
---|
147 | USE particle_attributes |
---|
148 | USE pegrid |
---|
149 | USE prognostic_equations_mod |
---|
150 | USE statistics |
---|
151 | USE user_actions_mod |
---|
152 | |
---|
153 | IMPLICIT NONE |
---|
154 | |
---|
155 | CHARACTER (LEN=9) :: time_to_string |
---|
156 | |
---|
157 | ! |
---|
158 | !-- At the beginning of a simulation determine the time step as well as |
---|
159 | !-- determine and print out the run control parameters |
---|
160 | IF ( simulated_time == 0.0 ) CALL timestep |
---|
161 | |
---|
162 | CALL run_control |
---|
163 | |
---|
164 | |
---|
165 | ! |
---|
166 | !-- Data exchange between coupled models in case that a call has been omitted |
---|
167 | !-- at the end of the previous run of a job chain. |
---|
168 | IF ( coupling_mode /= 'uncoupled' .AND. run_coupled ) THEN |
---|
169 | ! |
---|
170 | !-- In case of model termination initiated by the local model the coupler |
---|
171 | !-- must not be called because this would again cause an MPI hang. |
---|
172 | DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 ) |
---|
173 | CALL surface_coupler |
---|
174 | time_coupling = time_coupling - dt_coupling |
---|
175 | ENDDO |
---|
176 | IF (time_coupling == 0.0 .AND. time_since_reference_point < dt_coupling)& |
---|
177 | THEN |
---|
178 | time_coupling = time_since_reference_point |
---|
179 | ENDIF |
---|
180 | ENDIF |
---|
181 | |
---|
182 | |
---|
183 | #if defined( __dvrp_graphics ) |
---|
184 | ! |
---|
185 | !-- Time measurement with dvrp software |
---|
186 | CALL DVRP_LOG_EVENT( 2, current_timestep_number ) |
---|
187 | #endif |
---|
188 | |
---|
189 | ! |
---|
190 | !-- Start of the time loop |
---|
191 | DO WHILE ( simulated_time < end_time .AND. .NOT. stop_dt .AND. & |
---|
192 | .NOT. terminate_run ) |
---|
193 | |
---|
194 | CALL cpu_log( log_point_s(10), 'timesteps', 'start' ) |
---|
195 | ! |
---|
196 | !-- Determine size of next time step |
---|
197 | IF ( simulated_time /= 0.0 ) CALL timestep |
---|
198 | ! |
---|
199 | !-- Execute the user-defined actions |
---|
200 | CALL user_actions( 'before_timestep' ) |
---|
201 | |
---|
202 | ! |
---|
203 | !-- Start of intermediate step loop |
---|
204 | intermediate_timestep_count = 0 |
---|
205 | DO WHILE ( intermediate_timestep_count < & |
---|
206 | intermediate_timestep_count_max ) |
---|
207 | |
---|
208 | intermediate_timestep_count = intermediate_timestep_count + 1 |
---|
209 | |
---|
210 | ! |
---|
211 | !-- Set the steering factors for the prognostic equations which depend |
---|
212 | !-- on the timestep scheme |
---|
213 | CALL timestep_scheme_steering |
---|
214 | |
---|
215 | ! |
---|
216 | !-- Solve the prognostic equations. A fast cache optimized version with |
---|
217 | !-- only one single loop is used in case of Piascek-Williams advection |
---|
218 | !-- scheme. NEC vector machines use a different version, because |
---|
219 | !-- in the other versions a good vectorization is prohibited due to |
---|
220 | !-- inlining problems. |
---|
221 | IF ( loop_optimization == 'cache' ) THEN |
---|
222 | CALL prognostic_equations_cache |
---|
223 | ELSEIF ( loop_optimization == 'vector' ) THEN |
---|
224 | CALL prognostic_equations_vector |
---|
225 | ELSEIF ( loop_optimization == 'acc' ) THEN |
---|
226 | CALL prognostic_equations_acc |
---|
227 | ENDIF |
---|
228 | |
---|
229 | ! |
---|
230 | !-- Particle transport/physics with the Lagrangian particle model |
---|
231 | !-- (only once during intermediate steps, because it uses an Euler-step) |
---|
232 | IF ( particle_advection .AND. & |
---|
233 | simulated_time >= particle_advection_start .AND. & |
---|
234 | intermediate_timestep_count == 1 ) THEN |
---|
235 | CALL lpm |
---|
236 | first_call_lpm = .FALSE. |
---|
237 | ENDIF |
---|
238 | |
---|
239 | ! |
---|
240 | !-- Interaction of droplets with temperature and specific humidity. |
---|
241 | !-- Droplet condensation and evaporation is calculated within |
---|
242 | !-- advec_particles. |
---|
243 | IF ( cloud_droplets .AND. & |
---|
244 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
245 | THEN |
---|
246 | CALL interaction_droplets_ptq |
---|
247 | ENDIF |
---|
248 | |
---|
249 | ! |
---|
250 | !-- Exchange of ghost points (lateral boundary conditions) |
---|
251 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'start' ) |
---|
252 | |
---|
253 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
254 | on_device = .TRUE. ! to be removed after complete porting |
---|
255 | ELSE ! of ghost point exchange |
---|
256 | !$acc update host( e_p, pt_p, u_p, v_p, w_p ) |
---|
257 | ENDIF |
---|
258 | |
---|
259 | CALL exchange_horiz( u_p, nbgp ) |
---|
260 | CALL exchange_horiz( v_p, nbgp ) |
---|
261 | CALL exchange_horiz( w_p, nbgp ) |
---|
262 | CALL exchange_horiz( pt_p, nbgp ) |
---|
263 | IF ( .NOT. constant_diffusion ) CALL exchange_horiz( e_p, nbgp ) |
---|
264 | IF ( ocean ) THEN |
---|
265 | CALL exchange_horiz( sa_p, nbgp ) |
---|
266 | CALL exchange_horiz( rho, nbgp ) |
---|
267 | CALL exchange_horiz( prho, nbgp ) |
---|
268 | ENDIF |
---|
269 | IF (humidity .OR. passive_scalar) THEN |
---|
270 | CALL exchange_horiz( q_p, nbgp ) |
---|
271 | IF ( cloud_physics .AND. icloud_scheme == 0 .AND. & |
---|
272 | precipitation) THEN |
---|
273 | CALL exchange_horiz( qr_p, nbgp ) |
---|
274 | CALL exchange_horiz( nr_p, nbgp ) |
---|
275 | ENDIF |
---|
276 | ENDIF |
---|
277 | IF ( cloud_droplets ) THEN |
---|
278 | CALL exchange_horiz( ql, nbgp ) |
---|
279 | CALL exchange_horiz( ql_c, nbgp ) |
---|
280 | CALL exchange_horiz( ql_v, nbgp ) |
---|
281 | CALL exchange_horiz( ql_vp, nbgp ) |
---|
282 | ENDIF |
---|
283 | IF ( wang_kernel .OR. turbulence ) CALL exchange_horiz( diss, nbgp ) |
---|
284 | |
---|
285 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
286 | on_device = .FALSE. ! to be removed after complete porting |
---|
287 | ELSE ! of ghost point exchange |
---|
288 | !$acc update device( e_p, pt_p, u_p, v_p, w_p ) |
---|
289 | ENDIF |
---|
290 | |
---|
291 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' ) |
---|
292 | |
---|
293 | ! |
---|
294 | !-- Boundary conditions for the prognostic quantities (except of the |
---|
295 | !-- velocities at the outflow in case of a non-cyclic lateral wall) |
---|
296 | CALL boundary_conds |
---|
297 | |
---|
298 | ! |
---|
299 | !-- Swap the time levels in preparation for the next time step. |
---|
300 | CALL swap_timelevel |
---|
301 | |
---|
302 | ! |
---|
303 | !-- Temperature offset must be imposed at cyclic boundaries in x-direction |
---|
304 | !-- when a sloping surface is used |
---|
305 | IF ( sloping_surface ) THEN |
---|
306 | IF ( nxl == 0 ) pt(:,:,nxlg:nxl-1) = pt(:,:,nxlg:nxl-1) - & |
---|
307 | pt_slope_offset |
---|
308 | IF ( nxr == nx ) pt(:,:,nxr+1:nxrg) = pt(:,:,nxr+1:nxrg) + & |
---|
309 | pt_slope_offset |
---|
310 | ENDIF |
---|
311 | |
---|
312 | ! |
---|
313 | !-- Impose a turbulent inflow using the recycling method |
---|
314 | IF ( turbulent_inflow ) CALL inflow_turbulence |
---|
315 | |
---|
316 | ! |
---|
317 | !-- Impose a random perturbation on the horizontal velocity field |
---|
318 | IF ( create_disturbances .AND. & |
---|
319 | ( call_psolver_at_all_substeps .AND. & |
---|
320 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
321 | .OR. ( .NOT. call_psolver_at_all_substeps .AND. & |
---|
322 | intermediate_timestep_count == 1 ) ) & |
---|
323 | THEN |
---|
324 | time_disturb = time_disturb + dt_3d |
---|
325 | IF ( time_disturb >= dt_disturb ) THEN |
---|
326 | !$acc update host( u, v ) |
---|
327 | IF ( numprocs == 1 ) on_device = .FALSE. ! workaround, remove later |
---|
328 | IF ( hom(nzb+5,1,pr_palm,0) < disturbance_energy_limit ) THEN |
---|
329 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
330 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
331 | ELSEIF ( .NOT. bc_lr_cyc .OR. .NOT. bc_ns_cyc ) THEN |
---|
332 | ! |
---|
333 | !-- Runs with a non-cyclic lateral wall need perturbations |
---|
334 | !-- near the inflow throughout the whole simulation |
---|
335 | dist_range = 1 |
---|
336 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
337 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
338 | dist_range = 0 |
---|
339 | ENDIF |
---|
340 | IF ( numprocs == 1 ) on_device = .TRUE. ! workaround, remove later |
---|
341 | !$acc update device( u, v ) |
---|
342 | time_disturb = time_disturb - dt_disturb |
---|
343 | ENDIF |
---|
344 | ENDIF |
---|
345 | |
---|
346 | ! |
---|
347 | !-- Reduce the velocity divergence via the equation for perturbation |
---|
348 | !-- pressure. |
---|
349 | IF ( intermediate_timestep_count == 1 .OR. & |
---|
350 | call_psolver_at_all_substeps ) THEN |
---|
351 | CALL pres |
---|
352 | ENDIF |
---|
353 | |
---|
354 | ! |
---|
355 | !-- If required, compute liquid water content |
---|
356 | IF ( cloud_physics ) THEN |
---|
357 | CALL calc_liquid_water_content |
---|
358 | !$acc update device( ql ) |
---|
359 | ENDIF |
---|
360 | ! |
---|
361 | !-- If required, compute virtual potential temperature |
---|
362 | IF ( humidity ) THEN |
---|
363 | CALL compute_vpt |
---|
364 | !$acc update device( vpt ) |
---|
365 | ENDIF |
---|
366 | ! |
---|
367 | !-- Compute the diffusion quantities |
---|
368 | IF ( .NOT. constant_diffusion ) THEN |
---|
369 | |
---|
370 | ! |
---|
371 | !-- First the vertical fluxes in the Prandtl layer are being computed |
---|
372 | IF ( prandtl_layer ) THEN |
---|
373 | CALL cpu_log( log_point(19), 'prandtl_fluxes', 'start' ) |
---|
374 | CALL prandtl_fluxes |
---|
375 | CALL cpu_log( log_point(19), 'prandtl_fluxes', 'stop' ) |
---|
376 | ENDIF |
---|
377 | ! |
---|
378 | !-- Compute the diffusion coefficients |
---|
379 | CALL cpu_log( log_point(17), 'diffusivities', 'start' ) |
---|
380 | IF ( .NOT. humidity ) THEN |
---|
381 | IF ( ocean ) THEN |
---|
382 | CALL diffusivities( prho, prho_reference ) |
---|
383 | ELSE |
---|
384 | CALL diffusivities( pt, pt_reference ) |
---|
385 | ENDIF |
---|
386 | ELSE |
---|
387 | CALL diffusivities( vpt, pt_reference ) |
---|
388 | ENDIF |
---|
389 | CALL cpu_log( log_point(17), 'diffusivities', 'stop' ) |
---|
390 | |
---|
391 | ENDIF |
---|
392 | |
---|
393 | ENDDO ! Intermediate step loop |
---|
394 | |
---|
395 | ! |
---|
396 | !-- Increase simulation time and output times |
---|
397 | nr_timesteps_this_run = nr_timesteps_this_run + 1 |
---|
398 | current_timestep_number = current_timestep_number + 1 |
---|
399 | simulated_time = simulated_time + dt_3d |
---|
400 | simulated_time_chr = time_to_string( simulated_time ) |
---|
401 | time_since_reference_point = simulated_time - coupling_start_time |
---|
402 | |
---|
403 | IF ( simulated_time >= skip_time_data_output_av ) THEN |
---|
404 | time_do_av = time_do_av + dt_3d |
---|
405 | ENDIF |
---|
406 | IF ( simulated_time >= skip_time_do2d_xy ) THEN |
---|
407 | time_do2d_xy = time_do2d_xy + dt_3d |
---|
408 | ENDIF |
---|
409 | IF ( simulated_time >= skip_time_do2d_xz ) THEN |
---|
410 | time_do2d_xz = time_do2d_xz + dt_3d |
---|
411 | ENDIF |
---|
412 | IF ( simulated_time >= skip_time_do2d_yz ) THEN |
---|
413 | time_do2d_yz = time_do2d_yz + dt_3d |
---|
414 | ENDIF |
---|
415 | IF ( simulated_time >= skip_time_do3d ) THEN |
---|
416 | time_do3d = time_do3d + dt_3d |
---|
417 | ENDIF |
---|
418 | DO mid = 1, masks |
---|
419 | IF ( simulated_time >= skip_time_domask(mid) ) THEN |
---|
420 | time_domask(mid)= time_domask(mid) + dt_3d |
---|
421 | ENDIF |
---|
422 | ENDDO |
---|
423 | time_dvrp = time_dvrp + dt_3d |
---|
424 | IF ( simulated_time >= skip_time_dosp ) THEN |
---|
425 | time_dosp = time_dosp + dt_3d |
---|
426 | ENDIF |
---|
427 | time_dots = time_dots + dt_3d |
---|
428 | IF ( .NOT. first_call_lpm ) THEN |
---|
429 | time_dopts = time_dopts + dt_3d |
---|
430 | ENDIF |
---|
431 | IF ( simulated_time >= skip_time_dopr ) THEN |
---|
432 | time_dopr = time_dopr + dt_3d |
---|
433 | ENDIF |
---|
434 | time_dopr_listing = time_dopr_listing + dt_3d |
---|
435 | time_run_control = time_run_control + dt_3d |
---|
436 | |
---|
437 | ! |
---|
438 | !-- Data exchange between coupled models |
---|
439 | IF ( coupling_mode /= 'uncoupled' .AND. run_coupled ) THEN |
---|
440 | time_coupling = time_coupling + dt_3d |
---|
441 | |
---|
442 | ! |
---|
443 | !-- In case of model termination initiated by the local model |
---|
444 | !-- (terminate_coupled > 0), the coupler must be skipped because it would |
---|
445 | !-- cause an MPI intercomminucation hang. |
---|
446 | !-- If necessary, the coupler will be called at the beginning of the |
---|
447 | !-- next restart run. |
---|
448 | DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 ) |
---|
449 | CALL surface_coupler |
---|
450 | time_coupling = time_coupling - dt_coupling |
---|
451 | ENDDO |
---|
452 | ENDIF |
---|
453 | |
---|
454 | ! |
---|
455 | !-- Execute user-defined actions |
---|
456 | CALL user_actions( 'after_integration' ) |
---|
457 | |
---|
458 | ! |
---|
459 | !-- If Galilei transformation is used, determine the distance that the |
---|
460 | !-- model has moved so far |
---|
461 | IF ( galilei_transformation ) THEN |
---|
462 | advected_distance_x = advected_distance_x + u_gtrans * dt_3d |
---|
463 | advected_distance_y = advected_distance_y + v_gtrans * dt_3d |
---|
464 | ENDIF |
---|
465 | |
---|
466 | ! |
---|
467 | !-- Check, if restart is necessary (because cpu-time is expiring or |
---|
468 | !-- because it is forced by user) and set stop flag |
---|
469 | !-- This call is skipped if the remote model has already initiated a restart. |
---|
470 | IF ( .NOT. terminate_run ) CALL check_for_restart |
---|
471 | |
---|
472 | ! |
---|
473 | !-- Carry out statistical analysis and output at the requested output times. |
---|
474 | !-- The MOD function is used for calculating the output time counters (like |
---|
475 | !-- time_dopr) in order to regard a possible decrease of the output time |
---|
476 | !-- interval in case of restart runs |
---|
477 | |
---|
478 | ! |
---|
479 | !-- Set a flag indicating that so far no statistics have been created |
---|
480 | !-- for this time step |
---|
481 | flow_statistics_called = .FALSE. |
---|
482 | |
---|
483 | ! |
---|
484 | !-- If required, call flow_statistics for averaging in time |
---|
485 | IF ( averaging_interval_pr /= 0.0 .AND. & |
---|
486 | ( dt_dopr - time_dopr ) <= averaging_interval_pr .AND. & |
---|
487 | simulated_time >= skip_time_dopr ) THEN |
---|
488 | time_dopr_av = time_dopr_av + dt_3d |
---|
489 | IF ( time_dopr_av >= dt_averaging_input_pr ) THEN |
---|
490 | do_sum = .TRUE. |
---|
491 | time_dopr_av = MOD( time_dopr_av, & |
---|
492 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
493 | ENDIF |
---|
494 | ENDIF |
---|
495 | IF ( do_sum ) CALL flow_statistics |
---|
496 | |
---|
497 | ! |
---|
498 | !-- Sum-up 3d-arrays for later output of time-averaged 2d/3d/masked data |
---|
499 | IF ( averaging_interval /= 0.0 .AND. & |
---|
500 | ( dt_data_output_av - time_do_av ) <= averaging_interval .AND. & |
---|
501 | simulated_time >= skip_time_data_output_av ) & |
---|
502 | THEN |
---|
503 | time_do_sla = time_do_sla + dt_3d |
---|
504 | IF ( time_do_sla >= dt_averaging_input ) THEN |
---|
505 | CALL sum_up_3d_data |
---|
506 | average_count_3d = average_count_3d + 1 |
---|
507 | time_do_sla = MOD( time_do_sla, MAX( dt_averaging_input, dt_3d ) ) |
---|
508 | ENDIF |
---|
509 | ENDIF |
---|
510 | |
---|
511 | ! |
---|
512 | !-- Calculate spectra for time averaging |
---|
513 | IF ( averaging_interval_sp /= 0.0 .AND. & |
---|
514 | ( dt_dosp - time_dosp ) <= averaging_interval_sp .AND. & |
---|
515 | simulated_time >= skip_time_dosp ) THEN |
---|
516 | time_dosp_av = time_dosp_av + dt_3d |
---|
517 | IF ( time_dosp_av >= dt_averaging_input_pr ) THEN |
---|
518 | CALL calc_spectra |
---|
519 | time_dosp_av = MOD( time_dosp_av, & |
---|
520 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
521 | ENDIF |
---|
522 | ENDIF |
---|
523 | |
---|
524 | ! |
---|
525 | !-- Computation and output of run control parameters. |
---|
526 | !-- This is also done whenever perturbations have been imposed |
---|
527 | IF ( time_run_control >= dt_run_control .OR. & |
---|
528 | timestep_scheme(1:5) /= 'runge' .OR. disturbance_created ) & |
---|
529 | THEN |
---|
530 | CALL run_control |
---|
531 | IF ( time_run_control >= dt_run_control ) THEN |
---|
532 | time_run_control = MOD( time_run_control, & |
---|
533 | MAX( dt_run_control, dt_3d ) ) |
---|
534 | ENDIF |
---|
535 | ENDIF |
---|
536 | |
---|
537 | ! |
---|
538 | !-- Profile output (ASCII) on file |
---|
539 | IF ( time_dopr_listing >= dt_dopr_listing ) THEN |
---|
540 | CALL print_1d |
---|
541 | time_dopr_listing = MOD( time_dopr_listing, MAX( dt_dopr_listing, & |
---|
542 | dt_3d ) ) |
---|
543 | ENDIF |
---|
544 | |
---|
545 | ! |
---|
546 | !-- Graphic output for PROFIL |
---|
547 | IF ( time_dopr >= dt_dopr ) THEN |
---|
548 | IF ( dopr_n /= 0 ) CALL data_output_profiles |
---|
549 | time_dopr = MOD( time_dopr, MAX( dt_dopr, dt_3d ) ) |
---|
550 | time_dopr_av = 0.0 ! due to averaging (see above) |
---|
551 | ENDIF |
---|
552 | |
---|
553 | ! |
---|
554 | !-- Graphic output for time series |
---|
555 | IF ( time_dots >= dt_dots ) THEN |
---|
556 | CALL data_output_tseries |
---|
557 | time_dots = MOD( time_dots, MAX( dt_dots, dt_3d ) ) |
---|
558 | ENDIF |
---|
559 | |
---|
560 | ! |
---|
561 | !-- Output of spectra (formatted for use with PROFIL), in case of no |
---|
562 | !-- time averaging, spectra has to be calculated before |
---|
563 | IF ( time_dosp >= dt_dosp ) THEN |
---|
564 | IF ( average_count_sp == 0 ) CALL calc_spectra |
---|
565 | CALL data_output_spectra |
---|
566 | time_dosp = MOD( time_dosp, MAX( dt_dosp, dt_3d ) ) |
---|
567 | ENDIF |
---|
568 | |
---|
569 | ! |
---|
570 | !-- 2d-data output (cross-sections) |
---|
571 | IF ( time_do2d_xy >= dt_do2d_xy ) THEN |
---|
572 | CALL data_output_2d( 'xy', 0 ) |
---|
573 | time_do2d_xy = MOD( time_do2d_xy, MAX( dt_do2d_xy, dt_3d ) ) |
---|
574 | ENDIF |
---|
575 | IF ( time_do2d_xz >= dt_do2d_xz ) THEN |
---|
576 | CALL data_output_2d( 'xz', 0 ) |
---|
577 | time_do2d_xz = MOD( time_do2d_xz, MAX( dt_do2d_xz, dt_3d ) ) |
---|
578 | ENDIF |
---|
579 | IF ( time_do2d_yz >= dt_do2d_yz ) THEN |
---|
580 | CALL data_output_2d( 'yz', 0 ) |
---|
581 | time_do2d_yz = MOD( time_do2d_yz, MAX( dt_do2d_yz, dt_3d ) ) |
---|
582 | ENDIF |
---|
583 | |
---|
584 | ! |
---|
585 | !-- 3d-data output (volume data) |
---|
586 | IF ( time_do3d >= dt_do3d ) THEN |
---|
587 | CALL data_output_3d( 0 ) |
---|
588 | time_do3d = MOD( time_do3d, MAX( dt_do3d, dt_3d ) ) |
---|
589 | ENDIF |
---|
590 | |
---|
591 | ! |
---|
592 | !-- masked data output |
---|
593 | DO mid = 1, masks |
---|
594 | IF ( time_domask(mid) >= dt_domask(mid) ) THEN |
---|
595 | CALL data_output_mask( 0 ) |
---|
596 | time_domask(mid) = MOD( time_domask(mid), & |
---|
597 | MAX( dt_domask(mid), dt_3d ) ) |
---|
598 | ENDIF |
---|
599 | ENDDO |
---|
600 | |
---|
601 | ! |
---|
602 | !-- Output of time-averaged 2d/3d/masked data |
---|
603 | IF ( time_do_av >= dt_data_output_av ) THEN |
---|
604 | CALL average_3d_data |
---|
605 | CALL data_output_2d( 'xy', 1 ) |
---|
606 | CALL data_output_2d( 'xz', 1 ) |
---|
607 | CALL data_output_2d( 'yz', 1 ) |
---|
608 | CALL data_output_3d( 1 ) |
---|
609 | DO mid = 1, masks |
---|
610 | CALL data_output_mask( 1 ) |
---|
611 | ENDDO |
---|
612 | time_do_av = MOD( time_do_av, MAX( dt_data_output_av, dt_3d ) ) |
---|
613 | ENDIF |
---|
614 | |
---|
615 | ! |
---|
616 | !-- Output of particle time series |
---|
617 | IF ( particle_advection ) THEN |
---|
618 | IF ( time_dopts >= dt_dopts .OR. & |
---|
619 | ( simulated_time >= particle_advection_start .AND. & |
---|
620 | first_call_lpm ) ) THEN |
---|
621 | CALL data_output_ptseries |
---|
622 | time_dopts = MOD( time_dopts, MAX( dt_dopts, dt_3d ) ) |
---|
623 | ENDIF |
---|
624 | ENDIF |
---|
625 | |
---|
626 | ! |
---|
627 | !-- Output of dvrp-graphics (isosurface, particles, slicer) |
---|
628 | #if defined( __dvrp_graphics ) |
---|
629 | CALL DVRP_LOG_EVENT( -2, current_timestep_number-1 ) |
---|
630 | #endif |
---|
631 | IF ( time_dvrp >= dt_dvrp ) THEN |
---|
632 | CALL data_output_dvrp |
---|
633 | time_dvrp = MOD( time_dvrp, MAX( dt_dvrp, dt_3d ) ) |
---|
634 | ENDIF |
---|
635 | #if defined( __dvrp_graphics ) |
---|
636 | CALL DVRP_LOG_EVENT( 2, current_timestep_number ) |
---|
637 | #endif |
---|
638 | |
---|
639 | ! |
---|
640 | !-- If required, set the heat flux for the next time step at a random value |
---|
641 | IF ( constant_heatflux .AND. random_heatflux ) CALL disturb_heatflux |
---|
642 | |
---|
643 | ! |
---|
644 | !-- Execute user-defined actions |
---|
645 | CALL user_actions( 'after_timestep' ) |
---|
646 | |
---|
647 | CALL cpu_log( log_point_s(10), 'timesteps', 'stop' ) |
---|
648 | |
---|
649 | |
---|
650 | ENDDO ! time loop |
---|
651 | |
---|
652 | #if defined( __dvrp_graphics ) |
---|
653 | CALL DVRP_LOG_EVENT( -2, current_timestep_number ) |
---|
654 | #endif |
---|
655 | |
---|
656 | END SUBROUTINE time_integration |
---|