esmf-org / esmf

The Earth System Modeling Framework (ESMF) is a suite of software tools for developing high-performance, multi-component Earth science modeling applications.
https://earthsystemmodeling.org/
Other
156 stars 75 forks source link

ESMPy: Fix type cast to support large Arrays #267

Closed billsacks closed 2 months ago

billsacks commented 2 months ago

In a few places, the size of an Array was being cast to a c_int. This caused an overflow if the size exceeded 32 bits. An example of the issue is reported here, and I have reproduced this: https://github.com/orgs/esmf-org/discussions/263

From some reading, I think the correct cast here should be to ssize_t, which resolves to a long int (64 bits) on a 64-bit architecture. I am not 100% positive of this, but this seems consistent with what I have found; e.g., see:

billsacks commented 2 months ago

ESMPy testing passes with this change on my Mac.

billsacks commented 2 months ago

@rokuingh - I'm going ahead and merging this, but if you want to look at this later and notice any issues, I can change it.