error-handlingfortranlibrariesintel-mklsigfpe

Disable FPE handler on run-time in Fortran


I have a library written in Fortran that uses Intel's MKL (linked statically). I'm using ifort for compiling and linking.
When I link my library (dynamically) with some other code using the -fpe0 option, I get floating point exceptions in the MKL, which seems to be a known thing according to Intel and nothing to worry about. I assume it is due to some speculative executions.
However when someone else uses my library, they might try to use -fpe0 for linking their code to my library and this might lead to trouble. So I was wondering: Is there any way to turn off the FPE handler at runtime when entering my library and putting it back to the original state on return?
Thanks!


Solution

  • As Vladimir pointed out, the requested functionality is provided by the ieee_exceptions intrinsic module: See here

    This is supported by Intel's ifort from at least version 12 on (tested) and presumably by gfortran from version 4.10 (not tested).