From 42a76e3da675f34415a6286af4e7eac66516a54f Mon Sep 17 00:00:00 2001 From: Robert Kloefkorn Date: Mon, 9 May 2016 16:58:07 +0200 Subject: [PATCH] SimulatorFullyImplicitBlackoilOutput: use HAVE_PTHREAD to enable async_output by default. --- .../SimulatorFullyImplicitBlackoilOutput.hpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) 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() ) {