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

Last change on this file since 2365 was 2365, checked in by kanani, 4 years ago

Vertical nesting implemented (SadiqHuq?)

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