I have some Fortran code that calls RESHAPE
to reorder a matrix such that the dimension that I am now about to loop over becomes the first varying dimension (Column-major order in Fortran).
This has nothing to do with C/Fortran interoperability.
Now the matrix is rather large and when I call the RESHAPE
function I get a seg fault which I am very confident is a stack overflow. I know this because I can compile my code in ifort with -heap-arrays
and the problem disappears.
I do not want to modify the stack-size. This code needs to be portable for any computer without the user having to concern himself with stack-size.
Is there someway I can get this call of the RESHAPE
function to use the heap and not the stack for its internal memory use.
Worst case I will have to 'roll my own' RESHAPE
function for this instance but I wish there was a better way.