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

Last change on this file since 1036 was 1036, checked in by raasch, 9 years ago

code has been put under the GNU General Public License (v3)

  • Property svn:keywords set to Id
File size: 5.2 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-2012  Leibniz University Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: local_stop.f90 1036 2012-10-22 13:43:42Z raasch $
27!
28! 809 2012-01-30 13:32:58Z maronga
29! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
30!
31! 807 2012-01-25 11:53:51Z maronga
32! New cpp directive "__check" implemented which is used by check_namelist_files
33!
34! 667 2010-12-23 12:06:00Z suehring/gryschka
35! Exchange of terminate_coupled between ocean and atmosphere via PE0
36!
37! 213 2008-11-13 10:26:18Z raasch
38! Implementation of a MPI-1 coupling: replaced myid with target_id.
39! The uncoupled case allows stop or mpi_abort depending on new steering
40! parameter abort_mode, which is set in routine message.
41!
42! 147 2008-02-01 12:41:46Z raasch
43! Bugfix: a stop command was missing in some cases of the parallel branch
44!
45! 108 2007-08-24 15:10:38Z letzel
46! modifications to terminate coupled runs
47!
48! RCS Log replace by Id keyword, revision history cleaned up
49!
50! Revision 1.2  2003/03/16 09:40:28  raasch
51! Two underscores (_) are placed in front of all define-strings
52!
53! Revision 1.1  2002/12/19 15:46:23  raasch
54! Initial revision
55!
56!
57! Description:
58! ------------
59! Stop program execution
60!------------------------------------------------------------------------------!
61
62    USE pegrid
63    USE control_parameters
64
65
66#if defined( __parallel ) && ! defined ( __check )
67    IF ( coupling_mode == 'uncoupled' )  THEN
68       IF ( abort_mode == 1 )  THEN
69          CALL MPI_FINALIZE( ierr )
70          STOP
71       ELSEIF ( abort_mode == 2 )  THEN
72          CALL MPI_ABORT( comm2d, 9999, ierr )
73       ENDIF
74    ELSE
75
76       SELECT CASE ( terminate_coupled_remote )
77
78          CASE ( 0 )
79             IF ( myid == 0 )  THEN
80                PRINT*, '+++ local_stop:'
81                PRINT*, '    local model "', TRIM( coupling_mode ), &
82                     '" stops now'
83             ENDIF
84!
85!--          Inform the remote model of the termination and its reason, provided
86!--          the remote model has not already been informed of another
87!--          termination reason (terminate_coupled > 0) before.
88             IF ( terminate_coupled == 0 )  THEN
89                terminate_coupled = 1
90                IF ( myid == 0 ) THEN
91                   CALL MPI_SENDRECV( &
92                        terminate_coupled,        1, MPI_INTEGER, target_id,  0, &
93                        terminate_coupled_remote, 1, MPI_INTEGER, target_id,  0, &
94                        comm_inter, status, ierr )
95                ENDIF
96                CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_REAL, 0, comm2d, ierr)
97             ENDIF
98             CALL MPI_FINALIZE( ierr )
99             STOP
100
101          CASE ( 1 )
102             IF ( myid == 0 )  THEN
103                PRINT*, '+++ local_stop:'
104                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
105                     '" stopped'
106             ENDIF
107             CALL MPI_FINALIZE( ierr )
108             STOP
109
110          CASE ( 2 )
111             IF ( myid == 0 )  THEN
112                PRINT*, '+++ local_stop:'
113                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
114                     '" terminated'
115                PRINT*, '    with stop_dt = .T.'
116             ENDIF
117             stop_dt = .TRUE.
118
119          CASE ( 3 )
120             IF ( myid == 0 )  THEN
121                PRINT*, '+++ local_stop:'
122                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
123                     '" terminated'
124                PRINT*, '    with terminate_run = .T. (CPU-time limit)'
125             ENDIF
126             terminate_run = .TRUE.
127
128          CASE ( 4 )
129             IF ( myid == 0 )  THEN
130                PRINT*, '+++ local_stop:'
131                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
132                     '" terminated'
133                PRINT*, '    with terminate_run = .T. (restart)'
134             ENDIF
135             terminate_run = .TRUE.
136             time_restart = time_restart + dt_restart
137
138          CASE ( 5 )
139             IF ( myid == 0 )  THEN
140                PRINT*, '+++ local_stop:'
141                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
142                     '" terminated'
143                PRINT*, '    with terminate_run = .T. (single restart)'
144             ENDIF
145             terminate_run = .TRUE.
146             time_restart = 9999999.9
147
148       END SELECT
149
150    ENDIF
151
152#else
153
154    STOP
155
156#endif
157
158 END SUBROUTINE local_stop   
Note: See TracBrowser for help on using the repository browser.