Fix overflow bug in printing of Legendre polynomial arrays #202
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.
For large problems e.g. TCO2559, the sizes (in bytes) of arrays
FG%ZAA
andFG%ZAS
can be reported as negative inSETUP_TRANS
. This is because theSIZE
function returns a 4-byte signed integer value, maximum about 2 billion, by default. For certain configurations the sizes ofZAS
andZAA
(in number of elements) can go above this value, leading to an integer overflow. This number is then multiplied by the result ofC_SIZEOF
which I think returns aC_SIZE_T
. It seems that the result of this product between two different integer types is an 8-byte integer, for some reason.This PR fixes this bug by requesting a wider integer value from the
SIZE
function.How to reproduce
Write a simple program that only does a setup:
This sets
NPRTRV
to the number of MPI tasks which maximises the memory consumption of the Legendre polynomials on each task.Run this test with, e.g. 256 MPI tasks (which needs about 128 nodes on the ECMWF HPC to avoid running out of memory).
The test can be run even without GPUs available by commenting out all OpenACC or OpenMP target directives from
SETUP_TRANS
.The following will be printed to stdout:
After this PR, the following will be printed: