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

fix(inputoutput): handle line ending skipped by getline for cr or lf #1866

Merged
merged 2 commits into from
Jun 14, 2024

Conversation

vivekbedekar
Copy link
Contributor

No description provided.

! -- look for undetected end-of-record with isolated CR or LF
linesize = len(line)
crlfcheck: do i = 1, linesize
if (line(i:i) .eq. cr .or. line(i:i) .eq. lf) then
Copy link
Contributor

Choose a reason for hiding this comment

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

I must be missing something fundamental here. The outermost if statement looks for CR or LF in line(i:i). Then, the inner if statements again check for CR or LF in line(i:i). How does this check for an isolated CR or LF? I'm sure you tested this so you know it works -- I just can't see why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The outer if statement identifies an isolated CR or LF. The inner if statement only prints the appropriate message for either CR or LF. Both CR and LF are not expected to be present in the middle of the line [line(i:i)]. If, for any reason, CR and LF appear in the middle of a line, that is still a bug.

@langevin-usgs
Copy link
Contributor

@vivekbedekar, thanks for this. I will go ahead and merge. Can you please add a release notes description on this PR as a comment and we will add it to the release notes. Maybe something like: "For ASCII input files erroneously containing a mix of line endings, MODFLOW would sometimes proceed with unexpected results. The program was corrected to stop with an error message if an input line contained both carriage returns and line feeds." Ideally you would add this to the release notes yourself (under ./doc/ReleaseNotes/develop.tex) and include in the PR, but this is a latex file and I'm not sure you are set up to work with latex yet.

@langevin-usgs langevin-usgs merged commit 151df87 into MODFLOW-USGS:develop Jun 14, 2024
18 checks passed
@langevin-usgs
Copy link
Contributor

a mix of line endings, MODFLOW would sometimes proceed with unexpected results. The program was corrected to stop wit

@vivekbedekar, thanks for this. I will go ahead and merge. Can you please add a release notes description on this PR as a comment and we will add it to the release notes. Maybe something like: "For ASCII input files erroneously containing a mix of line endings, MODFLOW would sometimes proceed with unexpected results. The program was corrected to stop with an error message if an input line contained both carriage returns and line feeds." Ideally you would add this to the release notes yourself (under ./doc/ReleaseNotes/develop.tex) and include in the PR, but this is a latex file and I'm not sure you are set up to work with latex yet.

Sorry, I just noticed that you did update the release notes in this PR. Sorry I missed that. But it might be good to update with a better description of the change. Can you look at my proposal and revise as appropriate? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants