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

Last change on this file since 3151 was 2718, checked in by maronga, 7 years ago

deleting of deprecated files; headers updated where needed

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