source: palm/trunk/SOURCE/time_integration.f90 @ 1185

Last change on this file since 1185 was 1182, checked in by raasch, 11 years ago

last commit documented, rc-file for example run updated

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