1 | SUBROUTINE local_stop |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Current revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: local_stop.f90 484 2010-02-05 07:36:54Z maronga $ |
---|
11 | ! |
---|
12 | ! 213 2008-11-13 10:26:18Z raasch |
---|
13 | ! Implementation of a MPI-1 coupling: replaced myid with target_id. |
---|
14 | ! The uncoupled case allows stop or mpi_abort depending on new steering |
---|
15 | ! parameter abort_mode, which is set in routine message. |
---|
16 | ! |
---|
17 | ! 147 2008-02-01 12:41:46Z raasch |
---|
18 | ! Bugfix: a stop command was missing in some cases of the parallel branch |
---|
19 | ! |
---|
20 | ! 108 2007-08-24 15:10:38Z letzel |
---|
21 | ! modifications to terminate coupled runs |
---|
22 | ! |
---|
23 | ! RCS Log replace by Id keyword, revision history cleaned up |
---|
24 | ! |
---|
25 | ! Revision 1.2 2003/03/16 09:40:28 raasch |
---|
26 | ! Two underscores (_) are placed in front of all define-strings |
---|
27 | ! |
---|
28 | ! Revision 1.1 2002/12/19 15:46:23 raasch |
---|
29 | ! Initial revision |
---|
30 | ! |
---|
31 | ! |
---|
32 | ! Description: |
---|
33 | ! ------------ |
---|
34 | ! Stop program execution |
---|
35 | !------------------------------------------------------------------------------! |
---|
36 | |
---|
37 | USE pegrid |
---|
38 | USE control_parameters |
---|
39 | |
---|
40 | |
---|
41 | #if defined( __parallel ) |
---|
42 | IF ( coupling_mode == 'uncoupled' ) THEN |
---|
43 | IF ( abort_mode == 1 ) THEN |
---|
44 | CALL MPI_FINALIZE( ierr ) |
---|
45 | STOP |
---|
46 | ELSEIF ( abort_mode == 2 ) THEN |
---|
47 | CALL MPI_ABORT( comm2d, 9999, ierr ) |
---|
48 | ENDIF |
---|
49 | ELSE |
---|
50 | |
---|
51 | SELECT CASE ( terminate_coupled_remote ) |
---|
52 | |
---|
53 | CASE ( 0 ) |
---|
54 | IF ( myid == 0 ) THEN |
---|
55 | PRINT*, '+++ local_stop:' |
---|
56 | PRINT*, ' local model "', TRIM( coupling_mode ), & |
---|
57 | '" stops now' |
---|
58 | ENDIF |
---|
59 | ! |
---|
60 | !-- Inform the remote model of the termination and its reason, provided |
---|
61 | !-- the remote model has not already been informed of another |
---|
62 | !-- termination reason (terminate_coupled > 0) before. |
---|
63 | IF ( terminate_coupled == 0 ) THEN |
---|
64 | terminate_coupled = 1 |
---|
65 | CALL MPI_SENDRECV( & |
---|
66 | terminate_coupled, 1, MPI_INTEGER, target_id, 0, & |
---|
67 | terminate_coupled_remote, 1, MPI_INTEGER, target_id, 0, & |
---|
68 | comm_inter, status, ierr ) |
---|
69 | ENDIF |
---|
70 | CALL MPI_FINALIZE( ierr ) |
---|
71 | STOP |
---|
72 | |
---|
73 | CASE ( 1 ) |
---|
74 | IF ( myid == 0 ) THEN |
---|
75 | PRINT*, '+++ local_stop:' |
---|
76 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
77 | '" stopped' |
---|
78 | ENDIF |
---|
79 | CALL MPI_FINALIZE( ierr ) |
---|
80 | STOP |
---|
81 | |
---|
82 | CASE ( 2 ) |
---|
83 | IF ( myid == 0 ) THEN |
---|
84 | PRINT*, '+++ local_stop:' |
---|
85 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
86 | '" terminated' |
---|
87 | PRINT*, ' with stop_dt = .T.' |
---|
88 | ENDIF |
---|
89 | stop_dt = .TRUE. |
---|
90 | |
---|
91 | CASE ( 3 ) |
---|
92 | IF ( myid == 0 ) THEN |
---|
93 | PRINT*, '+++ local_stop:' |
---|
94 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
95 | '" terminated' |
---|
96 | PRINT*, ' with terminate_run = .T. (CPU-time limit)' |
---|
97 | ENDIF |
---|
98 | terminate_run = .TRUE. |
---|
99 | |
---|
100 | CASE ( 4 ) |
---|
101 | IF ( myid == 0 ) THEN |
---|
102 | PRINT*, '+++ local_stop:' |
---|
103 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
104 | '" terminated' |
---|
105 | PRINT*, ' with terminate_run = .T. (restart)' |
---|
106 | ENDIF |
---|
107 | terminate_run = .TRUE. |
---|
108 | time_restart = time_restart + dt_restart |
---|
109 | |
---|
110 | CASE ( 5 ) |
---|
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. (single restart)' |
---|
116 | ENDIF |
---|
117 | terminate_run = .TRUE. |
---|
118 | time_restart = 9999999.9 |
---|
119 | |
---|
120 | END SELECT |
---|
121 | |
---|
122 | ENDIF |
---|
123 | |
---|
124 | #else |
---|
125 | |
---|
126 | STOP |
---|
127 | |
---|
128 | #endif |
---|
129 | |
---|
130 | END SUBROUTINE local_stop |
---|