From 4eda4d9ff6993ac18c311480d8e55d87975fb929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 16 Mar 2017 15:40:24 +0100 Subject: [PATCH 1/4] Remove unused code and simplify. - The output_interval_ member is no longer used (here). - After setup, the IOConfig contains the output dir, use it. --- opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index 4ac61c002..14c16ee26 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -310,7 +310,6 @@ namespace Opm // Parameters for output. const std::string outputDir_; - const int output_interval_; const bool restart_double_si_; int lastBackupReportStep_; @@ -341,8 +340,7 @@ namespace Opm const Opm::PhaseUsage &phaseUsage) : output_( param.getDefault("output", true) ), parallelOutput_( output_ ? new ParallelDebugOutput< Grid >( grid, eclipseState, phaseUsage.num_phases, phaseUsage ) : 0 ), - outputDir_( output_ ? param.getDefault("output_dir", std::string("output")) : "." ), - output_interval_( output_ ? param.getDefault("output_interval", 1): 0 ), + outputDir_( eclipseState.getIOConfig().getOutputDir() ), restart_double_si_( output_ ? param.getDefault("restart_double_si", false) : false ), lastBackupReportStep_( -1 ), phaseUsage_( phaseUsage ), From 4ea87b31b2b9e8c623846405458567fe7f6d3c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 16 Mar 2017 15:43:46 +0100 Subject: [PATCH 2/4] Change output dir default. With this the default output dir is the location of the deck file (as stored in the IOConfig), rather than the current working directory. --- opm/autodiff/FlowMain.hpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/opm/autodiff/FlowMain.hpp b/opm/autodiff/FlowMain.hpp index c43a21424..a71bf6d73 100644 --- a/opm/autodiff/FlowMain.hpp +++ b/opm/autodiff/FlowMain.hpp @@ -145,8 +145,8 @@ namespace Opm if (!ok) { return EXIT_FAILURE; } - asImpl().setupOutput(); asImpl().readDeckInput(); + asImpl().setupOutput(); asImpl().setupLogging(); asImpl().extractMessages(); asImpl().setupGridAndProps(); @@ -365,14 +365,17 @@ namespace Opm // Throws std::runtime_error if failed to create (if requested) output dir. void setupOutput() { - // Write parameters used for later reference. (only if rank is zero) output_to_files_ = output_cout_ && param_.getDefault("output", true); - // Always read output_dir as it will be set unconditionally later. - // Not doing this might cause files to be created in the current - // directory. - output_dir_ = - param_.getDefault("output_dir", std::string(".")); + // Setup output directory. + auto& ioConfig = eclipse_state_->getIOConfig(); + // Default output directory is the directory where the deck is found. + const std::string default_output_dir = ioConfig.getOutputDir(); + output_dir_ = param_.getDefault("output_dir", default_output_dir); + // Override output directory if user specified. + ioConfig.setOutputDir(output_dir_); + + // Write parameters used for later reference. (only if rank is zero) if (output_to_files_) { // Create output directory if needed. boost::filesystem::path fpath(output_dir_); @@ -409,13 +412,9 @@ namespace Opm } else { baseName = path(fpath.filename()).string(); } - if (param_.has("output_dir")) { - logFileStream << output_dir_ << "/"; - debugFileStream << output_dir_ + "/"; - } - logFileStream << baseName; - debugFileStream << "." << baseName; + logFileStream << output_dir_ << "/" << baseName; + debugFileStream << output_dir_ << "/" << "." << baseName; if ( must_distribute_ && mpi_rank_ != 0 ) { @@ -511,8 +510,6 @@ namespace Opm } eclipse_state_.reset(new EclipseState(*deck_, parseContext)); - auto& ioConfig = eclipse_state_->getIOConfig(); - ioConfig.setOutputDir(output_dir_); } catch (const std::invalid_argument& e) { std::cerr << "Failed to create valid EclipseState object. See logfile: " << logFile_ << std::endl; From 059367e14df5fb9e8a8df768e373c4c358817208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 16 Mar 2017 16:05:33 +0100 Subject: [PATCH 3/4] Change default output dir for flow_ebos. --- opm/autodiff/FlowMainEbos.hpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/opm/autodiff/FlowMainEbos.hpp b/opm/autodiff/FlowMainEbos.hpp index b681cc573..05445a193 100644 --- a/opm/autodiff/FlowMainEbos.hpp +++ b/opm/autodiff/FlowMainEbos.hpp @@ -87,8 +87,8 @@ namespace Opm return EXIT_FAILURE; } - setupOutput(); setupEbosSimulator(); + setupOutput(); setupLogging(); extractMessages(); setupGridAndProps(); @@ -225,14 +225,17 @@ namespace Opm // Throws std::runtime_error if failed to create (if requested) output dir. void setupOutput() { - // Write parameters used for later reference. (only if rank is zero) output_to_files_ = output_cout_ && param_.getDefault("output", true); - // Always read output_dir as it will be set unconditionally later. - // Not doing this might cause files to be created in the current - // directory. - output_dir_ = - param_.getDefault("output_dir", std::string(".")); + // Setup output directory. + auto& ioConfig = eclState().getIOConfig(); + // Default output directory is the directory where the deck is found. + const std::string default_output_dir = ioConfig.getOutputDir(); + output_dir_ = param_.getDefault("output_dir", default_output_dir); + // Override output directory if user specified. + ioConfig.setOutputDir(output_dir_); + + // Write parameters used for later reference. (only if rank is zero) if (output_to_files_) { // Create output directory if needed. boost::filesystem::path fpath(output_dir_); @@ -265,13 +268,9 @@ namespace Opm } else { baseName = path(fpath.filename()).string(); } - if (param_.has("output_dir")) { - logFileStream << output_dir_ << "/"; - debugFileStream << output_dir_ + "/"; - } - logFileStream << baseName; - debugFileStream << "." << baseName; + logFileStream << output_dir_ << "/" << baseName; + debugFileStream << output_dir_ << "/" << "." << baseName; if ( must_distribute_ && mpi_rank_ != 0 ) { @@ -354,12 +353,10 @@ namespace Opm MissingFeatures::checkKeywords(deck()); } - IOConfig& ioConfig = eclState().getIOConfig(); - ioConfig.setOutputDir(output_dir_); - // Possible to force initialization only behavior (NOSIM). if (param_.has("nosim")) { const bool nosim = param_.get("nosim"); + auto& ioConfig = eclState().getIOConfig(); ioConfig.overrideNOSIM( nosim ); } } From a89af9c92f563af3b18185e28a01dcb5bd5f2868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 16 Mar 2017 17:18:14 +0100 Subject: [PATCH 4/4] Updated output_dir in test driver scripts/ --- tests/run-init-regressionTest.sh | 2 +- tests/run-parallel-regressionTest.sh | 4 ++-- tests/run-regressionTest.sh | 2 +- tests/run-restart-regressionTest.sh | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/run-init-regressionTest.sh b/tests/run-init-regressionTest.sh index c68e90189..e1fe25807 100755 --- a/tests/run-init-regressionTest.sh +++ b/tests/run-init-regressionTest.sh @@ -21,7 +21,7 @@ TEST_ARGS="$@" rm -Rf ${RESULT_PATH} mkdir -p ${RESULT_PATH} cd ${RESULT_PATH} -${BINPATH}/${EXE_NAME} ${TEST_ARGS} nosim=true +${BINPATH}/${EXE_NAME} ${TEST_ARGS} nosim=true output_dir=${RESULT_PATH} cd .. ecode=0 diff --git a/tests/run-parallel-regressionTest.sh b/tests/run-parallel-regressionTest.sh index 1c149b6ca..051ced320 100755 --- a/tests/run-parallel-regressionTest.sh +++ b/tests/run-parallel-regressionTest.sh @@ -19,11 +19,11 @@ TEST_ARGS="$@" rm -Rf ${RESULT_PATH} mkdir -p ${RESULT_PATH} cd ${RESULT_PATH} -${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 +${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 output_dir=${RESULT_PATH} test $? -eq 0 || exit 1 mkdir mpi cd mpi -mpirun -np 4 ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 +mpirun -np 4 ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 output_dir=${RESULT_PATH}/mpi test $? -eq 0 || exit 1 cd .. diff --git a/tests/run-regressionTest.sh b/tests/run-regressionTest.sh index f6a808f6b..16565a590 100755 --- a/tests/run-regressionTest.sh +++ b/tests/run-regressionTest.sh @@ -18,7 +18,7 @@ TEST_ARGS="$@" rm -Rf ${RESULT_PATH} mkdir -p ${RESULT_PATH} cd ${RESULT_PATH} -${BINPATH}/${EXE_NAME} ${TEST_ARGS} +${BINPATH}/${EXE_NAME} ${TEST_ARGS} output_dir=${RESULT_PATH} cd .. ecode=0 diff --git a/tests/run-restart-regressionTest.sh b/tests/run-restart-regressionTest.sh index f5e9bb28a..da87be72e 100755 --- a/tests/run-restart-regressionTest.sh +++ b/tests/run-restart-regressionTest.sh @@ -19,9 +19,9 @@ TEST_ARGS="$@" rm -Rf ${RESULT_PATH} mkdir -p ${RESULT_PATH} cd ${RESULT_PATH} -${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA timestep.adaptive=false +${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA timestep.adaptive=false output_dir=${RESULT_PATH} test $? -eq 0 || exit 1 -${BINPATH}/${EXE_NAME} ${TEST_ARGS}_RESTART.DATA timestep.adaptive=false +${BINPATH}/${EXE_NAME} ${TEST_ARGS}_RESTART.DATA timestep.adaptive=false output_dir=${RESULT_PATH} test $? -eq 0 || exit 1 ecode=0