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

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

Code annotations made doxygen readable

  • Property svn:keywords set to Id
File size: 5.1 KB
RevLine 
[1682]1!> @file local_stop.f90
[1036]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!
[1310]16! Copyright 1997-2014 Leibniz Universitaet Hannover
[1036]17!--------------------------------------------------------------------------------!
18!
[484]19! Current revisions:
[1]20! -----------------
[1682]21! Code annotations made doxygen readable
[1354]22!
[1]23! Former revisions:
24! -----------------
[3]25! $Id: local_stop.f90 1682 2015-10-07 23:56:08Z knoop $
[110]26!
[1354]27! 1353 2014-04-08 15:21:23Z heinze
28! REAL constants provided with KIND-attribute
29!
[1321]30! 1320 2014-03-20 08:40:49Z raasch
31! ONLY-attribute added to USE-statements,
32! revision history before 2012 removed
33!
[1037]34! 1036 2012-10-22 13:43:42Z raasch
35! code put under GPL (PALM 3.9)
36!
[810]37! 809 2012-01-30 13:32:58Z maronga
38! Bugfix: replaced .AND. and .NOT. with && and ! in the preprocessor directives
39!
[808]40! 807 2012-01-25 11:53:51Z maronga
41! New cpp directive "__check" implemented which is used by check_namelist_files
42!
[1]43! Revision 1.1  2002/12/19 15:46:23  raasch
44! Initial revision
45!
46!
47! Description:
48! ------------
[1682]49!> Stop program execution
[3]50!------------------------------------------------------------------------------!
[1682]51 SUBROUTINE local_stop
52 
[1]53
54    USE pegrid
[1320]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
[1]60
[206]61
[809]62#if defined( __parallel ) && ! defined ( __check )
[108]63    IF ( coupling_mode == 'uncoupled' )  THEN
[213]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
[108]70    ELSE
[1]71
[108]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
[667]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)
[108]93             ENDIF
94             CALL MPI_FINALIZE( ierr )
[147]95             STOP
[108]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 )
[147]104             STOP
[108]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.
[1353]142             time_restart = 9999999.9_wp
[108]143
144       END SELECT
145
146    ENDIF
147
148#else
149
[1]150    STOP
151
[108]152#endif
153
[1]154 END SUBROUTINE local_stop   
Note: See TracBrowser for help on using the repository browser.