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

Last change on this file since 1682 was 1682, checked in by knoop, 9 years ago

Code annotations made doxygen readable

  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1!> @file local_stop.f90
2!--------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the terms
6! of the GNU General Public License as published by the Free Software Foundation,
7! either version 3 of the License, or (at your option) any later version.
8!
9! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
10! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12!
13! You should have received a copy of the GNU General Public License along with
14! PALM. If not, see <http://www.gnu.org/licenses/>.
15!
16! Copyright 1997-2014 Leibniz Universitaet Hannover
17!--------------------------------------------------------------------------------!
18!
19! Current revisions:
20! -----------------
21! Code annotations made doxygen readable
22!
23! Former revisions:
24! -----------------
25! $Id: local_stop.f90 1682 2015-10-07 23:56:08Z knoop $
26!
27! 1353 2014-04-08 15:21:23Z heinze
28! REAL constants provided with KIND-attribute
29!
30! 1320 2014-03-20 08:40:49Z raasch
31! ONLY-attribute added to USE-statements,
32! revision history before 2012 removed
33!
34! 1036 2012-10-22 13:43:42Z raasch
35! code put under GPL (PALM 3.9)
36!
37! 809 2012-01-30 13:32:58Z maronga
38! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
39!
40! 807 2012-01-25 11:53:51Z maronga
41! New cpp directive "__check" implemented which is used by check_namelist_files
42!
43! Revision 1.1  2002/12/19 15:46:23  raasch
44! Initial revision
45!
46!
47! Description:
48! ------------
49!> Stop program execution
50!------------------------------------------------------------------------------!
51 SUBROUTINE local_stop
52 
53
54    USE pegrid
55   
56    USE control_parameters,                                                    &
57        ONLY:  abort_mode, coupling_mode, coupling_mode_remote, dt_restart,    &
58               stop_dt, terminate_coupled, terminate_coupled_remote,           &
59               terminate_run, time_restart
60
61
62#if defined( __parallel ) && ! defined ( __check )
63    IF ( coupling_mode == 'uncoupled' )  THEN
64       IF ( abort_mode == 1 )  THEN
65          CALL MPI_FINALIZE( ierr )
66          STOP
67       ELSEIF ( abort_mode == 2 )  THEN
68          CALL MPI_ABORT( comm2d, 9999, ierr )
69       ENDIF
70    ELSE
71
72       SELECT CASE ( terminate_coupled_remote )
73
74          CASE ( 0 )
75             IF ( myid == 0 )  THEN
76                PRINT*, '+++ local_stop:'
77                PRINT*, '    local model "', TRIM( coupling_mode ), &
78                     '" stops now'
79             ENDIF
80!
81!--          Inform the remote model of the termination and its reason, provided
82!--          the remote model has not already been informed of another
83!--          termination reason (terminate_coupled > 0) before.
84             IF ( terminate_coupled == 0 )  THEN
85                terminate_coupled = 1
86                IF ( myid == 0 ) THEN
87                   CALL MPI_SENDRECV( &
88                        terminate_coupled,        1, MPI_INTEGER, target_id,  0, &
89                        terminate_coupled_remote, 1, MPI_INTEGER, target_id,  0, &
90                        comm_inter, status, ierr )
91                ENDIF
92                CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_REAL, 0, comm2d, ierr)
93             ENDIF
94             CALL MPI_FINALIZE( ierr )
95             STOP
96
97          CASE ( 1 )
98             IF ( myid == 0 )  THEN
99                PRINT*, '+++ local_stop:'
100                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
101                     '" stopped'
102             ENDIF
103             CALL MPI_FINALIZE( ierr )
104             STOP
105
106          CASE ( 2 )
107             IF ( myid == 0 )  THEN
108                PRINT*, '+++ local_stop:'
109                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
110                     '" terminated'
111                PRINT*, '    with stop_dt = .T.'
112             ENDIF
113             stop_dt = .TRUE.
114
115          CASE ( 3 )
116             IF ( myid == 0 )  THEN
117                PRINT*, '+++ local_stop:'
118                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
119                     '" terminated'
120                PRINT*, '    with terminate_run = .T. (CPU-time limit)'
121             ENDIF
122             terminate_run = .TRUE.
123
124          CASE ( 4 )
125             IF ( myid == 0 )  THEN
126                PRINT*, '+++ local_stop:'
127                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
128                     '" terminated'
129                PRINT*, '    with terminate_run = .T. (restart)'
130             ENDIF
131             terminate_run = .TRUE.
132             time_restart = time_restart + dt_restart
133
134          CASE ( 5 )
135             IF ( myid == 0 )  THEN
136                PRINT*, '+++ local_stop:'
137                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
138                     '" terminated'
139                PRINT*, '    with terminate_run = .T. (single restart)'
140             ENDIF
141             terminate_run = .TRUE.
142             time_restart = 9999999.9_wp
143
144       END SELECT
145
146    ENDIF
147
148#else
149
150    STOP
151
152#endif
153
154 END SUBROUTINE local_stop   
Note: See TracBrowser for help on using the repository browser.