Fix size() for large variables >= 2^31 values#482
Open
Dave-Allured wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refer to #476. This PR might resolve the issue.
This is a straightforward PR, but it is untested. Please run this through CI, or let me know how I can enable CI on my personal fork of netcdf-fortran.
This PR supports large array variables with aggregate size (total number of values [not bytes]) exceeding the original code limit of MAX_INT (2^31 - 1).
The original library code created temp arrays like this. The original fortran 90
size()intrinsic function returned only 32-bit integers. This overflowed and failed whenever the total number of elements (product of multiple dimensions) exceeded MAX_INT:Fortran 2003+ allows 64-bit integers to be optionally specified for the
size()intrinsic. The array limit now becomes MAX_INT64 (2^63 - 1) total number of values:This PR fixes all 28 instances of this
allocateconstruction, across three different source files in thefortran/source directory.This PR will require a minimum standard of fortran 2003 to build netcdf-fortran. I do not know whether the current overall requirement has already reached fortran 2003.