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

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

last commit documented

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