diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index 5ad844bb4..529317109 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -302,12 +302,6 @@ namespace Opm eclipseState_(eclipseState), asyncOutput_() { - // create output thread if needed - if( output_ && param.getDefault("async_output", bool( false ) ) ) - { - asyncOutput_.reset( new ThreadHandle() ); - } - // For output. if (output_ && parallelOutput_->isIORank() ) { // Ensure that output dir exists @@ -319,6 +313,22 @@ namespace Opm OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath); } + // create output thread if enabled and rank is I/O rank + // async output is enabled by default if pthread are enabled +#if HAVE_PTHREAD + const bool asyncOutputDefault = true; +#else + const bool asyncOutputDefault = false; +#endif + if( param.getDefault("async_output", asyncOutputDefault ) ) + { +#if HAVE_PTHREAD + asyncOutput_.reset( new ThreadHandle() ); +#else + OPM_THROW(std::runtime_error,"Pthreads were not found, cannot enable async_output"); +#endif + } + std::string backupfilename = param.getDefault("backupfile", std::string("") ); if( ! backupfilename.empty() ) {