Skip to content

Conversation

@joseph-robertson
Copy link
Collaborator

Pull request overview

Description of the purpose of this PR

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies
  • If adding/removing any output files (e.g., eplustbl.*)
    • Update ..\scripts\Epl-run.bat
    • Update ..\scripts\RunEPlus.bat
    • Update ..\src\EPLaunch\ MainModule.bas, epl-ui.frm, and epl.vbp (VersionComments)
    • Update ...github\workflows\energyplus.py

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@joseph-robertson joseph-robertson self-assigned this Jan 29, 2026
@mitchute mitchute added the Defect Includes code to repair a defect in EnergyPlus label Jan 30, 2026
@mitchute
Copy link
Collaborator

As I understand it, Windows builds don't pick up uninitialized variables, which we treat as errors.

/home/mitchute/Projects/EnergyPlus/tst/EnergyPlus/unit/EMSManager.unit.cc:1065:9: error: unused variable ‘wallSurfNum’ [-Werror=unused-variable]
 1065 |     int wallSurfNum = Util::FindItemInList("WALL", state->dataSurface->Surface);
      |         ^~~~~~~~~~~

@rraustad
Copy link
Collaborator

rraustad commented Jan 30, 2026

I am using Windows 11 and do not get the unused variable warning for wallSurfNum, well, because it is initialized at line 1065 and used at 1068. If there is an issue with EMS initializing a variable before it's used (e.g., site_temp_adj) then this unit test should fail. But it doesn't, it passes with. wallSurfNum = 1, ViewFactorGround = 0.1 and seriousErrorFound = false (i.e., EXPECT_TRUE on line 1076 should be EXPECT_FASLE and line 1068 is correct). So what should happen here? I assume this unit test should check for whether site_temp_adj was initialized before it was used, but I don't see that in this unit test.

image

@joseph-robertson
Copy link
Collaborator Author

joseph-robertson commented Jan 30, 2026

This PR is about the EMS variable site_temp_adj, not wallSurfNum. The intent (i.e., 8623d71) was to commit a failing test, to demonstrate that the uninitialized site_temp_adj should throw an error but does not. The test fails on my machine.

Comment on lines 1047 to 1048
" Set power_mult = site_temp_adj, !- Program Line 1",
" Set site_temp_adj = 0.1, !- Program Line 2",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable site_temp_adj is being initialized after it is referenced. We should expect an error, right?

int wallSurfNum = Util::FindItemInList("WALL", state->dataSurface->Surface);
bool anyRan;
EMSManager::ManageEMS(*state, EMSManager::EMSCallFrom::BeginTimestepBeforePredictor, anyRan, ObjexxFCL::Optional_int_const());
EXPECT_EQ(state->dataSurface->Surface(wallSurfNum).ViewFactorGround, 0.1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally had this line commented out so that we could get to EXPECT_TRUE(seriousErrorFound); down below.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, feel free to do what you need. I won't interfere anymore until you need someone to look. I was just pointing out that the CI linux builds were failing due to to the unused variable, that we treat as an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, understood.

@joseph-robertson
Copy link
Collaborator Author

Pretty sure I have this narrowed down. I think GetEMSInput can set state.dataRuntimeLang->ErlVariable(VariableNum).Value.initialized = true without calling EvaluateExpression first.


internalVarNum = RuntimeLanguageProcessor::FindEMSVariable(*state, "site_temp_adj", 1);
ASSERT_GT(internalVarNum, 0);
EXPECT_TRUE(state->dataRuntimeLang->ErlVariable(internalVarNum).Value.initialized);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main difference with the first test; why is this suddenly initialized?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unitialized EMS variable is misused

4 participants