loganoz / horses3d

HORSES3D: A high-order discontinuous Galerkin solver for flow simulations and multi-physics applications
https://loganoz.github.io/horses3d/
MIT License
106 stars 23 forks source link

intermediate integer overflow when writing large files #223

Closed TRPrasanna closed 1 month ago

TRPrasanna commented 3 months ago

19 There seems to be still one bug remaining from aforementioned issue that was solved earlier. This appears when writing large files exceeding around 2 GB. For instance, when running the Taylor-Green vortex test case with polynomial order of 11 or more, horses3d will fail to write the initial solution and crash. The bug is in line 2981 of /Solver/src/libs/mesh/HexMesh.f90:

pos = POS_INIT_DATA + (e % globID-1)*5_AddrInt*SIZEOF_INT + padding*e % offsetIO * SIZEOF_RP

What happens is that at some point, the value of

padding*e % offsetIO * SIZEOF_RP

exceeds the value for a 32-bit integer and overflows because it has not been promoted to integer of type AddrInt yet. The solution seems simple, for instance, changing this line to

pos = POS_INIT_DATA + (e % globID-1)*5_AddrInt*SIZEOF_INT + 1_AddrInt* padding*e % offsetIO * SIZEOF_RP

I have suggested the same in my pull request #224

loganoz commented 2 months ago

Thank you. I approved the pull request to run the test cases in CI and assign the review to one of my collaborators