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

Last change on this file since 2053 was 2001, checked in by knoop, 8 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 5.9 KB
RevLine 
[1682]1!> @file local_stop.f90
[2000]2!------------------------------------------------------------------------------!
[1036]3! This file is part of PALM.
4!
[2000]5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! version.
[1036]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!
[1818]17! Copyright 1997-2016 Leibniz Universitaet Hannover
[2000]18!------------------------------------------------------------------------------!
[1036]19!
[484]20! Current revisions:
[1]21! -----------------
[1805]22!
[2001]23!
[1]24! Former revisions:
25! -----------------
[3]26! $Id: local_stop.f90 2001 2016-08-20 18:41:22Z gronemeier $
[110]27!
[2001]28! 2000 2016-08-20 18:09:15Z knoop
29! Forced header and separation lines into 80 columns
30!
[1805]31! 1804 2016-04-05 16:30:18Z maronga
32! Removed code for parameter file check (__check)
33!
[1765]34! 1764 2016-02-28 12:45:19Z raasch
35! abort with MPI_COMM_WORLD added, nested runs always abort with MPI_ABORT
36!
[1683]37! 1682 2015-10-07 23:56:08Z knoop
38! Code annotations made doxygen readable
39!
[1354]40! 1353 2014-04-08 15:21:23Z heinze
41! REAL constants provided with KIND-attribute
42!
[1321]43! 1320 2014-03-20 08:40:49Z raasch
44! ONLY-attribute added to USE-statements,
45! revision history before 2012 removed
46!
[1037]47! 1036 2012-10-22 13:43:42Z raasch
48! code put under GPL (PALM 3.9)
49!
[810]50! 809 2012-01-30 13:32:58Z maronga
51! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
52!
[808]53! 807 2012-01-25 11:53:51Z maronga
54! New cpp directive "__check" implemented which is used by check_namelist_files
55!
[1]56! Revision 1.1  2002/12/19 15:46:23  raasch
57! Initial revision
58!
59!
60! Description:
61! ------------
[1682]62!> Stop program execution
[3]63!------------------------------------------------------------------------------!
[1682]64 SUBROUTINE local_stop
65 
[1]66
[1320]67    USE control_parameters,                                                    &
68        ONLY:  abort_mode, coupling_mode, coupling_mode_remote, dt_restart,    &
69               stop_dt, terminate_coupled, terminate_coupled_remote,           &
70               terminate_run, time_restart
[1]71
[1764]72    USE pegrid
[206]73
[1764]74    USE pmc_interface,                                                         &
75        ONLY:  nested_run
76
[1804]77#if defined( __parallel )
[108]78    IF ( coupling_mode == 'uncoupled' )  THEN
[1764]79       IF ( nested_run )  THEN
80!
81!--       Workaround: If any of the nested model crashes, it aborts the whole
82!--       run with MPI_ABORT, regardless of the reason given by abort_mode
83          CALL MPI_ABORT( MPI_COMM_WORLD, 9999, ierr )
84       ELSE
85          IF ( abort_mode == 1 )  THEN
86             CALL MPI_FINALIZE( ierr )
87             STOP
88          ELSEIF ( abort_mode == 2 )  THEN
89             CALL MPI_ABORT( comm2d, 9999, ierr )
90          ELSEIF ( abort_mode == 3 )  THEN
91             CALL MPI_ABORT( MPI_COMM_WORLD, 9999, ierr )
92          ENDIF
[213]93       ENDIF
[108]94    ELSE
[1]95
[108]96       SELECT CASE ( terminate_coupled_remote )
97
98          CASE ( 0 )
99             IF ( myid == 0 )  THEN
100                PRINT*, '+++ local_stop:'
101                PRINT*, '    local model "', TRIM( coupling_mode ), &
102                     '" stops now'
103             ENDIF
104!
105!--          Inform the remote model of the termination and its reason, provided
106!--          the remote model has not already been informed of another
107!--          termination reason (terminate_coupled > 0) before.
108             IF ( terminate_coupled == 0 )  THEN
109                terminate_coupled = 1
[667]110                IF ( myid == 0 ) THEN
111                   CALL MPI_SENDRECV( &
112                        terminate_coupled,        1, MPI_INTEGER, target_id,  0, &
113                        terminate_coupled_remote, 1, MPI_INTEGER, target_id,  0, &
114                        comm_inter, status, ierr )
115                ENDIF
116                CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_REAL, 0, comm2d, ierr)
[108]117             ENDIF
118             CALL MPI_FINALIZE( ierr )
[147]119             STOP
[108]120
121          CASE ( 1 )
122             IF ( myid == 0 )  THEN
123                PRINT*, '+++ local_stop:'
124                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
125                     '" stopped'
126             ENDIF
127             CALL MPI_FINALIZE( ierr )
[147]128             STOP
[108]129
130          CASE ( 2 )
131             IF ( myid == 0 )  THEN
132                PRINT*, '+++ local_stop:'
133                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
134                     '" terminated'
135                PRINT*, '    with stop_dt = .T.'
136             ENDIF
137             stop_dt = .TRUE.
138
139          CASE ( 3 )
140             IF ( myid == 0 )  THEN
141                PRINT*, '+++ local_stop:'
142                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
143                     '" terminated'
144                PRINT*, '    with terminate_run = .T. (CPU-time limit)'
145             ENDIF
146             terminate_run = .TRUE.
147
148          CASE ( 4 )
149             IF ( myid == 0 )  THEN
150                PRINT*, '+++ local_stop:'
151                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
152                     '" terminated'
153                PRINT*, '    with terminate_run = .T. (restart)'
154             ENDIF
155             terminate_run = .TRUE.
156             time_restart = time_restart + dt_restart
157
158          CASE ( 5 )
159             IF ( myid == 0 )  THEN
160                PRINT*, '+++ local_stop:'
161                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
162                     '" terminated'
163                PRINT*, '    with terminate_run = .T. (single restart)'
164             ENDIF
165             terminate_run = .TRUE.
[1353]166             time_restart = 9999999.9_wp
[108]167
168       END SELECT
169
170    ENDIF
171
172#else
173
[1]174    STOP
175
[108]176#endif
177
[1]178 END SUBROUTINE local_stop   
Note: See TracBrowser for help on using the repository browser.