I should start with that I am not a Fortran developer but am helping out with a port of some native applications from a 32 bit to 64 bit architecture.
In one particular Fortran file (which works fine in 32 bit) crashes with a segfault in 64 bit. The problem relates to the use of a cray pointer to a real array that is dynamically allocated to a particular size. When the routine goes to read a bunch of reals into that array it segfaults. Note: if I statically allocate a real array and use that then the code reads correctly from the file and populates the array. Here is an abbreviated example:
real climpack
pointer (pclimpack, climpack)
pclimpack = malloc(ipack)
.....
read(31, iostat=istat) climpack
free(pclimpack)
Now this same section of code works fine with integers (both on 32 and 64 bit) and works fine with reals on 32 bit but segfaults with reals on 64 bit. And why does it work with a statically allocated array but not with the cray pointer? What am I missing?
It should be noted that I am using gfortran as the compiler
Thank you!