From c5219a55c5f126bd1e8d6e760fc5b3ddd96a9418 Mon Sep 17 00:00:00 2001 From: Kyle Benne Date: Tue, 31 Oct 2023 13:49:00 -0500 Subject: [PATCH] Update Runner::lastEPWFile before every Measure. ref #5009 --- src/workflow/ApplyMeasure.cpp | 5 ++--- src/workflow/OSWorkflow.cpp | 11 +++++++---- src/workflow/OSWorkflow.hpp | 2 +- src/workflow/RunTranslator.cpp | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/workflow/ApplyMeasure.cpp b/src/workflow/ApplyMeasure.cpp index 54c56415650..d15886bdf19 100644 --- a/src/workflow/ApplyMeasure.cpp +++ b/src/workflow/ApplyMeasure.cpp @@ -60,9 +60,8 @@ void OSWorkflow::applyMeasures(MeasureType measureType, bool energyplus_output_r if (!sqlPath.empty()) { runner.setLastEnergyPlusSqlFilePath(sqlPath); } - if (!epwPath.empty()) { - runner.setLastEpwFilePath(epwPath); - } + + updateLastWeatherFileFromModel(); const auto measureDirName = step.measureDirName(); if (openstudio::filesystem::path(measureDirName).is_absolute()) { diff --git a/src/workflow/OSWorkflow.cpp b/src/workflow/OSWorkflow.cpp index 6a7cc4b7b97..5fbfebde22b 100644 --- a/src/workflow/OSWorkflow.cpp +++ b/src/workflow/OSWorkflow.cpp @@ -117,16 +117,17 @@ void OSWorkflow::initializeWeatherFileFromOSW() { if (auto epwFile_ = openstudio::EpwFile::load(epwPath)) { model::WeatherFile::setWeatherFile(model, epwFile_.get()); + runner.setLastEpwFilePath(epwPath); } else { LOG(Warn, "Could not load weather file from " << epwPath_.get()); } } else { - LOG(Debug, "No weather file defined by osw"); + LOG(Debug, "Weather file is not defined by the osw"); } } -void OSWorkflow::applyWeatherFileFromModel() { - LOG(Debug, "Apply the final weather file"); +void OSWorkflow::updateLastWeatherFileFromModel() { + LOG(Debug, "Find model's weather file and update LastEpwFilePath"); if (auto epwFile_ = model.weatherFile()) { if (auto epwPath_ = epwFile_->path()) { LOG(Debug, "Search for weather file " << epwPath_.get()); @@ -139,11 +140,13 @@ void OSWorkflow::applyWeatherFileFromModel() { } epwPath = epwFullPath_.get(); + runner.setLastEpwFilePath(epwPath); + return; } } - LOG(Warn, "Weather file is not defined"); + LOG(Debug, "Weather file is not defined by the model"); } void OSWorkflow::applyArguments(measure::OSArgumentMap& argumentMap, const std::string& argumentName, const openstudio::Variant& argumentValue) { diff --git a/src/workflow/OSWorkflow.hpp b/src/workflow/OSWorkflow.hpp index 73f3ad1c693..e7b608f479f 100644 --- a/src/workflow/OSWorkflow.hpp +++ b/src/workflow/OSWorkflow.hpp @@ -117,7 +117,7 @@ class OSWorkflow //@} void initializeWeatherFileFromOSW(); - void applyWeatherFileFromModel(); + void updateLastWeatherFileFromModel(); void applyMeasures(MeasureType measureType, bool energyplus_output_requests = false); static void applyArguments(measure::OSArgumentMap& argumentMap, const std::string& argumentName, const openstudio::Variant& argumentValue); void saveOSMToRootDirIfDebug(); diff --git a/src/workflow/RunTranslator.cpp b/src/workflow/RunTranslator.cpp index 91484dbb84c..9fd9b97036a 100644 --- a/src/workflow/RunTranslator.cpp +++ b/src/workflow/RunTranslator.cpp @@ -38,7 +38,7 @@ void OSWorkflow::runTranslator() { auto runDir = workflowJSON.absoluteRunDir(); OS_ASSERT(openstudio::filesystem::is_directory(runDir)); - applyWeatherFileFromModel(); + updateLastWeatherFileFromModel(); // Copy in the weather file if (!epwPath.empty()) {