I am porting and compiling legacy fortran code that is fairly size-able. In this code, the original designers used EQUIVALENCE to set 2 arrays
INTEGER4 ARRAY1 (500000) and REAL8 ARRAY2 (250000)
in same memory space with EQUIVALENCE(ARRAY1(1), ARRAY2(1))
I cannot be sure why they did this exactly, other than possibly conserving valuable memory space, but they did it. Removing the EQUIVALENCE is not an option that I wish to explore for other reasons.
Nonetheless, when reading real numbers from ARRAY2 occasionally the code fails with 'Invalid Floating Point Operation.' Which seems logical, if the numbers written in that space were originally intended as two integer4's and not a real8.
My questions are:
- Does Silverfrost FTN95 use the IEE754 standard for real number representation? (I assume yes, since it supports NaN, etc).
- Assuming that the largest REAL8 is 1.7976931E+308 and the smallest REAL8 is 2.2250739E-308, what triggers the error : 'Invalid Floating Point Operation.' Numbers that are outside this range? Other parameters?
- How does the Silverfrost FTN95 compiler stores REAL*8 numbers? (I asume that a fair description would be in http://en.wikipedia.org/wiki/Double_precision_floating-point_format however what is the exact byte order? That is, are the 52 bits of the mantissa first and the 11 bits of the exponent following? I can see that the sign bit appears to be in the last word of the 8, but this is slightly counterinitiative to me. If 0.5 is equal to
0 01111111110 0000000000000000000000000000000000000000000000000000 with Exponent= 1022 (01111111110) how are these bits packaged into the 8 bytes?
My interest in these questions is the leave the legacy code intact, substantially, and trap these errors by looking at the bytes before reading a real*8 number, and if they are not a valid floating point number, to either skip the assignment or assign to an appropriate surrogate dependant on the intent of that assignment where it is called.
Thanks in advance for your help on this odd question.