From 1b68101964043dcd7835d44aeaf7626baf7a9e94 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Mon, 5 Apr 2021 16:56:31 -0600 Subject: [PATCH 1/3] add -D to alt build GH actions CMake --- .github/workflows/linux_build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux_build.yml b/.github/workflows/linux_build.yml index 0fe6a4d5f22..4d9509361d4 100644 --- a/.github/workflows/linux_build.yml +++ b/.github/workflows/linux_build.yml @@ -65,9 +65,9 @@ jobs: -DLINK_WITH_PYTHON=OFF \ -DUSE_PSYCHROMETRICS_CACHING=OFF \ -DUSE_GLYCOL_CACHING=OFF \ - -OPENGL_REQUIRED=OFF \ - -USE_PSYCH_STATS=ON \ - -USE_PSYCH_ERRORS=OFF \ + -DOPENGL_REQUIRED=OFF \ + -DUSE_PSYCH_STATS=ON \ + -DUSE_PSYCH_ERRORS=OFF \ ../ - name: Build EnergyPlus From 45e62e293d20abcf41db7cd71cb6ecb7ce669303 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 6 Apr 2021 10:15:10 -0600 Subject: [PATCH 2/3] fix alt build --- src/EnergyPlus/PsychCacheData.hh | 10 +++++++++ src/EnergyPlus/Psychrometrics.cc | 28 ++++++++++------------- src/EnergyPlus/Psychrometrics.hh | 35 ++++++++++------------------- src/EnergyPlus/api/EnergyPlusPgm.cc | 2 +- 4 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/EnergyPlus/PsychCacheData.hh b/src/EnergyPlus/PsychCacheData.hh index 3920e71c7be..40636bd623c 100644 --- a/src/EnergyPlus/PsychCacheData.hh +++ b/src/EnergyPlus/PsychCacheData.hh @@ -136,6 +136,12 @@ struct PsychrometricCacheData : BaseGlobalStruct Array1D cached_Tsat_HPb; // DIMENSION(0:tsat_hbp_cache_size) #endif +#ifdef EP_psych_stats + // EnergyPlus::Psychrometrics::NumPsychMonitors = 19 + Array1D NumTimesCalled = Array1D(19, 0); + Array1D_int NumIterations = Array1D_int(19, 0); +#endif + void clear_state() override { #ifdef EP_cache_PsyTwbFnTdbWPb @@ -149,6 +155,10 @@ struct PsychrometricCacheData : BaseGlobalStruct #endif #ifdef EP_cache_PsyTsatFnHPb cached_Tsat_HPb.clear(); +#endif +#ifdef EP_psych_stats + NumTimesCalled = Array1D(19, 0); + NumIterations = Array1D_int(19, 0); #endif } }; diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index 28b19be9007..9e4e4fb34e0 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -184,11 +184,7 @@ namespace Psychrometrics { #endif } -#ifdef EP_psych_stats - void ShowPsychrometricSummary(InputOutputFile &auditFile) -#else - void ShowPsychrometricSummary([[maybe_unused]] InputOutputFile &auditFile) -#endif + void ShowPsychrometricSummary([[maybe_unused]] EnergyPlusData &state, InputOutputFile &auditFile) { // SUBROUTINE INFORMATION: @@ -227,14 +223,14 @@ namespace Psychrometrics { Real64 AverageIterations; if (!auditFile.good()) return; - if (any_gt(state.dataPsychrometrics->NumTimesCalled, 0)) { + if (any_gt(state.dataPsychCache->NumTimesCalled, 0)) { print(auditFile, "RoutineName,#times Called,Avg Iterations\n"); for (Loop = 1; Loop <= NumPsychMonitors; ++Loop) { if (!PsyReportIt(Loop)) continue; - const auto istring = fmt::to_string(state.dataPsychrometrics->NumTimesCalled(Loop)); - if (state.dataPsychrometrics->NumIterations(Loop) > 0) { + const auto istring = fmt::to_string(state.dataPsychCache->NumTimesCalled(Loop)); + if (state.dataPsychCache->NumIterations(Loop) > 0) { AverageIterations = - double(state.dataPsychrometrics->NumIterations(Loop)) / double(state.dataPsychrometrics->NumTimesCalled(Loop)); + double(state.dataPsychCache->NumIterations(Loop)) / double(state.dataPsychCache->NumTimesCalled(Loop)); print(auditFile, "{},{},{:.2R}\n", PsyRoutineNames(Loop), istring, AverageIterations); } else { print(auditFile, "{},{}\n", PsyRoutineNames(Loop), istring); @@ -471,7 +467,7 @@ namespace Psychrometrics { bool FlagError; // set when errors should be flagged #ifdef EP_psych_stats - ++state.dataPsychrometrics->NumTimesCalled(iPsyTwbFnTdbWPb); + ++state.dataPsychCache->NumTimesCalled(iPsyTwbFnTdbWPb); #endif // CHECK TDB IN RANGE. @@ -583,7 +579,7 @@ namespace Psychrometrics { } // End of Iteration Loop #ifdef EP_psych_stats - state.dataPsychrometrics->NumIterations(iPsyTwbFnTdbWPb) += iter; + state.dataPsychCache->NumIterations(iPsyTwbFnTdbWPb) += iter; #endif // Wet bulb temperature has not converged after maximum specified @@ -712,7 +708,7 @@ namespace Psychrometrics { Real64 PsyPsatFnTemp(EnergyPlusData &state, Real64 const T, // dry-bulb temperature {C} - std::string const &CalledFrom // routine this function was called from (error messages) + [[maybe_unused]] std::string const &CalledFrom // routine this function was called from (error messages) ) #endif { @@ -752,7 +748,7 @@ namespace Psychrometrics { // FUNCTION LOCAL VARIABLE DECLARATIONS: #ifdef EP_psych_stats - ++state.dataPsychrometrics->NumTimesCalled(iPsyPsatFnTemp); + ++state.dataPsychCache->NumTimesCalled(iPsyPsatFnTemp); #endif // CHECK T IN RANGE. @@ -1000,7 +996,7 @@ namespace Psychrometrics { } #ifdef EP_psych_stats - ++state.dataPsychrometrics->NumTimesCalled(iPsyTsatFnHPb); + ++state.dataPsychCache->NumTimesCalled(iPsyTsatFnHPb); #endif FlagError = false; @@ -1352,7 +1348,7 @@ namespace Psychrometrics { int iter; // Iteration counter #ifdef EP_psych_stats - ++state.dataPsychrometrics->NumTimesCalled(iPsyTsatFnPb); + ++state.dataPsychCache->NumTimesCalled(iPsyTsatFnPb); #endif // Check press in range. @@ -1433,7 +1429,7 @@ namespace Psychrometrics { } // End If for the Pressure Range Checking #ifdef EP_psych_stats - state.dataPsychrometrics->NumIterations(iPsyTsatFnPb) += iter; + state.dataPsychCache->NumIterations(iPsyTsatFnPb) += iter; #endif #ifdef EP_psych_errors diff --git a/src/EnergyPlus/Psychrometrics.hh b/src/EnergyPlus/Psychrometrics.hh index 1cf31214677..e630b89da35 100644 --- a/src/EnergyPlus/Psychrometrics.hh +++ b/src/EnergyPlus/Psychrometrics.hh @@ -146,7 +146,7 @@ namespace Psychrometrics { void InitializePsychRoutines(EnergyPlusData &state); - void ShowPsychrometricSummary(InputOutputFile &auditFile); + void ShowPsychrometricSummary(EnergyPlusData &state, InputOutputFile &auditFile); #ifdef EP_psych_errors void PsyRhoAirFnPbTdbW_error(EnergyPlusData &state, @@ -471,7 +471,7 @@ namespace Psychrometrics { // ASHRAE handbook 1993 Fundamentals, #ifdef EP_psych_stats - ++NumTimesCalled(iPsyRhFnTdbRhovLBnd0C); + ++state.dataPsychCache->NumTimesCalled(iPsyRhFnTdbRhovLBnd0C); #endif Real64 const RHValue(Rhovapor > 0.0 ? Rhovapor * 461.52 * (Tdb + DataGlobalConstants::KelvinConv) * @@ -548,7 +548,7 @@ namespace Psychrometrics { // ASHRAE HANDBOOK OF FUNDAMENTALS, 1972, P99, EQN 28 #ifdef EP_psych_stats - ++NumTimesCalled(iPsyVFnTdbWPb); + ++state.dataPsychCache->NumTimesCalled(iPsyVFnTdbWPb); #endif Real64 const w(max(dW, 1.0e-5)); // humidity ratio @@ -595,7 +595,7 @@ namespace Psychrometrics { // ASHRAE HANDBOOK OF FUNDAMENTALS, 1972, P100, EQN 32 #ifdef EP_psych_stats - ++NumTimesCalled(iPsyWFnTdbH); + ++state.dataPsychCache->NumTimesCalled(iPsyWFnTdbH); #endif Real64 const W((H - 1.00484e3 * TDB) / (2.50094e6 + 1.85895e3 * TDB)); // humidity ratio @@ -651,7 +651,7 @@ namespace Psychrometrics { assert(Grid_Shift == 64 - 12 - psatprecision_bits); // Force Grid_Shift updates when precision bits changes #ifdef EP_psych_stats - ++NumTimesCalled(iPsyPsatFnTemp_cache); + ++state.dataPsychCache->NumTimesCalled(iPsyPsatFnTemp_cache); #endif Int64 const Tdb_tag(bit_shift(bit_transfer(T, Grid_Shift), -Grid_Shift)); // Note that 2nd arg to TRANSFER is not used: Only type matters @@ -707,7 +707,7 @@ namespace Psychrometrics { Int64 hash; #ifdef EP_psych_stats - ++NumTimesCalled(iPsyTwbFnTdbWPb_cache); + ++state.dataPsychCache->NumTimesCalled(iPsyTwbFnTdbWPb_cache); #endif H_tag = bit_transfer(H, H_tag); @@ -806,7 +806,7 @@ namespace Psychrometrics { static std::string const RoutineName("PsyRhFnTdbRhov"); #ifdef EP_psych_stats - ++NumTimesCalled(iPsyRhFnTdbRhov); + ++state.dataPsychCache->NumTimesCalled(iPsyRhFnTdbRhov); #endif Real64 const RHValue(Rhovapor > 0.0 ? Rhovapor * 461.52 * (Tdb + DataGlobalConstants::KelvinConv) / PsyPsatFnTemp(state, Tdb, RoutineName) @@ -857,7 +857,7 @@ namespace Psychrometrics { static std::string const RoutineName("PsyRhFnTdbWPb"); #ifdef EP_psych_stats - ++NumTimesCalled(iPsyRhFnTdbWPb); + ++state.dataPsychCache->NumTimesCalled(iPsyRhFnTdbWPb); #endif Real64 const PWS(PsyPsatFnTemp(state, TDB, (CalledFrom.empty() ? RoutineName : CalledFrom))); // Pressure -- saturated for pure water @@ -915,7 +915,7 @@ namespace Psychrometrics { static std::string const RoutineName("PsyWFnTdpPb"); #ifdef EP_psych_stats - ++NumTimesCalled(iPsyWFnTdpPb); + ++state.dataPsychCache->NumTimesCalled(iPsyWFnTdpPb); #endif Real64 const PDEW( @@ -978,7 +978,7 @@ namespace Psychrometrics { static std::string const RoutineName("PsyWFnTdbRhPb"); #ifdef EP_psych_stats - ++NumTimesCalled(iPsyWFnTdbRhPb); + ++state.dataPsychCache->NumTimesCalled(iPsyWFnTdbRhPb); #endif Real64 const PDEW(RH * @@ -1044,7 +1044,7 @@ namespace Psychrometrics { static std::string const RoutineName("PsyWFnTdbTwbPb"); #ifdef EP_psych_stats - ++NumTimesCalled(iPsyWFnTdbTwbPb); + ++state.dataPsychCache->NumTimesCalled(iPsyWFnTdbTwbPb); #endif Real64 TWB(TWBin); // test wet-bulb temperature @@ -1191,7 +1191,7 @@ namespace Psychrometrics { // This function calculates the dew-point temperature {C} from dry-bulb, wet-bulb and pressure. #ifdef EP_psych_stats - ++NumTimesCalled(iPsyTdpFnTdbTwbPb); + ++state.dataPsychCache->NumTimesCalled(iPsyTdpFnTdbTwbPb); #endif Real64 const W(max(PsyWFnTdbTwbPb(state, TDB, TWB, PB, CalledFrom), 1.0e-5)); @@ -1315,12 +1315,6 @@ struct PsychrometricsData : BaseGlobalStruct Real64 last_tBoil = -99999.0; // Boiling temperature of water at given pressure (last) Real64 Press_Save = -99999.0; Real64 tSat_Save = -99999.0; - -#ifdef EP_psych_stats - Array1D NumTimesCalled = Array1D(NumPsychMonitors, 0); - Array1D_int NumIterations = Array1D_int(NumPsychMonitors, 0); -#endif - Array1D_int iPsyErrIndex = Array1D_int(Psychrometrics::NumPsychMonitors, 0); // Number of times error occurred std::string String; bool ReportErrors = true; @@ -1335,11 +1329,6 @@ struct PsychrometricsData : BaseGlobalStruct tSat_Save = -99999.0; String = ""; ReportErrors = true; - -#ifdef EP_psych_stats - NumTimesCalled = Array1D(NumPsychMonitors, 0); - NumIterations = Array1D_int(NumPsychMonitors, 0); -#endif } }; diff --git a/src/EnergyPlus/api/EnergyPlusPgm.cc b/src/EnergyPlus/api/EnergyPlusPgm.cc index ce25b0d7f6d..2905d608eca 100644 --- a/src/EnergyPlus/api/EnergyPlusPgm.cc +++ b/src/EnergyPlus/api/EnergyPlusPgm.cc @@ -344,7 +344,7 @@ int wrapUpEnergyPlus(EnergyPlus::EnergyPlusData &state) GenOutputVariablesAuditReport(state); - Psychrometrics::ShowPsychrometricSummary(state.files.audit); + Psychrometrics::ShowPsychrometricSummary(state, state.files.audit); state.dataInputProcessing->inputProcessor->reportOrphanRecordObjects(state); FluidProperties::ReportOrphanFluids(state); From 2c112e35c73c4d4e90d77d94c37944ef918b65c9 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Tue, 6 Apr 2021 13:36:34 -0600 Subject: [PATCH 3/3] fix warning, move NumPsychMonitors to PyschCacheData to avoid more circular references --- src/EnergyPlus/PsychCacheData.hh | 11 ++++++----- src/EnergyPlus/Psychrometrics.cc | 2 +- src/EnergyPlus/Psychrometrics.hh | 5 ++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/EnergyPlus/PsychCacheData.hh b/src/EnergyPlus/PsychCacheData.hh index 40636bd623c..2b95e6fb494 100644 --- a/src/EnergyPlus/PsychCacheData.hh +++ b/src/EnergyPlus/PsychCacheData.hh @@ -52,6 +52,8 @@ namespace EnergyPlus { +constexpr int NumPsychMonitors = 19; // Parameterization of Number of psychrometric routines that + #ifdef EP_nocache_Psychrometrics #undef EP_cache_PsyTwbFnTdbWPb #undef EP_cache_PsyPsatFnTemp @@ -137,9 +139,8 @@ struct PsychrometricCacheData : BaseGlobalStruct #endif #ifdef EP_psych_stats - // EnergyPlus::Psychrometrics::NumPsychMonitors = 19 - Array1D NumTimesCalled = Array1D(19, 0); - Array1D_int NumIterations = Array1D_int(19, 0); + Array1D NumTimesCalled = Array1D(NumPsychMonitors, 0); + Array1D_int NumIterations = Array1D_int(NumPsychMonitors, 0); #endif void clear_state() override @@ -157,8 +158,8 @@ struct PsychrometricCacheData : BaseGlobalStruct cached_Tsat_HPb.clear(); #endif #ifdef EP_psych_stats - NumTimesCalled = Array1D(19, 0); - NumIterations = Array1D_int(19, 0); + NumTimesCalled = Array1D(NumPsychMonitors, 0); + NumIterations = Array1D_int(NumPsychMonitors, 0); #endif } }; diff --git a/src/EnergyPlus/Psychrometrics.cc b/src/EnergyPlus/Psychrometrics.cc index 9e4e4fb34e0..c86920b4d1c 100644 --- a/src/EnergyPlus/Psychrometrics.cc +++ b/src/EnergyPlus/Psychrometrics.cc @@ -184,7 +184,7 @@ namespace Psychrometrics { #endif } - void ShowPsychrometricSummary([[maybe_unused]] EnergyPlusData &state, InputOutputFile &auditFile) + void ShowPsychrometricSummary([[maybe_unused]] EnergyPlusData &state, [[maybe_unused]] InputOutputFile &auditFile) { // SUBROUTINE INFORMATION: diff --git a/src/EnergyPlus/Psychrometrics.hh b/src/EnergyPlus/Psychrometrics.hh index e630b89da35..1db251fe6e1 100644 --- a/src/EnergyPlus/Psychrometrics.hh +++ b/src/EnergyPlus/Psychrometrics.hh @@ -106,7 +106,6 @@ namespace Psychrometrics { constexpr int iPsyRhFnTdbRhovLBnd0C = 13; constexpr int iPsyTwbFnTdbWPb_cache = 18; constexpr int iPsyPsatFnTemp_cache = 19; - constexpr int NumPsychMonitors = 19; // Parameterization of Number of psychrometric routines that std::string const blank_string; @@ -1315,13 +1314,13 @@ struct PsychrometricsData : BaseGlobalStruct Real64 last_tBoil = -99999.0; // Boiling temperature of water at given pressure (last) Real64 Press_Save = -99999.0; Real64 tSat_Save = -99999.0; - Array1D_int iPsyErrIndex = Array1D_int(Psychrometrics::NumPsychMonitors, 0); // Number of times error occurred + Array1D_int iPsyErrIndex = Array1D_int(EnergyPlus::NumPsychMonitors, 0); // Number of times error occurred std::string String; bool ReportErrors = true; void clear_state() override { - iPsyErrIndex = Array1D_int(Psychrometrics::NumPsychMonitors, 0); + iPsyErrIndex = Array1D_int(EnergyPlus::NumPsychMonitors, 0); iconvTol = 0.0001; last_Patm = -99999.0; // barometric pressure {Pascals} (last) last_tBoil = -99999.0; // Boiling temperature of water at given pressure (last)