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 | ! calculation of qr and nr is restricted to precipitation |
---|
23 | ! |
---|
24 | ! Former revisions: |
---|
25 | ! ----------------- |
---|
26 | ! $Id: time_integration.f90 1115 2013-03-26 18:16:16Z hoffmann $ |
---|
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 .AND. & |
---|
269 | precipitation) THEN |
---|
270 | CALL exchange_horiz( qr_p, nbgp ) |
---|
271 | CALL exchange_horiz( nr_p, nbgp ) |
---|
272 | ENDIF |
---|
273 | ENDIF |
---|
274 | IF ( cloud_droplets ) THEN |
---|
275 | CALL exchange_horiz( ql, nbgp ) |
---|
276 | CALL exchange_horiz( ql_c, nbgp ) |
---|
277 | CALL exchange_horiz( ql_v, nbgp ) |
---|
278 | CALL exchange_horiz( ql_vp, nbgp ) |
---|
279 | ENDIF |
---|
280 | IF ( wang_kernel .OR. turbulence ) CALL exchange_horiz( diss, nbgp ) |
---|
281 | |
---|
282 | IF ( numprocs == 1 ) THEN ! workaround for single-core GPU runs |
---|
283 | on_device = .FALSE. ! to be removed after complete porting |
---|
284 | ELSE ! of ghost point exchange |
---|
285 | !$acc update device( e_p, pt_p, u_p, v_p, w_p ) |
---|
286 | ENDIF |
---|
287 | |
---|
288 | CALL cpu_log( log_point(26), 'exchange-horiz-progn', 'stop' ) |
---|
289 | |
---|
290 | ! |
---|
291 | !-- Boundary conditions for the prognostic quantities (except of the |
---|
292 | !-- velocities at the outflow in case of a non-cyclic lateral wall) |
---|
293 | CALL boundary_conds |
---|
294 | |
---|
295 | ! |
---|
296 | !-- Swap the time levels in preparation for the next time step. |
---|
297 | CALL swap_timelevel |
---|
298 | |
---|
299 | ! |
---|
300 | !-- Temperature offset must be imposed at cyclic boundaries in x-direction |
---|
301 | !-- when a sloping surface is used |
---|
302 | IF ( sloping_surface ) THEN |
---|
303 | IF ( nxl == 0 ) pt(:,:,nxlg:nxl-1) = pt(:,:,nxlg:nxl-1) - & |
---|
304 | pt_slope_offset |
---|
305 | IF ( nxr == nx ) pt(:,:,nxr+1:nxrg) = pt(:,:,nxr+1:nxrg) + & |
---|
306 | pt_slope_offset |
---|
307 | ENDIF |
---|
308 | |
---|
309 | ! |
---|
310 | !-- Impose a turbulent inflow using the recycling method |
---|
311 | IF ( turbulent_inflow ) CALL inflow_turbulence |
---|
312 | |
---|
313 | ! |
---|
314 | !-- Impose a random perturbation on the horizontal velocity field |
---|
315 | IF ( create_disturbances .AND. & |
---|
316 | ( call_psolver_at_all_substeps .AND. & |
---|
317 | intermediate_timestep_count == intermediate_timestep_count_max )& |
---|
318 | .OR. ( .NOT. call_psolver_at_all_substeps .AND. & |
---|
319 | intermediate_timestep_count == 1 ) ) & |
---|
320 | THEN |
---|
321 | time_disturb = time_disturb + dt_3d |
---|
322 | IF ( time_disturb >= dt_disturb ) THEN |
---|
323 | !$acc update host( u, v ) |
---|
324 | IF ( numprocs == 1 ) on_device = .FALSE. ! workaround, remove later |
---|
325 | IF ( hom(nzb+5,1,pr_palm,0) < disturbance_energy_limit ) THEN |
---|
326 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
327 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
328 | ELSEIF ( .NOT. bc_lr_cyc .OR. .NOT. bc_ns_cyc ) THEN |
---|
329 | ! |
---|
330 | !-- Runs with a non-cyclic lateral wall need perturbations |
---|
331 | !-- near the inflow throughout the whole simulation |
---|
332 | dist_range = 1 |
---|
333 | CALL disturb_field( nzb_u_inner, tend, u ) |
---|
334 | CALL disturb_field( nzb_v_inner, tend, v ) |
---|
335 | dist_range = 0 |
---|
336 | ENDIF |
---|
337 | IF ( numprocs == 1 ) on_device = .TRUE. ! workaround, remove later |
---|
338 | !$acc update device( u, v ) |
---|
339 | time_disturb = time_disturb - dt_disturb |
---|
340 | ENDIF |
---|
341 | ENDIF |
---|
342 | |
---|
343 | ! |
---|
344 | !-- Reduce the velocity divergence via the equation for perturbation |
---|
345 | !-- pressure. |
---|
346 | IF ( intermediate_timestep_count == 1 .OR. & |
---|
347 | call_psolver_at_all_substeps ) THEN |
---|
348 | CALL pres |
---|
349 | ENDIF |
---|
350 | |
---|
351 | ! |
---|
352 | !-- If required, compute liquid water content |
---|
353 | IF ( cloud_physics ) THEN |
---|
354 | CALL calc_liquid_water_content |
---|
355 | !$acc update device( ql ) |
---|
356 | ENDIF |
---|
357 | ! |
---|
358 | !-- If required, compute virtual potential temperature |
---|
359 | IF ( humidity ) THEN |
---|
360 | CALL compute_vpt |
---|
361 | !$acc update device( vpt ) |
---|
362 | ENDIF |
---|
363 | ! |
---|
364 | !-- Compute the diffusion quantities |
---|
365 | IF ( .NOT. constant_diffusion ) THEN |
---|
366 | |
---|
367 | ! |
---|
368 | !-- First the vertical fluxes in the Prandtl layer are being computed |
---|
369 | IF ( prandtl_layer ) THEN |
---|
370 | CALL cpu_log( log_point(19), 'prandtl_fluxes', 'start' ) |
---|
371 | CALL prandtl_fluxes |
---|
372 | CALL cpu_log( log_point(19), 'prandtl_fluxes', 'stop' ) |
---|
373 | ENDIF |
---|
374 | ! |
---|
375 | !-- Compute the diffusion coefficients |
---|
376 | CALL cpu_log( log_point(17), 'diffusivities', 'start' ) |
---|
377 | IF ( .NOT. humidity ) THEN |
---|
378 | IF ( ocean ) THEN |
---|
379 | CALL diffusivities( prho, prho_reference ) |
---|
380 | ELSE |
---|
381 | CALL diffusivities( pt, pt_reference ) |
---|
382 | ENDIF |
---|
383 | ELSE |
---|
384 | CALL diffusivities( vpt, pt_reference ) |
---|
385 | ENDIF |
---|
386 | CALL cpu_log( log_point(17), 'diffusivities', 'stop' ) |
---|
387 | |
---|
388 | ENDIF |
---|
389 | |
---|
390 | ENDDO ! Intermediate step loop |
---|
391 | |
---|
392 | ! |
---|
393 | !-- Increase simulation time and output times |
---|
394 | nr_timesteps_this_run = nr_timesteps_this_run + 1 |
---|
395 | current_timestep_number = current_timestep_number + 1 |
---|
396 | simulated_time = simulated_time + dt_3d |
---|
397 | simulated_time_chr = time_to_string( simulated_time ) |
---|
398 | time_since_reference_point = simulated_time - coupling_start_time |
---|
399 | |
---|
400 | IF ( simulated_time >= skip_time_data_output_av ) THEN |
---|
401 | time_do_av = time_do_av + dt_3d |
---|
402 | ENDIF |
---|
403 | IF ( simulated_time >= skip_time_do2d_xy ) THEN |
---|
404 | time_do2d_xy = time_do2d_xy + dt_3d |
---|
405 | ENDIF |
---|
406 | IF ( simulated_time >= skip_time_do2d_xz ) THEN |
---|
407 | time_do2d_xz = time_do2d_xz + dt_3d |
---|
408 | ENDIF |
---|
409 | IF ( simulated_time >= skip_time_do2d_yz ) THEN |
---|
410 | time_do2d_yz = time_do2d_yz + dt_3d |
---|
411 | ENDIF |
---|
412 | IF ( simulated_time >= skip_time_do3d ) THEN |
---|
413 | time_do3d = time_do3d + dt_3d |
---|
414 | ENDIF |
---|
415 | DO mid = 1, masks |
---|
416 | IF ( simulated_time >= skip_time_domask(mid) ) THEN |
---|
417 | time_domask(mid)= time_domask(mid) + dt_3d |
---|
418 | ENDIF |
---|
419 | ENDDO |
---|
420 | time_dvrp = time_dvrp + dt_3d |
---|
421 | IF ( simulated_time >= skip_time_dosp ) THEN |
---|
422 | time_dosp = time_dosp + dt_3d |
---|
423 | ENDIF |
---|
424 | time_dots = time_dots + dt_3d |
---|
425 | IF ( .NOT. first_call_lpm ) THEN |
---|
426 | time_dopts = time_dopts + dt_3d |
---|
427 | ENDIF |
---|
428 | IF ( simulated_time >= skip_time_dopr ) THEN |
---|
429 | time_dopr = time_dopr + dt_3d |
---|
430 | ENDIF |
---|
431 | time_dopr_listing = time_dopr_listing + dt_3d |
---|
432 | time_run_control = time_run_control + dt_3d |
---|
433 | |
---|
434 | ! |
---|
435 | !-- Data exchange between coupled models |
---|
436 | IF ( coupling_mode /= 'uncoupled' .AND. run_coupled ) THEN |
---|
437 | time_coupling = time_coupling + dt_3d |
---|
438 | |
---|
439 | ! |
---|
440 | !-- In case of model termination initiated by the local model |
---|
441 | !-- (terminate_coupled > 0), the coupler must be skipped because it would |
---|
442 | !-- cause an MPI intercomminucation hang. |
---|
443 | !-- If necessary, the coupler will be called at the beginning of the |
---|
444 | !-- next restart run. |
---|
445 | DO WHILE ( time_coupling >= dt_coupling .AND. terminate_coupled == 0 ) |
---|
446 | CALL surface_coupler |
---|
447 | time_coupling = time_coupling - dt_coupling |
---|
448 | ENDDO |
---|
449 | ENDIF |
---|
450 | |
---|
451 | ! |
---|
452 | !-- Execute user-defined actions |
---|
453 | CALL user_actions( 'after_integration' ) |
---|
454 | |
---|
455 | ! |
---|
456 | !-- If Galilei transformation is used, determine the distance that the |
---|
457 | !-- model has moved so far |
---|
458 | IF ( galilei_transformation ) THEN |
---|
459 | advected_distance_x = advected_distance_x + u_gtrans * dt_3d |
---|
460 | advected_distance_y = advected_distance_y + v_gtrans * dt_3d |
---|
461 | ENDIF |
---|
462 | |
---|
463 | ! |
---|
464 | !-- Check, if restart is necessary (because cpu-time is expiring or |
---|
465 | !-- because it is forced by user) and set stop flag |
---|
466 | !-- This call is skipped if the remote model has already initiated a restart. |
---|
467 | IF ( .NOT. terminate_run ) CALL check_for_restart |
---|
468 | |
---|
469 | ! |
---|
470 | !-- Carry out statistical analysis and output at the requested output times. |
---|
471 | !-- The MOD function is used for calculating the output time counters (like |
---|
472 | !-- time_dopr) in order to regard a possible decrease of the output time |
---|
473 | !-- interval in case of restart runs |
---|
474 | |
---|
475 | ! |
---|
476 | !-- Set a flag indicating that so far no statistics have been created |
---|
477 | !-- for this time step |
---|
478 | flow_statistics_called = .FALSE. |
---|
479 | |
---|
480 | ! |
---|
481 | !-- If required, call flow_statistics for averaging in time |
---|
482 | IF ( averaging_interval_pr /= 0.0 .AND. & |
---|
483 | ( dt_dopr - time_dopr ) <= averaging_interval_pr .AND. & |
---|
484 | simulated_time >= skip_time_dopr ) THEN |
---|
485 | time_dopr_av = time_dopr_av + dt_3d |
---|
486 | IF ( time_dopr_av >= dt_averaging_input_pr ) THEN |
---|
487 | do_sum = .TRUE. |
---|
488 | time_dopr_av = MOD( time_dopr_av, & |
---|
489 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
490 | ENDIF |
---|
491 | ENDIF |
---|
492 | IF ( do_sum ) CALL flow_statistics |
---|
493 | |
---|
494 | ! |
---|
495 | !-- Sum-up 3d-arrays for later output of time-averaged 2d/3d/masked data |
---|
496 | IF ( averaging_interval /= 0.0 .AND. & |
---|
497 | ( dt_data_output_av - time_do_av ) <= averaging_interval .AND. & |
---|
498 | simulated_time >= skip_time_data_output_av ) & |
---|
499 | THEN |
---|
500 | time_do_sla = time_do_sla + dt_3d |
---|
501 | IF ( time_do_sla >= dt_averaging_input ) THEN |
---|
502 | CALL sum_up_3d_data |
---|
503 | average_count_3d = average_count_3d + 1 |
---|
504 | time_do_sla = MOD( time_do_sla, MAX( dt_averaging_input, dt_3d ) ) |
---|
505 | ENDIF |
---|
506 | ENDIF |
---|
507 | |
---|
508 | ! |
---|
509 | !-- Calculate spectra for time averaging |
---|
510 | IF ( averaging_interval_sp /= 0.0 .AND. & |
---|
511 | ( dt_dosp - time_dosp ) <= averaging_interval_sp .AND. & |
---|
512 | simulated_time >= skip_time_dosp ) THEN |
---|
513 | time_dosp_av = time_dosp_av + dt_3d |
---|
514 | IF ( time_dosp_av >= dt_averaging_input_pr ) THEN |
---|
515 | CALL calc_spectra |
---|
516 | time_dosp_av = MOD( time_dosp_av, & |
---|
517 | MAX( dt_averaging_input_pr, dt_3d ) ) |
---|
518 | ENDIF |
---|
519 | ENDIF |
---|
520 | |
---|
521 | ! |
---|
522 | !-- Computation and output of run control parameters. |
---|
523 | !-- This is also done whenever perturbations have been imposed |
---|
524 | IF ( time_run_control >= dt_run_control .OR. & |
---|
525 | timestep_scheme(1:5) /= 'runge' .OR. disturbance_created ) & |
---|
526 | THEN |
---|
527 | CALL run_control |
---|
528 | IF ( time_run_control >= dt_run_control ) THEN |
---|
529 | time_run_control = MOD( time_run_control, & |
---|
530 | MAX( dt_run_control, dt_3d ) ) |
---|
531 | ENDIF |
---|
532 | ENDIF |
---|
533 | |
---|
534 | ! |
---|
535 | !-- Profile output (ASCII) on file |
---|
536 | IF ( time_dopr_listing >= dt_dopr_listing ) THEN |
---|
537 | CALL print_1d |
---|
538 | time_dopr_listing = MOD( time_dopr_listing, MAX( dt_dopr_listing, & |
---|
539 | dt_3d ) ) |
---|
540 | ENDIF |
---|
541 | |
---|
542 | ! |
---|
543 | !-- Graphic output for PROFIL |
---|
544 | IF ( time_dopr >= dt_dopr ) THEN |
---|
545 | IF ( dopr_n /= 0 ) CALL data_output_profiles |
---|
546 | time_dopr = MOD( time_dopr, MAX( dt_dopr, dt_3d ) ) |
---|
547 | time_dopr_av = 0.0 ! due to averaging (see above) |
---|
548 | ENDIF |
---|
549 | |
---|
550 | ! |
---|
551 | !-- Graphic output for time series |
---|
552 | IF ( time_dots >= dt_dots ) THEN |
---|
553 | CALL data_output_tseries |
---|
554 | time_dots = MOD( time_dots, MAX( dt_dots, dt_3d ) ) |
---|
555 | ENDIF |
---|
556 | |
---|
557 | ! |
---|
558 | !-- Output of spectra (formatted for use with PROFIL), in case of no |
---|
559 | !-- time averaging, spectra has to be calculated before |
---|
560 | IF ( time_dosp >= dt_dosp ) THEN |
---|
561 | IF ( average_count_sp == 0 ) CALL calc_spectra |
---|
562 | CALL data_output_spectra |
---|
563 | time_dosp = MOD( time_dosp, MAX( dt_dosp, dt_3d ) ) |
---|
564 | ENDIF |
---|
565 | |
---|
566 | ! |
---|
567 | !-- 2d-data output (cross-sections) |
---|
568 | IF ( time_do2d_xy >= dt_do2d_xy ) THEN |
---|
569 | CALL data_output_2d( 'xy', 0 ) |
---|
570 | time_do2d_xy = MOD( time_do2d_xy, MAX( dt_do2d_xy, dt_3d ) ) |
---|
571 | ENDIF |
---|
572 | IF ( time_do2d_xz >= dt_do2d_xz ) THEN |
---|
573 | CALL data_output_2d( 'xz', 0 ) |
---|
574 | time_do2d_xz = MOD( time_do2d_xz, MAX( dt_do2d_xz, dt_3d ) ) |
---|
575 | ENDIF |
---|
576 | IF ( time_do2d_yz >= dt_do2d_yz ) THEN |
---|
577 | CALL data_output_2d( 'yz', 0 ) |
---|
578 | time_do2d_yz = MOD( time_do2d_yz, MAX( dt_do2d_yz, dt_3d ) ) |
---|
579 | ENDIF |
---|
580 | |
---|
581 | ! |
---|
582 | !-- 3d-data output (volume data) |
---|
583 | IF ( time_do3d >= dt_do3d ) THEN |
---|
584 | CALL data_output_3d( 0 ) |
---|
585 | time_do3d = MOD( time_do3d, MAX( dt_do3d, dt_3d ) ) |
---|
586 | ENDIF |
---|
587 | |
---|
588 | ! |
---|
589 | !-- masked data output |
---|
590 | DO mid = 1, masks |
---|
591 | IF ( time_domask(mid) >= dt_domask(mid) ) THEN |
---|
592 | CALL data_output_mask( 0 ) |
---|
593 | time_domask(mid) = MOD( time_domask(mid), & |
---|
594 | MAX( dt_domask(mid), dt_3d ) ) |
---|
595 | ENDIF |
---|
596 | ENDDO |
---|
597 | |
---|
598 | ! |
---|
599 | !-- Output of time-averaged 2d/3d/masked data |
---|
600 | IF ( time_do_av >= dt_data_output_av ) THEN |
---|
601 | CALL average_3d_data |
---|
602 | CALL data_output_2d( 'xy', 1 ) |
---|
603 | CALL data_output_2d( 'xz', 1 ) |
---|
604 | CALL data_output_2d( 'yz', 1 ) |
---|
605 | CALL data_output_3d( 1 ) |
---|
606 | DO mid = 1, masks |
---|
607 | CALL data_output_mask( 1 ) |
---|
608 | ENDDO |
---|
609 | time_do_av = MOD( time_do_av, MAX( dt_data_output_av, dt_3d ) ) |
---|
610 | ENDIF |
---|
611 | |
---|
612 | ! |
---|
613 | !-- Output of particle time series |
---|
614 | IF ( particle_advection ) THEN |
---|
615 | IF ( time_dopts >= dt_dopts .OR. & |
---|
616 | ( simulated_time >= particle_advection_start .AND. & |
---|
617 | first_call_lpm ) ) THEN |
---|
618 | CALL data_output_ptseries |
---|
619 | time_dopts = MOD( time_dopts, MAX( dt_dopts, dt_3d ) ) |
---|
620 | ENDIF |
---|
621 | ENDIF |
---|
622 | |
---|
623 | ! |
---|
624 | !-- Output of dvrp-graphics (isosurface, particles, slicer) |
---|
625 | #if defined( __dvrp_graphics ) |
---|
626 | CALL DVRP_LOG_EVENT( -2, current_timestep_number-1 ) |
---|
627 | #endif |
---|
628 | IF ( time_dvrp >= dt_dvrp ) THEN |
---|
629 | CALL data_output_dvrp |
---|
630 | time_dvrp = MOD( time_dvrp, MAX( dt_dvrp, dt_3d ) ) |
---|
631 | ENDIF |
---|
632 | #if defined( __dvrp_graphics ) |
---|
633 | CALL DVRP_LOG_EVENT( 2, current_timestep_number ) |
---|
634 | #endif |
---|
635 | |
---|
636 | ! |
---|
637 | !-- If required, set the heat flux for the next time step at a random value |
---|
638 | IF ( constant_heatflux .AND. random_heatflux ) CALL disturb_heatflux |
---|
639 | |
---|
640 | ! |
---|
641 | !-- Execute user-defined actions |
---|
642 | CALL user_actions( 'after_timestep' ) |
---|
643 | |
---|
644 | CALL cpu_log( log_point_s(10), 'timesteps', 'stop' ) |
---|
645 | |
---|
646 | |
---|
647 | ENDDO ! time loop |
---|
648 | |
---|
649 | #if defined( __dvrp_graphics ) |
---|
650 | CALL DVRP_LOG_EVENT( -2, current_timestep_number ) |
---|
651 | #endif |
---|
652 | |
---|
653 | END SUBROUTINE time_integration |
---|