作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个程序,该程序将在执行无效操作时停止,无论它是如何使用 GFortran 编译的。使用 ifort 我可以做这样的事情:
use ieee_exceptions
....
logical :: halt
....
call ieee_get_halting_mode(IEEE_USUAL,halt)
call ieee_set_halting_mode(IEEE_USUAL,.True.)
....
! Something that may stop the program
....
call ieee_set_halting_mode(IEEE_USUAL,halt)
ieee_exceptions
的模块? ?或者更好的是,有没有办法在不知道程序将如何编译或将使用哪个编译器的情况下停止暂停模式?
最佳答案
GFortran 从 GCC 5 版本开始支持 ieee_exceptions 模块。
如果您停留在较旧的 GFortran 版本上,一种解决方法是在 C/asm 中实现获取/设置 FP 捕获状态寄存器并从 Fortran 调用这些函数的函数。
PS.: GFortran 确实有一个开关 (-fpe-trap) 用于全局启用 FP 异常的陷阱,请参阅 http://gcc.gnu.org/onlinedocs/gfortran/Debugging-Options.html .但是,既然你明确地说“不管它是如何用 gfortran 编译的”,我想你不想使用它。
关于fortran - GFortran 等效于 ieee_exceptions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10541189/
我正在尝试编写一个程序,该程序将在执行无效操作时停止,无论它是如何使用 GFortran 编译的。使用 ifort 我可以做这样的事情: use ieee_exceptions .... logica
我是一名优秀的程序员,十分优秀!