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 iomsg allocation in save_npy #600

Merged
merged 2 commits into from Dec 17, 2021
Merged

Conversation

ivan-pi
Copy link
Member

@ivan-pi ivan-pi commented Dec 15, 2021

This is currently just a draft for a minor issue remaining in #581.

I've added a test to check that iomsg is deallocated if present, although this should technically be guaranteed by a standard-conforming compiler when the intent(out) attribute is present.

To make sure the message gets allocated I need a way to trigger stat /= 0. Is their any known way of doing this for a new file?

On more thought, I'm afraid that both stat and iomsg only communicate the result of the command close(), and not if opening or writing were unsuccessful. I'm not sure whether the standard stipulates these commands be connected (in other words whether the same I/O error will trigger the same iostat flag in any of the three commands).

Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

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

Good catch, thanks for fixing it

@@ -128,7 +128,9 @@ contains
end if

if (present(iomsg)) then
iomsg = "Failed to write array to file '"//filename//"'"
if (stat /= 0) then
Copy link
Member

Choose a reason for hiding this comment

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

Why not check for present(iomsg) .and. stat /= 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did that initially, but then decided to go with nested if's to avoid the .and..

@awvwgk awvwgk added the reviewers needed This patch requires extra eyes label Dec 16, 2021
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

Copy link
Member

@milancurcic milancurcic 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!

@milancurcic milancurcic merged commit 10f9438 into fortran-lang:master Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewers needed This patch requires extra eyes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants