source: palm/trunk/SOURCE/check_for_restart.f90 @ 108

Last change on this file since 108 was 108, checked in by letzel, 17 years ago
  • Improved coupler: evaporation - salinity-flux coupling for humidity = .T.,

avoid MPI hangs when coupled runs terminate, add DOC/app/chapter_3.8;

  • Optional calculation of km and kh from initial TKE e_init;
  • Default initialization of km,kh = 0.00001 for ocean = .T.;
  • Allow data_output_pr= q, wq, w"q", w*q* for humidity = .T.;
  • Bugfix: Rayleigh damping for ocean fixed.
  • Property svn:keywords set to Id
File size: 4.5 KB
RevLine 
[1]1 SUBROUTINE check_for_restart
2
3!------------------------------------------------------------------------------!
4! Actual revisions:
5! -----------------
[108]6! modifications to terminate coupled runs
[1]7!
8!
9! Former revisions:
10! -----------------
[3]11! $Id: check_for_restart.f90 108 2007-08-24 15:10:38Z letzel $
12! RCS Log replace by Id keyword, revision history cleaned up
13!
[1]14! Revision 1.11  2007/02/11 12:55:13  raasch
15! Informative output to the job protocol
16!
17! Revision 1.1  1998/03/18 20:06:51  raasch
18! Initial revision
19!
20!
21! Description:
22! ------------
23! Set stop flag, if restart is neccessary because of expiring cpu-time or
24! if it is forced by user
25!------------------------------------------------------------------------------!
26
27    USE pegrid
28    USE control_parameters
29
30    IMPLICIT NONE
31
32
33    LOGICAL :: terminate_run_l
34    REAL ::  remaining_time
35
36
37!
38!-- Check remaining CPU-time
39    CALL local_tremain( remaining_time )
40
41!
42!-- If necessary set a flag to stop the model run
43    terminate_run_l = .FALSE.
44    IF ( remaining_time <= termination_time_needed  .AND. &
45         write_binary(1:4) == 'true' )  THEN
46
47       terminate_run_l = .TRUE.
48    ENDIF
49
50#if defined( __parallel )
51!
52!-- Make a logical OR for all processes. Stop the model run if at least
53!-- one processor has reached the time limit.
54    CALL MPI_ALLREDUCE( terminate_run_l, terminate_run, 1, MPI_LOGICAL, &
55                        MPI_LOR, comm2d, ierr )
56#else
57    terminate_run = terminate_run_l
58#endif
59
60!
61!-- Output that job will be terminated
62    IF ( terminate_run  .AND.  myid == 0 )  THEN
63       PRINT*, '*** WARNING: run will be terminated because it is running out of job cpu', &
64                    'limit'
65       PRINT*, '             remaining time:         ', remaining_time, ' s'
66       PRINT*, '             termination time needed:', termination_time_needed, ' s'
67    ENDIF
68
69!
[108]70!-- In case of coupled runs inform the remote model of the termination
71!-- and its reason, provided the remote model has not already been
72!-- informed of another termination reason (terminate_coupled > 0) before,
73!-- or vice versa (terminate_coupled_remote > 0).
74    IF ( terminate_run .AND. TRIM( coupling_mode ) /= 'uncoupled'  &
75         .AND. terminate_coupled == 0  &
76         .AND. terminate_coupled_remote == 0 )  THEN
77       terminate_coupled = 3
78       CALL MPI_SENDRECV( &
79            terminate_coupled,        1, MPI_INTEGER, myid,  0, &
80            terminate_coupled_remote, 1, MPI_INTEGER, myid,  0, &
81            comm_inter, status, ierr )
82    ENDIF
83
84!
[1]85!-- Set the stop flag also, if restart is forced by user
86    IF ( time_restart /= 9999999.9  .AND.  time_restart < simulated_time ) &
87    THEN
88!
89!--    Restart is not neccessary, if the end time of the run (given by
90!--    the user) has been reached
91       IF ( simulated_time < end_time )  THEN
92          terminate_run = .TRUE.
93!
94!--       Increment restart time, if forced by user, otherwise set restart
95!--       time to default (no user restart)
96          IF ( dt_restart /= 9999999.9 )  THEN
97             time_restart = time_restart + dt_restart
98          ELSE
99             time_restart = 9999999.9
100          ENDIF
101
102          IF ( myid == 0 )  THEN
103             PRINT*, '*** INFORMATIVE: run will be terminated due to user settings of'
104             PRINT*, '                 restart_time / dt_restart'
105             PRINT*, '                 new restart time is: ', time_restart, ' s'
106          ENDIF
[108]107!
108!--       In case of coupled runs inform the remote model of the termination
109!--       and its reason, provided the remote model has not already been
110!--       informed of another termination reason (terminate_coupled > 0) before,
111!--       or vice versa (terminate_coupled_remote > 0).
112          IF ( coupling_mode /= 'uncoupled' .AND. terminate_coupled == 0  &
113               .AND. terminate_coupled_remote == 0)  THEN
114             IF ( dt_restart /= 9999999.9 )  THEN
115                terminate_coupled = 4
116             ELSE
117                terminate_coupled = 5
118             ENDIF
119             CALL MPI_SENDRECV( &
120                  terminate_coupled,        1, MPI_INTEGER, myid,  0, &
121                  terminate_coupled_remote, 1, MPI_INTEGER, myid,  0, &
122                  comm_inter, status, ierr )
123          ENDIF
124       ELSE
[1]125          time_restart = 9999999.9
126       ENDIF
127    ENDIF
128
129!
130!-- If the run is stopped, set a flag file which is necessary to initiate
131!-- the start of a continuation run
132    IF ( terminate_run  .AND.  myid == 0 )  THEN
133
134       OPEN ( 90, FILE='CONTINUE_RUN', FORM='FORMATTED' )
135       WRITE ( 90, '(A)' )  TRIM( run_description_header )
136       CLOSE ( 90 )
137
138    ENDIF
139
140
141 END SUBROUTINE check_for_restart
Note: See TracBrowser for help on using the repository browser.