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

Last change on this file since 1320 was 1320, checked in by raasch, 7 years ago

ONLY-attribute added to USE-statements,
kind-parameters added to all INTEGER and REAL declaration statements,
kinds are defined in new module kinds,
old module precision_kind is removed,
revision history before 2012 removed,
comment fields (!:) to be used for variable explanations added to all variable declaration statements

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