In the process of stress testing some code, I came across the following. If the result of a double precision operation to be stored in an integer exceeds the possible range of that integer, there is no exception generated, and the program terminates (and it takes a long time to do so). The following code illustrates the issue. I perform the calculation with the result being a 64-bit integer (stored into a 32-bit), the result calculated as a 32-bit integer (fails), and an implicit conversion across the equals sign (never gets here, actually). Only the first result gets output, and no overflow is detected with the conversion across the equals sign. /CHECKMATE and /RELEASE operate the same way.
program main
integer:: i_xx,i_yy,i_zz
real*8:: ddx
ddx = 9999999.d0
i_xx = int(ddx*1000.d0,4)
print *,i_xx
i_zz = int(ddx*1000.d0,3)
print *,i_zz
i_yy = ddx*1000.d0
print *,i_yy
end
Is there a compiler option to enforce the checking? Or, is there no run-time exception handler?
Bill