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