source: palm/trunk/SOURCE/timestep.f90 @ 1329

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

last commit documented

  • Property svn:keywords set to Id
File size: 21.2 KB
Line 
1 SUBROUTINE timestep
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-2014 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! ------------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: timestep.f90 1323 2014-03-20 17:09:54Z raasch $
27!
28! 1322 2014-03-20 16:38:49Z raasch
29! REAL functions provided with KIND-attribute
30!
31! 1320 2014-03-20 08:40:49Z raasch
32! ONLY-attribute added to USE-statements,
33! kind-parameters added to all INTEGER and REAL declaration statements,
34! kinds are defined in new module kinds,
35! old module precision_kind is removed,
36! revision history before 2012 removed,
37! comment fields (!:) to be used for variable explanations added to
38! all variable declaration statements
39!
40! 1257 2013-11-08 15:18:40Z raasch
41! openacc porting
42! bugfix for calculation of advective timestep in case of vertically stretched
43! grids
44!
45! 1092 2013-02-02 11:24:22Z raasch
46! unused variables removed
47!
48! 1053 2012-11-13 17:11:03Z hoffmann
49! timestep is reduced in two-moment cloud scheme according to the maximum
50! terminal velocity of rain drops
51!
52! 1036 2012-10-22 13:43:42Z raasch
53! code put under GPL (PALM 3.9)
54!
55! 1001 2012-09-13 14:08:46Z raasch
56! all actions concerning leapfrog scheme removed
57!
58! 978 2012-08-09 08:28:32Z fricke
59! restriction of the outflow damping layer in the diffusion criterion removed
60!
61! 866 2012-03-28 06:44:41Z raasch
62! bugfix for timestep calculation in case of Galilei transformation,
63! special treatment in case of mirror velocity boundary condition removed
64!
65! Revision 1.1  1997/08/11 06:26:19  raasch
66! Initial revision
67!
68!
69! Description:
70! ------------
71! Compute the time step under consideration of the FCL and diffusion criterion.
72!------------------------------------------------------------------------------!
73
74    USE arrays_3d,                                                             &
75        ONLY:  cdc, dzu, dzw, kh, km, lad_u, lad_v, lad_w, u, v, w
76
77    USE cloud_parameters,                                                      &
78        ONLY:  dt_precipitation
79
80    USE control_parameters,                                                    &
81        ONLY:  cfl_factor, coupling_mode, dt_3d, dt_fixed, dt_max,             &
82               galilei_transformation, old_dt, plant_canopy, message_string,   &
83               stop_dt, terminate_coupled, terminate_coupled_remote,           &
84               timestep_reason, u_gtrans, use_ug_for_galilei_tr, v_gtrans
85
86    USE cpulog,                                                                &
87        ONLY:  cpu_log, log_point
88
89    USE grid_variables,                                                        &
90        ONLY:  dx, dx2, dy, dy2
91
92    USE indices,                                                               &
93        ONLY:  nxl, nxlg, nxr, nxrg, nyn, nyng, nys, nysg, nzb, nzt
94
95    USE interfaces
96
97    USE kinds
98
99    USE pegrid
100
101    USE statistics,                                                            &
102        ONLY:  flow_statistics_called, hom, u_max, u_max_ijk, v_max, v_max_ijk,&
103               w_max, w_max_ijk
104
105    IMPLICIT NONE
106
107    INTEGER(iwp) ::  i !:
108    INTEGER(iwp) ::  j !:
109    INTEGER(iwp) ::  k !:
110
111    REAL(wp) ::  div               !:
112    REAL(wp) ::  dt_diff           !:
113    REAL(wp) ::  dt_diff_l         !:
114    REAL(wp) ::  dt_plant_canopy   !:
115    REAL(wp) ::  dt_plant_canopy_l !:
116    REAL(wp) ::  dt_plant_canopy_u !:
117    REAL(wp) ::  dt_plant_canopy_v !:
118    REAL(wp) ::  dt_plant_canopy_w !:
119    REAL(wp) ::  dt_u              !:
120    REAL(wp) ::  dt_u_l            !:
121    REAL(wp) ::  dt_v              !:
122    REAL(wp) ::  dt_v_l            !:
123    REAL(wp) ::  dt_w              !:
124    REAL(wp) ::  dt_w_l            !:
125    REAL(wp) ::  u_gtrans_l        !:
126    REAL(wp) ::  u_max_l           !:
127    REAL(wp) ::  u_min_l           !:
128    REAL(wp) ::  value             !:
129    REAL(wp) ::  v_gtrans_l        !:
130    REAL(wp) ::  v_max_l           !:
131    REAL(wp) ::  v_min_l           !:
132    REAL(wp) ::  w_max_l           !:
133    REAL(wp) ::  w_min_l           !:
134 
135    REAL(wp), DIMENSION(2)         ::  uv_gtrans   !:
136    REAL(wp), DIMENSION(2)         ::  uv_gtrans_l !:
137    REAL(wp), DIMENSION(3)         ::  reduce      !:
138    REAL(wp), DIMENSION(3)         ::  reduce_l    !:
139    REAL(wp), DIMENSION(nzb+1:nzt) ::  dxyz2_min   !: 
140
141
142
143    CALL cpu_log( log_point(12), 'calculate_timestep', 'start' )
144
145!
146!-- In case of Galilei-transform not using the geostrophic wind as translation
147!-- velocity, compute the volume-averaged horizontal velocity components, which
148!-- will then be subtracted from the horizontal wind for the time step and
149!-- horizontal advection routines.
150    IF ( galilei_transformation  .AND. .NOT.  use_ug_for_galilei_tr )  THEN
151       IF ( flow_statistics_called )  THEN
152!
153!--       Horizontal averages already existent, just need to average them
154!--       vertically.
155          u_gtrans = 0.0
156          v_gtrans = 0.0
157          DO  k = nzb+1, nzt
158             u_gtrans = u_gtrans + hom(k,1,1,0)
159             v_gtrans = v_gtrans + hom(k,1,2,0)
160          ENDDO
161          u_gtrans = u_gtrans / REAL( nzt - nzb, KIND=wp )
162          v_gtrans = v_gtrans / REAL( nzt - nzb, KIND=wp )
163       ELSE
164!
165!--       Averaging over the entire model domain.
166          u_gtrans_l = 0.0
167          v_gtrans_l = 0.0
168          !$acc parallel present( u, v )
169          DO  i = nxl, nxr
170             DO  j = nys, nyn
171                DO  k = nzb+1, nzt
172                   u_gtrans_l = u_gtrans_l + u(k,j,i)
173                   v_gtrans_l = v_gtrans_l + v(k,j,i)
174                ENDDO
175             ENDDO
176          ENDDO
177          !$acc end parallel
178          uv_gtrans_l(1) = u_gtrans_l / REAL( (nxr-nxl+1)*(nyn-nys+1)*(nzt-nzb), KIND=wp )
179          uv_gtrans_l(2) = v_gtrans_l / REAL( (nxr-nxl+1)*(nyn-nys+1)*(nzt-nzb), KIND=wp )
180#if defined( __parallel )
181          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
182          CALL MPI_ALLREDUCE( uv_gtrans_l, uv_gtrans, 2, MPI_REAL, MPI_SUM, &
183                              comm2d, ierr )
184          u_gtrans = uv_gtrans(1) / REAL( numprocs, KIND=wp )
185          v_gtrans = uv_gtrans(2) / REAL( numprocs, KIND=wp )
186#else
187          u_gtrans = uv_gtrans_l(1)
188          v_gtrans = uv_gtrans_l(2)
189#endif
190       ENDIF
191    ENDIF
192
193!
194!-- Determine the maxima of the velocity components, including their
195!-- grid index positions.
196#if defined( __openacc )
197    IF ( dt_fixed )  THEN  ! otherwise do it further below for better cache usage
198       u_max_l = -999999.9
199       u_min_l =  999999.9
200       v_max_l = -999999.9
201       v_min_l =  999999.9
202       w_max_l = -999999.9
203       w_min_l =  999999.9
204       !$acc parallel present( u, v, w )
205       DO  i = nxl, nxr
206          DO  j = nys, nyn
207             DO  k = nzb+1, nzt
208                u_max_l = MAX( u_max_l, u(k,j,i) )
209                u_min_l = MIN( u_min_l, u(k,j,i) )
210                v_max_l = MAX( v_max_l, v(k,j,i) )
211                v_min_l = MIN( v_min_l, v(k,j,i) )
212                w_max_l = MAX( w_max_l, w(k,j,i) )
213                w_min_l = MIN( w_min_l, w(k,j,i) )
214             ENDDO
215          ENDDO
216       ENDDO
217       !$acc end parallel
218#if defined( __parallel )
219       reduce_l(1) = u_max_l
220       reduce_l(2) = v_max_l
221       reduce_l(3) = w_max_l
222       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
223       CALL MPI_ALLREDUCE( reduce_l, reduce, 3, MPI_REAL, MPI_MAX, comm2d, ierr )
224       u_max = reduce(1)
225       v_max = reduce(2)
226       w_max = reduce(3)
227       reduce_l(1) = u_min_l
228       reduce_l(2) = v_min_l
229       reduce_l(3) = w_min_l
230       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
231       CALL MPI_ALLREDUCE( reduce_l, reduce, 3, MPI_REAL, MPI_MIN, comm2d, ierr )
232       IF ( ABS( reduce(1) ) > u_max )  u_max = reduce(1)
233       IF ( ABS( reduce(2) ) > v_max )  v_max = reduce(2)
234       IF ( ABS( reduce(3) ) > w_max )  w_max = reduce(3)
235#else
236       IF ( ABS( u_min_l ) > u_max_l )  THEN
237          u_max = u_min_l
238       ELSE
239          u_max = u_max_l
240       ENDIF
241       IF ( ABS( v_min_l ) > v_max_l )  THEN
242          v_max = v_min_l
243       ELSE
244          v_max = v_max_l
245       ENDIF
246       IF ( ABS( w_min_l ) > w_max_l )  THEN
247          w_max = w_min_l
248       ELSE
249          w_max = w_max_l
250       ENDIF
251#endif
252    ENDIF
253#else
254    CALL global_min_max( nzb, nzt+1, nysg, nyng, nxlg, nxrg, u, 'abs', 0.0_wp, &
255                         u_max, u_max_ijk )
256    CALL global_min_max( nzb, nzt+1, nysg, nyng, nxlg, nxrg, v, 'abs', 0.0_wp, &
257                         v_max, v_max_ijk )
258    CALL global_min_max( nzb, nzt+1, nysg, nyng, nxlg, nxrg, w, 'abs', 0.0_wp, &
259                         w_max, w_max_ijk )
260#endif
261
262    IF ( .NOT. dt_fixed )  THEN
263#if defined( __openacc )
264!
265!--    Variable time step:
266!--    Calculate the maximum time step according to the CFL-criterion,
267!--    individually for each velocity component
268       dt_u_l  =  999999.9
269       dt_v_l  =  999999.9
270       dt_w_l  =  999999.9
271       u_max_l = -999999.9
272       u_min_l =  999999.9
273       v_max_l = -999999.9
274       v_min_l =  999999.9
275       w_max_l = -999999.9
276       w_min_l =  999999.9
277       !$acc parallel loop collapse(3) present( u, v, w )
278       DO  i = nxl, nxr
279          DO  j = nys, nyn
280             DO  k = nzb+1, nzt
281                dt_u_l  = MIN( dt_u_l, ( dx     / ( ABS( u(k,j,i) - u_gtrans ) + 1.0E-10 ) ) )
282                dt_v_l  = MIN( dt_v_l, ( dy     / ( ABS( v(k,j,i) - v_gtrans ) + 1.0E-10 ) ) )
283                dt_w_l  = MIN( dt_w_l, ( dzu(k) / ( ABS( w(k,j,i) )            + 1.0E-10 ) ) )
284                u_max_l = MAX( u_max_l, u(k,j,i) )
285                u_min_l = MIN( u_min_l, u(k,j,i) )
286                v_max_l = MAX( v_max_l, v(k,j,i) )
287                v_min_l = MIN( v_min_l, v(k,j,i) )
288                w_max_l = MAX( w_max_l, w(k,j,i) )
289                w_min_l = MIN( w_min_l, w(k,j,i) )
290             ENDDO
291          ENDDO
292       ENDDO
293       !$acc end parallel
294
295#if defined( __parallel )
296       reduce_l(1) = dt_u_l
297       reduce_l(2) = dt_v_l
298       reduce_l(3) = dt_w_l
299       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
300       CALL MPI_ALLREDUCE( reduce_l, reduce, 3, MPI_REAL, MPI_MIN, comm2d, ierr )
301       dt_u = reduce(1)
302       dt_v = reduce(2)
303       dt_w = reduce(3)
304
305       reduce_l(1) = u_max_l
306       reduce_l(2) = v_max_l
307       reduce_l(3) = w_max_l
308       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
309       CALL MPI_ALLREDUCE( reduce_l, reduce, 3, MPI_REAL, MPI_MAX, comm2d, ierr )
310       u_max = reduce(1)
311       v_max = reduce(2)
312       w_max = reduce(3)
313       reduce_l(1) = u_min_l
314       reduce_l(2) = v_min_l
315       reduce_l(3) = w_min_l
316       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
317       CALL MPI_ALLREDUCE( reduce_l, reduce, 3, MPI_REAL, MPI_MIN, comm2d, ierr )
318       IF ( ABS( reduce(1) ) > u_max )  u_max = reduce(1)
319       IF ( ABS( reduce(2) ) > v_max )  v_max = reduce(2)
320       IF ( ABS( reduce(3) ) > w_max )  w_max = reduce(3)
321#else
322       dt_u = dt_u_l
323       dt_v = dt_v_l
324       dt_w = dt_w_l
325
326       IF ( ABS( u_min_l ) > u_max_l )  THEN
327          u_max = u_min_l
328       ELSE
329          u_max = u_max_l
330       ENDIF
331       IF ( ABS( v_min_l ) > v_max_l )  THEN
332          v_max = v_min_l
333       ELSE
334          v_max = v_max_l
335       ENDIF
336       IF ( ABS( w_min_l ) > w_max_l )  THEN
337          w_max = w_min_l
338       ELSE
339          w_max = w_max_l
340       ENDIF
341#endif
342
343#else
344!
345!--    Variable time step:
346!--    Calculate the maximum time step according to the CFL-criterion,
347!--    individually for each velocity component
348       dt_u_l = 999999.9
349       dt_v_l = 999999.9
350       dt_w_l = 999999.9
351       DO  i = nxl, nxr
352          DO  j = nys, nyn
353             DO  k = nzb+1, nzt
354                dt_u_l = MIN( dt_u_l, ( dx     / ( ABS( u(k,j,i) - u_gtrans ) + 1.0E-10 ) ) )
355                dt_v_l = MIN( dt_v_l, ( dy     / ( ABS( v(k,j,i) - v_gtrans ) + 1.0E-10 ) ) )
356                dt_w_l = MIN( dt_w_l, ( dzu(k) / ( ABS( w(k,j,i) )            + 1.0E-10 ) ) )
357             ENDDO
358          ENDDO
359       ENDDO
360
361#if defined( __parallel )
362       reduce_l(1) = dt_u_l
363       reduce_l(2) = dt_v_l
364       reduce_l(3) = dt_w_l
365       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
366       CALL MPI_ALLREDUCE( reduce_l, reduce, 3, MPI_REAL, MPI_MIN, comm2d, ierr )
367       dt_u = reduce(1)
368       dt_v = reduce(2)
369       dt_w = reduce(3)
370#else
371       dt_u = dt_u_l
372       dt_v = dt_v_l
373       dt_w = dt_w_l
374#endif
375
376#endif
377
378!
379!--    Compute time step according to the diffusion criterion.
380!--    First calculate minimum grid spacing which only depends on index k
381!--    Note: also at k=nzb+1 a full grid length is being assumed, although
382!--          in the Prandtl-layer friction term only dz/2 is used.
383!--          Experience from the old model seems to justify this.
384       dt_diff_l = 999999.0
385
386       DO  k = nzb+1, nzt
387           dxyz2_min(k) = MIN( dx2, dy2, dzw(k)*dzw(k) ) * 0.125
388       ENDDO
389
390!$OMP PARALLEL private(i,j,k,value) reduction(MIN: dt_diff_l)
391!$OMP DO
392       !$acc parallel loop collapse(3) present( kh, km )
393       DO  i = nxl, nxr
394          DO  j = nys, nyn
395             DO  k = nzb+1, nzt
396                dt_diff_l = MIN( dt_diff_l, dxyz2_min(k) / &
397                                       ( MAX( kh(k,j,i), km(k,j,i) ) + 1E-20 ) )
398             ENDDO
399          ENDDO
400       ENDDO
401       !$acc end parallel
402!$OMP END PARALLEL
403#if defined( __parallel )
404       IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
405       CALL MPI_ALLREDUCE( dt_diff_l, dt_diff, 1, MPI_REAL, MPI_MIN, comm2d, &
406                           ierr )
407#else
408       dt_diff = dt_diff_l
409#endif
410
411!
412!--    Additional timestep criterion with plant canopies:
413!--    it is not allowed to extract more than the available momentum
414       IF ( plant_canopy ) THEN
415
416          dt_plant_canopy_l = 0.0
417          DO  i = nxl, nxr
418             DO  j = nys, nyn
419                DO k = nzb+1, nzt
420                   dt_plant_canopy_u = cdc(k,j,i) * lad_u(k,j,i) *  &
421                                       SQRT(     u(k,j,i)**2     +  &
422                                             ( ( v(k,j,i-1)      +  &
423                                                 v(k,j,i)        +  &
424                                                 v(k,j+1,i)      +  &
425                                                 v(k,j+1,i-1) )     &
426                                               / 4.0 )**2        +  &
427                                             ( ( w(k-1,j,i-1)    +  &
428                                                 w(k-1,j,i)      +  &
429                                                 w(k,j,i-1)      +  &
430                                                 w(k,j,i) )         &
431                                                 / 4.0 )**2 ) 
432                   IF ( dt_plant_canopy_u > dt_plant_canopy_l ) THEN
433                      dt_plant_canopy_l = dt_plant_canopy_u 
434                   ENDIF
435                   dt_plant_canopy_v = cdc(k,j,i) * lad_v(k,j,i) *  &
436                                       SQRT( ( ( u(k,j-1,i)      +  &
437                                                 u(k,j-1,i+1)    +  &
438                                                 u(k,j,i)        +  &
439                                                 u(k,j,i+1) )       &
440                                               / 4.0 )**2        +  &
441                                                 v(k,j,i)**2     +  &
442                                             ( ( w(k-1,j-1,i)    +  &
443                                                 w(k-1,j,i)      +  &
444                                                 w(k,j-1,i)      +  &
445                                                 w(k,j,i) )         &
446                                                 / 4.0 )**2 ) 
447                   IF ( dt_plant_canopy_v > dt_plant_canopy_l ) THEN
448                      dt_plant_canopy_l = dt_plant_canopy_v
449                   ENDIF                   
450                   dt_plant_canopy_w = cdc(k,j,i) * lad_w(k,j,i) *  &
451                                       SQRT( ( ( u(k,j,i)        +  &
452                                                 u(k,j,i+1)      +  &
453                                                 u(k+1,j,i)      +  &
454                                                 u(k+1,j,i+1) )     &
455                                               / 4.0 )**2        +  &
456                                             ( ( v(k,j,i)        +  &
457                                                 v(k,j+1,i)      +  &
458                                                 v(k+1,j,i)      +  &
459                                                 v(k+1,j+1,i) )     &
460                                               / 4.0 )**2        +  &
461                                                 w(k,j,i)**2 )     
462                   IF ( dt_plant_canopy_w > dt_plant_canopy_l ) THEN
463                      dt_plant_canopy_l = dt_plant_canopy_w
464                   ENDIF
465                ENDDO
466             ENDDO
467          ENDDO 
468
469          IF ( dt_plant_canopy_l > 0.0 ) THEN
470!
471!--          Invert dt_plant_canopy_l and apply a security timestep factor 0.1
472             dt_plant_canopy_l = 0.1 / dt_plant_canopy_l
473          ELSE
474!
475!--          In case of inhomogeneous plant canopy, some processors may have no
476!--          canopy at all. Then use dt_max as dummy instead.
477             dt_plant_canopy_l = dt_max
478          ENDIF
479
480!
481!--       Determine the global minumum
482#if defined( __parallel )
483          IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
484          CALL MPI_ALLREDUCE( dt_plant_canopy_l, dt_plant_canopy, 1, MPI_REAL, &
485                              MPI_MIN, comm2d, ierr )
486#else
487          dt_plant_canopy = dt_plant_canopy_l
488#endif
489
490       ELSE
491!
492!--       Use dt_diff as dummy value to avoid extra IF branches further below
493          dt_plant_canopy = dt_diff
494
495       ENDIF
496
497!
498!--    The time step is the minimum of the 3-4 components and the diffusion time
499!--    step minus a reduction (cfl_factor) to be on the safe side.
500!--    The time step must not exceed the maximum allowed value.
501       dt_3d = cfl_factor * MIN( dt_diff, dt_plant_canopy, dt_u, dt_v, dt_w,   &
502                                 dt_precipitation )
503       dt_3d = MIN( dt_3d, dt_max )
504
505!
506!--    Remember the restricting time step criterion for later output.
507       IF ( MIN( dt_u, dt_v, dt_w ) < MIN( dt_diff, dt_plant_canopy ) )  THEN
508          timestep_reason = 'A'
509       ELSEIF ( dt_plant_canopy < dt_diff )  THEN
510          timestep_reason = 'C'
511       ELSE
512          timestep_reason = 'D'
513       ENDIF
514
515!
516!--    Set flag if the time step becomes too small.
517       IF ( dt_3d < ( 0.00001 * dt_max ) )  THEN
518          stop_dt = .TRUE.
519
520          WRITE( message_string, * ) 'Time step has reached minimum limit.',  &
521               '&dt              = ', dt_3d, ' s  Simulation is terminated.', &
522               '&old_dt          = ', old_dt, ' s',                           &
523               '&dt_u            = ', dt_u, ' s',                             &
524               '&dt_v            = ', dt_v, ' s',                             &
525               '&dt_w            = ', dt_w, ' s',                             &
526               '&dt_diff         = ', dt_diff, ' s',                          &
527               '&dt_plant_canopy = ', dt_plant_canopy, ' s',                  &
528               '&u_max           = ', u_max, ' m/s   k=', u_max_ijk(1),       &
529               '  j=', u_max_ijk(2), '  i=', u_max_ijk(3),                    &
530               '&v_max           = ', v_max, ' m/s   k=', v_max_ijk(1),       &
531               '  j=', v_max_ijk(2), '  i=', v_max_ijk(3),                    &
532               '&w_max           = ', w_max, ' m/s   k=', w_max_ijk(1),       &
533               '  j=', w_max_ijk(2), '  i=', w_max_ijk(3)
534          CALL message( 'timestep', 'PA0312', 0, 1, 0, 6, 0 )
535!
536!--       In case of coupled runs inform the remote model of the termination
537!--       and its reason, provided the remote model has not already been
538!--       informed of another termination reason (terminate_coupled > 0) before.
539#if defined( __parallel )
540          IF ( coupling_mode /= 'uncoupled' .AND. terminate_coupled == 0 )  THEN
541             terminate_coupled = 2
542             IF ( myid == 0 ) THEN
543                CALL MPI_SENDRECV( &
544                     terminate_coupled,        1, MPI_INTEGER, target_id,  0, &
545                     terminate_coupled_remote, 1, MPI_INTEGER, target_id,  0, &
546                     comm_inter, status, ierr )
547             ENDIF
548             CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_INTEGER, 0, comm2d, ierr)
549          ENDIF
550#endif
551       ENDIF
552
553!
554!--    Ensure a smooth value (two significant digits) of the timestep.
555       div = 1000.0
556       DO  WHILE ( dt_3d < div )
557          div = div / 10.0
558       ENDDO
559       dt_3d = NINT( dt_3d * 100.0 / div ) * div / 100.0
560
561!
562!--    Adjust the time step
563       old_dt = dt_3d
564
565    ENDIF
566
567    CALL cpu_log( log_point(12), 'calculate_timestep', 'stop' )
568
569 END SUBROUTINE timestep
Note: See TracBrowser for help on using the repository browser.