Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPM - Fortran Transition - throw if SPM names are not unique #10542

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Jun 3, 2024

Pull request overview

ref #10537 (comment)

Testbed on compiler explorer: https://gcc.godbolt.org/z/KK4e64c8b

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • 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

Reviewer

This will not be exhaustively relevant to every PR.

  • 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

@jmarrec jmarrec added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Jun 3, 2024
CALL GetObjectItem(SPMTypes(i),spmNum,Alphas,NumAlphas,Numbers,NumNumbers,Status)
! VerifyName(TRIM(Alphas(1)), SPMNames, spmIndex, SPMErrorFound, IsBlank, "SetpointManager Unicity");
IF (FindItemInList(TRIM(Alphas(1)), SPMNames, spmIndex) /= 0) THEN
CALL ShowFatalError('SetpointManager Unicity of Names: SPM of type '//TRIM(SPMTypes(i))//' has a name already found='//TRIM(Alphas(1)),Auditf)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you just append a loop or counter index to make the name unique and continue searching?


INTEGER, PARAMETER :: NumSPMTypes = 29
CHARACTER(len=MaxNameLength), DIMENSION(NumSPMTypes) :: SPMTypes
SPMTypes(1) = "SETPOINTMANAGER:SCHEDULED"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't really read Fortran, and by "can't" I mean "don't want to." Why is this thing in Fortran and not in Python? This seems like a very Python thing.

Copy link
Member

Choose a reason for hiding this comment

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

You are right that this is a Python thing. It is actively being worked on by @jasondegraw, and it looks great. We'll get there.

@jmarrec
Copy link
Contributor Author

jmarrec commented Jun 4, 2024

I forgot to add the license text I guess. Edwin just mentionned this would be needed, and I nerdsnipped myself into helping out.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

Anyways, I agree this would be better in any other language, even C++.

Python is a good candidate, would make it much easier to write transition rules (and we could even have - hear me out - tests!). @Myoldmopar long had a vision to integrate seemlessly python utilities in our install of E+, the issue has always been (IIUC) packaging.

I think I've got a solution, "just" make it part of the CLI as a subcommand, and use the embedded python to execute the modules.
I'd get CMake to run python -m pip install --target="$<TARGET_FILE_DIR:energyplusapi>/python_standard_lib" --upgrade energyplus-python-apps==24.1a1 (could be a specific subdir instead of python_standard_lib, this is irrelevant to the point I'm making).

And TADAAAA

python_auxiliary_tools

CALL GetObjectItem(SPMTypes(i),spmNum,Alphas,NumAlphas,Numbers,NumNumbers,Status)
! VerifyName(TRIM(Alphas(1)), SPMNames, spmIndex, SPMErrorFound, IsBlank, "SetpointManager Unicity");
IF (FindItemInList(TRIM(Alphas(1)), SPMNames, spmIndex) /= 0) THEN
CALL ShowFatalError('SetpointManager Unicity of Names: SPM of type '//TRIM(SPMTypes(i))//' has a name already found='//TRIM(Alphas(1)),Auditf)
Copy link
Member

Choose a reason for hiding this comment

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

Unicity. TIL

Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

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

This looks fine, and I confirmed it works by making a non-unicity-based input file:

 **  Fatal  ** SetpointManager Unicity of Names: SPM of type SETPOINTMANAGER:MIXEDAIR has a name already found=Mixed Air Temp Manager 1
 ************* Conversion Terminated--Fatal Error Detected. 1 Warning; 0 Severe Errors

@Myoldmopar Myoldmopar merged commit 866845f into SPM Jun 4, 2024
14 checks passed
@Myoldmopar Myoldmopar deleted the SPM-transition branch June 4, 2024 14:07
@mjwitte
Copy link
Contributor

mjwitte commented Jun 4, 2024

Late to the party here. I don't think we want transition to fatal. If transition isn't going to fix the names, then throw a warning but continue and convert the rest of the file. IMHO it makes more sense as a user to repair the newer version file rather than go back and change the original.

@Myoldmopar
Copy link
Member

So I know it says it fatalled....but it actually created the new input file properly with 24.2 version and everything. Here's the vCpErr:

Program Version,Conversion 24.1 => 24.2
   ** Warning ** Object=Sizing:Zone, name=SPACE1-1, entered with less than minimum number of fields.
   **   ~~~   ** Attempting fill to minimum.
   **  Fatal  ** SetpointManager Unicity of Names: SPM of type SETPOINTMANAGER:MIXEDAIR has a name already found=Mixed Air Temp Manager 1
   ************* Conversion Terminated--Fatal Error Detected. 1 Warning; 0 Severe Errors
   ************* Conversion Completed Successfully-- 1 Warning; 0 Severe Errors

I agree it shouldn't fatal. And if it's reporting a fatal and continuing anyway, it shouldn't be reporting a fatal error. We can fix it over in the SPM branch where this code now lives. (It's not in develop yet, this PR just put it into SPM)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants