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