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

loadtxt/savetxt: do not require space after last entry #877

Merged
merged 8 commits into from
Oct 22, 2024

Conversation

perazz
Copy link
Contributor

@perazz perazz commented Sep 27, 2024

Attempt to address #862.

The current formats require an end-of-row space both in savetxt and loadtxt, i.e.,

format(*(i0,1x))

This PR proposes to not require a space after the last record, i.e.,

format(*(i0,:,1x))

This should hopefully improve the seldom crashing CI tests.
@fortran-lang/stdlib @chuckyvt @minhqdao

PS: these routines would benefit from some form of error control in the read and write statements.
Without changing the API, I propose checking for iostat and iomsg, so that when something goes wrong, an error can be produced to give information about what happened (what file, which line).

Copy link
Member

@jvdp1 jvdp1 left a comment

Choose a reason for hiding this comment

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

Thank you @perazz . Pending minor comments, LGTM.
Note: I thought that write(*,'(*(i0,1x)') would not result in a line with a space at its end. Is this compiler-specific?

src/stdlib_io.fypp Outdated Show resolved Hide resolved
src/stdlib_io.fypp Outdated Show resolved Hide resolved
src/stdlib_io.fypp Outdated Show resolved Hide resolved
src/stdlib_io.fypp Outdated Show resolved Hide resolved
@perazz
Copy link
Contributor Author

perazz commented Oct 6, 2024

Is this compiler-specific?

I'm never sure about these string formats, so I went test it here. It seems like all most used compilers do add a space at the end. After this PR we will have an error message, so if those tests fail again, we will hopefully know why (I've never had any errors testing on my machine locally).

@jvdp1
Copy link
Member

jvdp1 commented Oct 21, 2024

Can this PR be merged, @perazz ?

@perazz
Copy link
Contributor Author

perazz commented Oct 22, 2024

As there have been no further comments, I will merge @jvdp1. Thanks for the review and approval.

@perazz perazz merged commit 38e8e0e into fortran-lang:master Oct 22, 2024
16 checks passed
@perazz perazz deleted the fix_loadtxt branch October 22, 2024 06:51
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.

2 participants