Search code examples
fortranintelflags

Questions about intel fortran compiler options


I am currently running a fortran code both on serial (single core)/parallel (48 cores),and there are values such as "infinity" or "NaN" in the output (which shouldn't have) without any other information. I would like to use the compiler options to help me locate the source of the infinity/NaN. I tried the combination of "-O0 -g -traceback -fpe3", then during run-time, the infinity appears earlier in such case than the normal case (without debug options). But still, there is no information about which line in the source code causes such behavior. So, I was wondering, are there any available compiler options that can help me locate the source of infinity/NaN? Or am I using the right combination of the flags?

Thanks in advance! =)


Solution

  • The fpe option was the right idea! But you used the wrong number: according to the Intel Fortran Compiler documentation, when the integer after fpe is 3:

    All floating-point exceptions are disabled. Floating-point underflow is gradual, unless you explicitly specify a compiler option that enables flush-to-zero, such as -ftz or /Qftz, O3, or O2 on IA-32 and Intel EM64T systems. This setting provides full IEEE support.

    You need to use -fpe0, which results in:

    Floating-point invalid, divide-by-zero, and overflow exceptions are enabled. If any such exceptions occur, execution is aborted. This option sets the -ftz (Linux and Mac OS) or /Qftz (Windows) option; therefore underflow results will be set to zero unless you explicitly specify -no-ftz (Linux and Mac OS) or /Qftz- (Windows). On Itanium®-based systems, underflow behavior is equivalent to specifying option -ftz or /Qftz.