source: palm/trunk/SOURCE/local_stop.f90 @ 1418

Last change on this file since 1418 was 1354, checked in by heinze, 10 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 5.0 KB
Line 
1 SUBROUTINE local_stop
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: local_stop.f90 1354 2014-04-08 15:22:57Z fricke $
27!
28! 1353 2014-04-08 15:21:23Z heinze
29! REAL constants provided with KIND-attribute
30!
31! 1320 2014-03-20 08:40:49Z raasch
32! ONLY-attribute added to USE-statements,
33! revision history before 2012 removed
34!
35! 1036 2012-10-22 13:43:42Z raasch
36! code put under GPL (PALM 3.9)
37!
38! 809 2012-01-30 13:32:58Z maronga
39! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
40!
41! 807 2012-01-25 11:53:51Z maronga
42! New cpp directive "__check" implemented which is used by check_namelist_files
43!
44! Revision 1.1  2002/12/19 15:46:23  raasch
45! Initial revision
46!
47!
48! Description:
49! ------------
50! Stop program execution
51!------------------------------------------------------------------------------!
52
53    USE pegrid
54   
55    USE control_parameters,                                                    &
56        ONLY:  abort_mode, coupling_mode, coupling_mode_remote, dt_restart,    &
57               stop_dt, terminate_coupled, terminate_coupled_remote,           &
58               terminate_run, time_restart
59
60
61#if defined( __parallel ) && ! defined ( __check )
62    IF ( coupling_mode == 'uncoupled' )  THEN
63       IF ( abort_mode == 1 )  THEN
64          CALL MPI_FINALIZE( ierr )
65          STOP
66       ELSEIF ( abort_mode == 2 )  THEN
67          CALL MPI_ABORT( comm2d, 9999, ierr )
68       ENDIF
69    ELSE
70
71       SELECT CASE ( terminate_coupled_remote )
72
73          CASE ( 0 )
74             IF ( myid == 0 )  THEN
75                PRINT*, '+++ local_stop:'
76                PRINT*, '    local model "', TRIM( coupling_mode ), &
77                     '" stops now'
78             ENDIF
79!
80!--          Inform the remote model of the termination and its reason, provided
81!--          the remote model has not already been informed of another
82!--          termination reason (terminate_coupled > 0) before.
83             IF ( terminate_coupled == 0 )  THEN
84                terminate_coupled = 1
85                IF ( myid == 0 ) THEN
86                   CALL MPI_SENDRECV( &
87                        terminate_coupled,        1, MPI_INTEGER, target_id,  0, &
88                        terminate_coupled_remote, 1, MPI_INTEGER, target_id,  0, &
89                        comm_inter, status, ierr )
90                ENDIF
91                CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_REAL, 0, comm2d, ierr)
92             ENDIF
93             CALL MPI_FINALIZE( ierr )
94             STOP
95
96          CASE ( 1 )
97             IF ( myid == 0 )  THEN
98                PRINT*, '+++ local_stop:'
99                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
100                     '" stopped'
101             ENDIF
102             CALL MPI_FINALIZE( ierr )
103             STOP
104
105          CASE ( 2 )
106             IF ( myid == 0 )  THEN
107                PRINT*, '+++ local_stop:'
108                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
109                     '" terminated'
110                PRINT*, '    with stop_dt = .T.'
111             ENDIF
112             stop_dt = .TRUE.
113
114          CASE ( 3 )
115             IF ( myid == 0 )  THEN
116                PRINT*, '+++ local_stop:'
117                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
118                     '" terminated'
119                PRINT*, '    with terminate_run = .T. (CPU-time limit)'
120             ENDIF
121             terminate_run = .TRUE.
122
123          CASE ( 4 )
124             IF ( myid == 0 )  THEN
125                PRINT*, '+++ local_stop:'
126                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
127                     '" terminated'
128                PRINT*, '    with terminate_run = .T. (restart)'
129             ENDIF
130             terminate_run = .TRUE.
131             time_restart = time_restart + dt_restart
132
133          CASE ( 5 )
134             IF ( myid == 0 )  THEN
135                PRINT*, '+++ local_stop:'
136                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
137                     '" terminated'
138                PRINT*, '    with terminate_run = .T. (single restart)'
139             ENDIF
140             terminate_run = .TRUE.
141             time_restart = 9999999.9_wp
142
143       END SELECT
144
145    ENDIF
146
147#else
148
149    STOP
150
151#endif
152
153 END SUBROUTINE local_stop   
Note: See TracBrowser for help on using the repository browser.