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

Last change on this file since 4180 was 4180, checked in by scharf, 5 years ago

removed comments in 'Former revisions' section that are older than 01.01.2019

  • Property svn:keywords set to Id
File size: 5.3 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!
[3655]17! Copyright 1997-2019 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 4180 2019-08-21 14:37:54Z scharf $
[3250]27! Added an empty output string to stop keywords to clean up job protocol
28!
[2716]29!
[1]30! Description:
31! ------------
[1682]32!> Stop program execution
[3]33!------------------------------------------------------------------------------!
[1682]34 SUBROUTINE local_stop
35 
[1]36
[1320]37    USE control_parameters,                                                    &
38        ONLY:  abort_mode, coupling_mode, coupling_mode_remote, dt_restart,    &
39               stop_dt, terminate_coupled, terminate_coupled_remote,           &
40               terminate_run, time_restart
[1]41
[1764]42    USE pegrid
[206]43
[1764]44    USE pmc_interface,                                                         &
45        ONLY:  nested_run
46
[2365]47
[1804]48#if defined( __parallel )
[108]49    IF ( coupling_mode == 'uncoupled' )  THEN
[1764]50       IF ( nested_run )  THEN
51!
52!--       Workaround: If any of the nested model crashes, it aborts the whole
53!--       run with MPI_ABORT, regardless of the reason given by abort_mode
54          CALL MPI_ABORT( MPI_COMM_WORLD, 9999, ierr )
55       ELSE
56          IF ( abort_mode == 1 )  THEN
57             CALL MPI_FINALIZE( ierr )
[3312]58             STOP 1
[1764]59          ELSEIF ( abort_mode == 2 )  THEN
60             CALL MPI_ABORT( comm2d, 9999, ierr )
61          ELSEIF ( abort_mode == 3 )  THEN
62             CALL MPI_ABORT( MPI_COMM_WORLD, 9999, ierr )
63          ENDIF
[213]64       ENDIF
[2365]65    ELSEIF ( coupling_mode(1:8) == 'vnested_' )  THEN
66
67       PRINT*, '+++ local_stop:'
68       PRINT*, '     model "', TRIM( coupling_mode ), '" terminated'
69!
70!--    Abort both coarse and fine grid
71       CALL MPI_ABORT( MPI_COMM_WORLD, 9999, ierr )
[108]72    ELSE
[1]73
[108]74       SELECT CASE ( terminate_coupled_remote )
75
76          CASE ( 0 )
77             IF ( myid == 0 )  THEN
78                PRINT*, '+++ local_stop:'
79                PRINT*, '    local model "', TRIM( coupling_mode ), &
80                     '" stops now'
81             ENDIF
82!
83!--          Inform the remote model of the termination and its reason, provided
84!--          the remote model has not already been informed of another
85!--          termination reason (terminate_coupled > 0) before.
86             IF ( terminate_coupled == 0 )  THEN
87                terminate_coupled = 1
[667]88                IF ( myid == 0 ) THEN
89                   CALL MPI_SENDRECV( &
90                        terminate_coupled,        1, MPI_INTEGER, target_id,  0, &
91                        terminate_coupled_remote, 1, MPI_INTEGER, target_id,  0, &
92                        comm_inter, status, ierr )
93                ENDIF
94                CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_REAL, 0, comm2d, ierr)
[108]95             ENDIF
96             CALL MPI_FINALIZE( ierr )
[3312]97             STOP 1
[108]98
99          CASE ( 1 )
100             IF ( myid == 0 )  THEN
101                PRINT*, '+++ local_stop:'
102                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
103                     '" stopped'
104             ENDIF
105             CALL MPI_FINALIZE( ierr )
[3312]106             STOP 1
[108]107
108          CASE ( 2 )
109             IF ( myid == 0 )  THEN
110                PRINT*, '+++ local_stop:'
111                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
112                     '" terminated'
113                PRINT*, '    with stop_dt = .T.'
114             ENDIF
115             stop_dt = .TRUE.
116
117          CASE ( 3 )
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. (CPU-time limit)'
123             ENDIF
124             terminate_run = .TRUE.
125
126          CASE ( 4 )
127             IF ( myid == 0 )  THEN
128                PRINT*, '+++ local_stop:'
129                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
130                     '" terminated'
131                PRINT*, '    with terminate_run = .T. (restart)'
132             ENDIF
133             terminate_run = .TRUE.
134             time_restart = time_restart + dt_restart
135
136          CASE ( 5 )
137             IF ( myid == 0 )  THEN
138                PRINT*, '+++ local_stop:'
139                PRINT*, '    remote model "', TRIM( coupling_mode_remote ), &
140                     '" terminated'
141                PRINT*, '    with terminate_run = .T. (single restart)'
142             ENDIF
143             terminate_run = .TRUE.
[1353]144             time_restart = 9999999.9_wp
[108]145
146       END SELECT
147
148    ENDIF
149
150#else
151
[3312]152    STOP 1
[1]153
[108]154#endif
155
[1]156 END SUBROUTINE local_stop   
Note: See TracBrowser for help on using the repository browser.