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

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

REAL functions and a lot of REAL constants provided with KIND-attribute,
some small bugfixes

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