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

Last change on this file since 1308 was 1308, checked in by fricke, 10 years ago

Adjustments for parallel NetCDF output for lccrayh/lccrayb (Cray XC30 systems)

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