Reputation: 2752
I'm using MPI, and at some points want to use STOP (or another method), to exit the program with an error message.
Right now, I'm doing something like this:
STOP 'Error'
But I have a feeling I'm doing something wrong. Do I need to call MPI_FINALIZE first? Is there something else to be doing?
Upvotes: 8
Views: 7210
Reputation: 1334
Testing this on NERSC supercomupters, I found that
call MPI_FINALIZE(ierr)
stop
can not stop the whole program. The following works:
call MPI_Abort(MPI_COMM_WORLD, errcode, ierr)
stop
Upvotes: 2
Reputation: 50937
In a catastrophic error condition, the usual way to exit is call MPI_Abort(MPI_COMM_WORLD, errcode, ierr)
. In most implementations, this will kill all tasks. In less drastic situations you could make sure all the tasks know of the condition and then have them all excit more gracefully with an MPI_Finalize
.
Upvotes: 12
Reputation: 8273
Take a look at MPI_Abort:
The behavior of MPI_ABORT (comm, errorcode),for comm other then MPI_COMM_WORLD, is implementation-dependent. One the other hand, a call to MPI_ABORT(MPI_COMM_WORLD, errorcode) should always cause all processes in the group of MPI_COMM_WORLD to abort.
Upvotes: 6