Fortran · Exception
What does IEEE_INVALID — Invalid Floating-Point Operation mean in Fortran?
Signals when a floating-point operation has no well-defined real result: square root or log of a negative number, 0/0, subtracting two same-signed infinities, or any operation involving a signaling NaN. The IEEE_EXCEPTIONS module tracks it as a flag of type IEEE_FLAG_TYPE that starts quiet and turns signaling the instant the offending operation runs, and it's one of the three flags in the standard IEEE_USUAL set.
Signals when a floating-point operation has no well-defined real result: square root or log of a negative number, 0/0, subtracting two same-signed infinities, or any operation involving a signaling NaN. The IEEE_EXCEPTIONS module tracks it as a flag of type IEEE_FLAG_TYPE that starts quiet and turns signaling the instant the offending operation runs, and it's one of the three flags in the standard IEEE_USUAL set.
Turn on halting with IEEE_SET_HALTING_MODE(IEEE_INVALID, .TRUE.) (or compile with -ffpe-trap=invalid on gfortran, or enable invalid-operand trapping under Intel's -fpe0) so execution stops at the exact statement, then check IEEE_GET_FLAG(IEEE_INVALID, flag) around suspect expressions if you'd rather detect it in code than crash.