See chapter 14 of the Fortran 2003 standard. Example, cf. http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/642578db8949fd2f -------------- program ieee use,intrinsic :: ieee_arithmetic implicit none
if(.not. IEEE_support_standard(1.0d0) & .or. .not.IEEE_support_halting(IEEE_INVALID) & .or. .not.IEEE_support_halting(IEEE_DIVIDE_BY_ZERO)) & stop 'No IEEE support available!' call ieee_set_halting_mode([IEEE_INVALID, IEEE_DIVIDE_BY_ZERO],& .false.) call printLog(1.0d0) call printLog(0.0d0) call printLog(-1.0d0) call printLog(2.0d0) contains subroutine printLog(x) double precision, intent(in) :: x double precision :: y y = log(x) if(.not. ieee_is_finite(y)) then write(*,*) 'Ignoring calculation for x = ', x,'; result is: ',y else print *, 'Result is: log(',x,') = ',y end if end subroutine printLog end program ieee -------------- Expected result (NAG f95 gives the following): Result is: log( 1.0000000000000000 ) = 0.0000000000000000 Ignoring calculation for x = 0.0000000000000000 ; result is: -Infinity Ignoring calculation for x = -1.0000000000000000 ; result is: NaN Result is: log( 2.0000000000000000 ) = 0.6931471805599453 Warning: Floating invalid operand occurred Warning: Floating divide by zero occurred -- Summary: Fortran 2003/F95[TR15580:1999]: Floating point exception (IEEE) support Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tobias dot burnus at physik dot fu-berlin dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29383