[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 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 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 4564 2020-06-12 14:03:36Z pavelkrc $ |
---|
[4564] | 27 | ! Vertical nesting method of Huq et al. (2019) removed |
---|
| 28 | ! |
---|
| 29 | ! 4444 2020-03-05 15:59:50Z raasch |
---|
[4444] | 30 | ! bugfix: misplaced cpp-directive moved |
---|
| 31 | ! |
---|
| 32 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4182] | 33 | ! Corrected "Former revisions" section |
---|
| 34 | ! |
---|
| 35 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3250] | 36 | ! Added an empty output string to stop keywords to clean up job protocol |
---|
[2716] | 37 | ! |
---|
[4182] | 38 | ! Revision 1.1 2002/12/19 15:46:23 raasch |
---|
| 39 | ! Initial revision |
---|
| 40 | ! |
---|
| 41 | ! |
---|
[1] | 42 | ! Description: |
---|
| 43 | ! ------------ |
---|
[1682] | 44 | !> Stop program execution |
---|
[3] | 45 | !------------------------------------------------------------------------------! |
---|
[1682] | 46 | SUBROUTINE local_stop |
---|
| 47 | |
---|
[4444] | 48 | #if defined( __parallel ) |
---|
[1] | 49 | |
---|
[1320] | 50 | USE control_parameters, & |
---|
| 51 | ONLY: abort_mode, coupling_mode, coupling_mode_remote, dt_restart, & |
---|
| 52 | stop_dt, terminate_coupled, terminate_coupled_remote, & |
---|
| 53 | terminate_run, time_restart |
---|
[1] | 54 | |
---|
[1764] | 55 | USE pegrid |
---|
[206] | 56 | |
---|
[1764] | 57 | USE pmc_interface, & |
---|
| 58 | ONLY: nested_run |
---|
| 59 | |
---|
[2365] | 60 | |
---|
[108] | 61 | IF ( coupling_mode == 'uncoupled' ) THEN |
---|
[4564] | 62 | |
---|
[1764] | 63 | IF ( nested_run ) THEN |
---|
| 64 | ! |
---|
| 65 | !-- Workaround: If any of the nested model crashes, it aborts the whole |
---|
| 66 | !-- run with MPI_ABORT, regardless of the reason given by abort_mode |
---|
| 67 | CALL MPI_ABORT( MPI_COMM_WORLD, 9999, ierr ) |
---|
| 68 | ELSE |
---|
| 69 | IF ( abort_mode == 1 ) THEN |
---|
| 70 | CALL MPI_FINALIZE( ierr ) |
---|
[3312] | 71 | STOP 1 |
---|
[1764] | 72 | ELSEIF ( abort_mode == 2 ) THEN |
---|
| 73 | CALL MPI_ABORT( comm2d, 9999, ierr ) |
---|
| 74 | ELSEIF ( abort_mode == 3 ) THEN |
---|
| 75 | CALL MPI_ABORT( MPI_COMM_WORLD, 9999, ierr ) |
---|
| 76 | ENDIF |
---|
[213] | 77 | ENDIF |
---|
[2365] | 78 | |
---|
[108] | 79 | ELSE |
---|
[1] | 80 | |
---|
[108] | 81 | SELECT CASE ( terminate_coupled_remote ) |
---|
| 82 | |
---|
| 83 | CASE ( 0 ) |
---|
| 84 | IF ( myid == 0 ) THEN |
---|
| 85 | PRINT*, '+++ local_stop:' |
---|
| 86 | PRINT*, ' local model "', TRIM( coupling_mode ), & |
---|
| 87 | '" stops now' |
---|
| 88 | ENDIF |
---|
| 89 | ! |
---|
| 90 | !-- Inform the remote model of the termination and its reason, provided |
---|
| 91 | !-- the remote model has not already been informed of another |
---|
| 92 | !-- termination reason (terminate_coupled > 0) before. |
---|
| 93 | IF ( terminate_coupled == 0 ) THEN |
---|
| 94 | terminate_coupled = 1 |
---|
[667] | 95 | IF ( myid == 0 ) THEN |
---|
| 96 | CALL MPI_SENDRECV( & |
---|
| 97 | terminate_coupled, 1, MPI_INTEGER, target_id, 0, & |
---|
| 98 | terminate_coupled_remote, 1, MPI_INTEGER, target_id, 0, & |
---|
| 99 | comm_inter, status, ierr ) |
---|
| 100 | ENDIF |
---|
| 101 | CALL MPI_BCAST( terminate_coupled_remote, 1, MPI_REAL, 0, comm2d, ierr) |
---|
[108] | 102 | ENDIF |
---|
| 103 | CALL MPI_FINALIZE( ierr ) |
---|
[3312] | 104 | STOP 1 |
---|
[108] | 105 | |
---|
| 106 | CASE ( 1 ) |
---|
| 107 | IF ( myid == 0 ) THEN |
---|
| 108 | PRINT*, '+++ local_stop:' |
---|
| 109 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 110 | '" stopped' |
---|
| 111 | ENDIF |
---|
| 112 | CALL MPI_FINALIZE( ierr ) |
---|
[3312] | 113 | STOP 1 |
---|
[108] | 114 | |
---|
| 115 | CASE ( 2 ) |
---|
| 116 | IF ( myid == 0 ) THEN |
---|
| 117 | PRINT*, '+++ local_stop:' |
---|
| 118 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 119 | '" terminated' |
---|
| 120 | PRINT*, ' with stop_dt = .T.' |
---|
| 121 | ENDIF |
---|
| 122 | stop_dt = .TRUE. |
---|
| 123 | |
---|
| 124 | CASE ( 3 ) |
---|
| 125 | IF ( myid == 0 ) THEN |
---|
| 126 | PRINT*, '+++ local_stop:' |
---|
| 127 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 128 | '" terminated' |
---|
| 129 | PRINT*, ' with terminate_run = .T. (CPU-time limit)' |
---|
| 130 | ENDIF |
---|
| 131 | terminate_run = .TRUE. |
---|
| 132 | |
---|
| 133 | CASE ( 4 ) |
---|
| 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. (restart)' |
---|
| 139 | ENDIF |
---|
| 140 | terminate_run = .TRUE. |
---|
| 141 | time_restart = time_restart + dt_restart |
---|
| 142 | |
---|
| 143 | CASE ( 5 ) |
---|
| 144 | IF ( myid == 0 ) THEN |
---|
| 145 | PRINT*, '+++ local_stop:' |
---|
| 146 | PRINT*, ' remote model "', TRIM( coupling_mode_remote ), & |
---|
| 147 | '" terminated' |
---|
| 148 | PRINT*, ' with terminate_run = .T. (single restart)' |
---|
| 149 | ENDIF |
---|
| 150 | terminate_run = .TRUE. |
---|
[1353] | 151 | time_restart = 9999999.9_wp |
---|
[108] | 152 | |
---|
| 153 | END SELECT |
---|
| 154 | |
---|
| 155 | ENDIF |
---|
| 156 | |
---|
| 157 | #else |
---|
| 158 | |
---|
[3312] | 159 | STOP 1 |
---|
[1] | 160 | |
---|
[108] | 161 | #endif |
---|
| 162 | |
---|
[1] | 163 | END SUBROUTINE local_stop |
---|