The next release of FTN95 and its associated DLLs will provide support for the Fortran 2003 intrinsic IEEE_ARITHMETIC module.
This is particularly for x64, with some support for Win32.
A new routine TRAP_FP_EXCEPTIONS@ will be released for x64 but not for Win32.
SUBROUTINE TRAP_FP_EXCEPTIONS@(trap)
INTEGER trap
A trap value of zero masks all floating point runtime exceptions. A non-zero value restores the default state where
floating point exceptions lead to a runtime failure.
This routine is not provided for Win32 because the the existing TRAP_EXCEPTION@ function does not enable
progression (i.e. the CONTINUE_EXECUTION return state) after handling a floating point exception.
- TRAP_FP_EXCEPTIONS@ is implemented independently of the IEEE_ARITHMETIC module.
- Standard PRINT and WRITE statements will display 'NaN', 'Infinity', or '-Infinity' where appropiate (depending on the
field width) and this is independent of IEEE_ARITHMETIC. The current output is '????....'.
- Users who want to mask floating point exceptions must use x64 and must call TRAP_FP_EXCEPTIONS@(0) for related sections
of their code.
Example
real t,z,v(6)
z = 0.0
t = tiny(z)
call trap_fp_exceptions@(0)
v = [z/z,z/1.0,-z/1.0,1.0/z,-1.0/z,t/10]
call trap_fp_exceptions@(1)
do i = 1,6; print*, v(i); end do
end
Output:
NaN
0.00000
0.00000
Infinity
-Infinity
0.00000