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