Skip to content

Bugfix/atrayno/#338 enf of file gfortran bug#1038

Merged
mathomp4 merged 6 commits into
developfrom
bugfix/atrayno/#338_enf_of_file_gfortran_bug
Sep 21, 2021
Merged

Bugfix/atrayno/#338 enf of file gfortran bug#1038
mathomp4 merged 6 commits into
developfrom
bugfix/atrayno/#338_enf_of_file_gfortran_bug

Conversation

@atrayano
Copy link
Copy Markdown
Contributor

@atrayano atrayano commented Sep 18, 2021

Description

Fixes #338. Adds a workaround for a gfortran bug that handles end-of-file incorrectly

Related Issue

Motivation and Context

How Has This Been Tested?

@mathomp4 tested the fix on discover and on his laptop

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Trivial change (affects only documentation or cleanup)

Checklist:

  • I have tested this change with a run of GEOSgcm (if non-trivial)
  • I have added one of the required labels (0 diff, 0 diff trivial, 0 diff structural, non 0-diff)
  • I have updated the CHANGELOG.md accordingly following the style of Keep a Changelog

@atrayano atrayano added 0 Diff The changes in this pull request have verified to be zero-diff with the target branch. bugfix labels Sep 18, 2021
@atrayano atrayano requested a review from a team as a code owner September 18, 2021 18:05
@atrayano atrayano self-assigned this Sep 18, 2021
@mathomp4
Copy link
Copy Markdown
Member

I did test this with GEOSgcm and it didn't seem to change any answers with GNU or Intel.

Copy link
Copy Markdown
Collaborator

@tclune tclune left a comment

Choose a reason for hiding this comment

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

I don't think this is a bug in gfortran, but rather an attempt to do an unformatted read on a formatted file. The READ in question is missing a format.

http://www.hep.manchester.ac.uk/u/samt/misc/gfortran_errors.html

The correct fix would appear to be to read it one way for FORMATTED and the other for UNFORMATTED.

@atrayano
Copy link
Copy Markdown
Contributor Author

@tclune Let discuss this in the morning. This is no formatted/unformatted file issue. Before I coded the "fix" I also have looked at at about several years old patch for gfortran that introduces LIB_ERROR_OPTION_CONFLICT (i.e. 5001). My point is that we intentionally read the file (in this case unformatted binary) to check if we are past the end-of-file. Every other compiler returns properly IOSTAT=IOSTAT_END. But gfortran returns 5001

Copy link
Copy Markdown
Collaborator

@tclune tclune left a comment

Choose a reason for hiding this comment

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

I made a logical error in my analysis yesterday. PR is fine. This does appear to be a bug in gfortran based upon an isolated reproducer.

@mathomp4 mathomp4 merged commit 6dd7cdb into develop Sep 21, 2021
@mathomp4 mathomp4 deleted the bugfix/atrayno/#338_enf_of_file_gfortran_bug branch September 21, 2021 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 Diff The changes in this pull request have verified to be zero-diff with the target branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants