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