From 6bb7aa267a45774ebaf172372a0d083c9defdccc Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 3 Sep 2020 11:02:59 +0200 Subject: [PATCH 1/3] Fix some of #8249 --- src/EnergyPlus/IOFiles.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/IOFiles.cc b/src/EnergyPlus/IOFiles.cc index a62f18859a7..8b65230b578 100644 --- a/src/EnergyPlus/IOFiles.cc +++ b/src/EnergyPlus/IOFiles.cc @@ -286,7 +286,7 @@ std::vector InputOutputFile::getLines() void IOFiles::OutputControl::getInput() { - auto const instances = inputProcessor->epJSON.find("Output:Control"); + auto const instances = inputProcessor->epJSON.find("OutputControl:Files"); if (instances != inputProcessor->epJSON.end()) { auto find_input = [](nlohmann::json const & fields, std::string const & field_name) -> std::string { @@ -296,7 +296,7 @@ void IOFiles::OutputControl::getInput() input = found.value().get(); input = UtilityRoutines::MakeUPPERCase(input); } else { - inputProcessor->getDefaultValue("Output:Control", field_name, input); + inputProcessor->getDefaultValue("OutputControl:Files", field_name, input); } return input; }; @@ -400,13 +400,13 @@ void IOFiles::OutputControl::getInput() extshd = boolean_choice(find_input(fields, "output_extshd")); } { // "json" - json = boolean_choice(find_input(fields, "json")); + json = boolean_choice(find_input(fields, "output_json")); } { // "tabular" - tabular = boolean_choice(find_input(fields, "tabular")); + tabular = boolean_choice(find_input(fields, "output_tabular")); } { // "sqlite" - sqlite = boolean_choice(find_input(fields, "sqlite")); + sqlite = boolean_choice(find_input(fields, "output_sqlite")); } } } From 70377e364ca592a02f14a40821cd16971f5f9ab4 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 3 Sep 2020 11:20:22 +0200 Subject: [PATCH 2/3] #8249 - Support OutputControl:Files choice for output of END file. --- src/EnergyPlus/UtilityRoutines.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 100a6e9a72f..67a0ba4ffb2 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -761,7 +761,7 @@ namespace UtilityRoutines { " Severe Errors; Elapsed Time=" + Elapsed); DisplayString("EnergyPlus Run Time=" + Elapsed); - { + if (state.files.outputControl.end) { auto tempfl = state.files.endFile.try_open(state.files.outputControl.end); if (!tempfl.good()) { @@ -948,7 +948,7 @@ namespace UtilityRoutines { ShowMessage("EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed); DisplayString("EnergyPlus Run Time=" + Elapsed); - { + if (ioFiles.outputControl.end) { auto tempfl = ioFiles.endFile.try_open(ioFiles.outputControl.end); if (!tempfl.good()) { DisplayString("EndEnergyPlus: Could not open file " + tempfl.fileName + " for output (write)."); From 9dfd00ca3c03f1c6d141601ae1f2c25290dd1981 Mon Sep 17 00:00:00 2001 From: Mark Adams Date: Tue, 8 Sep 2020 16:23:49 -0400 Subject: [PATCH 3/3] Additional fixes for try_open --- src/EnergyPlus/IOFiles.cc | 4 ++-- src/EnergyPlus/IOFiles.hh | 4 ++-- src/EnergyPlus/UtilityRoutines.cc | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/IOFiles.cc b/src/EnergyPlus/IOFiles.cc index 8b65230b578..bddb33b4545 100644 --- a/src/EnergyPlus/IOFiles.cc +++ b/src/EnergyPlus/IOFiles.cc @@ -62,7 +62,7 @@ namespace EnergyPlus { InputFile &InputFile::ensure_open(const std::string &caller, bool output_to_file) { if (!good()) { - open(output_to_file); + open(false, output_to_file); } if (!good()) { ShowFatalError(fmt::format("{}: Could not open file {} for input (read).", caller, fileName)); @@ -107,7 +107,7 @@ std::ostream::pos_type InputFile::position() const noexcept return is->tellg(); } -void InputFile::open(bool) +void InputFile::open(bool, bool) { is = std::unique_ptr(new std::fstream(fileName.c_str(), std::ios_base::in | std::ios_base::binary)); is->imbue(std::locale("C")); diff --git a/src/EnergyPlus/IOFiles.hh b/src/EnergyPlus/IOFiles.hh index 9d784cd1c13..e6f15ea3cd6 100644 --- a/src/EnergyPlus/IOFiles.hh +++ b/src/EnergyPlus/IOFiles.hh @@ -97,7 +97,7 @@ public: std::istream::iostate rdstate() const noexcept; std::string fileName; - void open(bool = true); + void open(bool = false, bool = true); std::fstream::pos_type position() const noexcept; void rewind() noexcept { if (is) { is->seekg(0); } } @@ -165,7 +165,7 @@ template struct IOFileName FileType try_open(bool output_to_file = true) { FileType file{fileName}; - file.open(output_to_file); + file.open(false, output_to_file); return file; } }; diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index 67a0ba4ffb2..100a6e9a72f 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -761,7 +761,7 @@ namespace UtilityRoutines { " Severe Errors; Elapsed Time=" + Elapsed); DisplayString("EnergyPlus Run Time=" + Elapsed); - if (state.files.outputControl.end) { + { auto tempfl = state.files.endFile.try_open(state.files.outputControl.end); if (!tempfl.good()) { @@ -948,7 +948,7 @@ namespace UtilityRoutines { ShowMessage("EnergyPlus Completed Successfully-- " + NumWarnings + " Warning; " + NumSevere + " Severe Errors; Elapsed Time=" + Elapsed); DisplayString("EnergyPlus Run Time=" + Elapsed); - if (ioFiles.outputControl.end) { + { auto tempfl = ioFiles.endFile.try_open(ioFiles.outputControl.end); if (!tempfl.good()) { DisplayString("EndEnergyPlus: Could not open file " + tempfl.fileName + " for output (write).");