fixed: handle exceptions in I/O in parallel

properly exit on all processes, instead of deadlocking.
async output will still deadlock as there is no way to handle this
without syncronization which would defeat the purpose of async.
This commit is contained in:
Arne Morten Kvarving 2017-02-06 14:17:59 +01:00
parent c9813886ba
commit b5b42faba4
2 changed files with 42 additions and 2 deletions

View File

@ -288,6 +288,8 @@ namespace Opm
const WellStateFullyImplicitBlackoil& wellState = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalWellState() : localWellState;
// serial output is only done on I/O rank
int err = 0;
std::string emsg;
if( isIORank )
{
if( asyncOutput_ ) {
@ -296,7 +298,25 @@ namespace Opm
}
else {
// just write the data to disk
writeTimeStepSerial( timer, state, wellState, cellData, substep );
try {
writeTimeStepSerial( timer, state, wellState, cellData, substep );
} catch (std::runtime_error& msg) {
err = 1;
emsg = msg.what();
}
}
}
if (!asyncOutput_) {
#if HAVE_MPI
MPI_Bcast(&err, 1, MPI_INT, 0, MPI_COMM_WORLD);
#endif
if (err) {
if (isIORank) {
throw std::runtime_error(emsg);
} else {
throw std::runtime_error("I/O process encountered problems.");
}
}
}
}

View File

@ -132,6 +132,8 @@ namespace Opm
const WellStateFullyImplicitBlackoil& wellState = (parallelOutput_ && parallelOutput_->isParallel() ) ? parallelOutput_->globalWellState() : localWellState;
// serial output is only done on I/O rank
int err = 0;
std::string emsg;
if( isIORank )
{
if( asyncOutput_ ) {
@ -140,7 +142,25 @@ namespace Opm
}
else {
// just write the data to disk
writeTimeStepSerial( timer, state, wellState, sol, substep );
try {
writeTimeStepSerial( timer, state, wellState, sol, substep );
} catch (std::runtime_error& msg) {
err = 1;
emsg = msg.what();
}
}
}
if (!asyncOutput_) {
#if HAVE_MPI
MPI_Bcast(&err, 1, MPI_INT, 0, MPI_COMM_WORLD);
#endif
if (err) {
if (isIORank) {
throw std::runtime_error(emsg);
} else {
throw std::runtime_error("I/O process encountered problems.");
}
}
}
}