简体   繁体   English

在Fortran中在运行时禁用FPE处理程序

[英]Disable FPE handler on run-time in Fortran

I have a library written in Fortran that uses Intel's MKL (linked statically). 我有一个用Fortran编写的库,该库使用Intel的MKL(静态链接)。 I'm using ifort for compiling and linking. 我正在使用ifort进行编译和链接。
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. 当我使用-fpe0选项将我的库与其他代码动态地链接时,我在MKL中得到浮点异常,这对Intel来说似乎是已知的事情,无需担心。 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. 但是,当其他人使用我的库时,他们可能会尝试使用-fpe0将他们的代码链接到我的库,这可能会导致麻烦。 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? 所以我想知道:是否有什么方法可以在进入库时在运行时关闭FPE处理程序,并在返回时将其恢复为原始状态?
Thanks! 谢谢!

As Vladimir pointed out, the requested functionality is provided by the ieee_exceptions intrinsic module: See here 正如弗拉基米尔(Vladimir)所指出的那样,所请求的功能由ieee_exceptions内部模块提供: 请参见此处

This is supported by Intel's ifort from at least version 12 on (tested) and presumably by gfortran from version 4.10 (not tested). 至少从第12版开始的Intel的ifort(已测试)以及从4.10版开始的gfortran(未经测试)都支持此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM