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

Last change on this file since 1257 was 1257, checked in by raasch, 10 years ago

New:
---

openACC porting of timestep calculation
(modules, timestep, time_integration)

Changed:


openACC loop directives and vector clauses removed (because they do not give any performance improvement with PGI
compiler versions > 13.6)
(advec_ws, buoyancy, coriolis, diffusion_e, diffusion_s, diffusion_u, diffusion_v, diffusion_w, diffusivities, exchange_horiz, fft_xy, pres, production_e, transpose, tridia_solver, wall_fluxes)

openACC loop independent clauses added
(boundary_conds, prandtl_fluxes, pres)

openACC declare create statements moved after FORTRAN declaration statement
(diffusion_u, diffusion_v, diffusion_w, fft_xy, poisfft, production_e, tridia_solver)

openACC end parallel replaced by end parallel loop
(flow_statistics, pres)

openACC "kernels do" replaced by "kernels loop"
(prandtl_fluxes)

output format for theta* changed to avoid output of *
(run_control)

Errors:


bugfix for calculation of advective timestep (old version may cause wrong timesteps in case of
vertixcally stretched grids)
Attention: standard run-control output has changed!
(timestep)

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