NatLabRockies / NatLabRockies/SAM

Marine Wave Energy model fails to read weather file if Location ID is not a number

Open
#1,994 0 comments 0 reactions 1 assignee View on GitHub

@mjprilliman is already working on this.

Since Jan 22, 2025.

bug
Dominant language
C++
Stars
486
Forks
219
Avg merge
10h 10m
Merged PRs (30d)
2

Description

Describe the bug

When the Location ID in the weather file is not a number, the std::stod() function used to read the value returns an error and stops the file reading process.

See https://sam.nrel.gov/forum/forum-general/4905-wave-resource-simulation.

To Reproduce

Steps to reproduce the behavior:

  1. Download weather file from SAM Forum post.
  2. Create a new Marine Wave case.
  3. On the Wave Resource page click Add/remove weather file folders and add the folder containing the weather file from Step 1.
  4. Note that weather file does not get added to the library.
  5. Open the weather file with a text editor, and edit the Location ID value in Row to a numeric value.
  6. Repeat Step 3 above.
  7. Note weather file is added to library.

In general, I think anytime std::stod() or std::stof() is used, the value returned should be checked and if it is invalid (not a number), a useful error message should be generated. (This is also an issue with the wind file reader.)

Operating System and Version
  • SAM 2024.12.12
  • Windows 11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.