fortran - .or 的遗留代码使用

标签 fortran

在较旧的 fortran 代码中,当 .or.与两种整数类型一起使用,结果是按位还是按操作数或 0/1?

我正在更新遗留代码,并相信我应该替换这些 .or. 的实例与 IOR ,但不确定这是否是旧代码中的预期结果。我应该将结果设置为 0 还是 1?

最佳答案

我相信您所看到的确实是一个自定义扩展。我以前从未见过使用过这个,但我确实在网上找到了关于实际存在于野外的此类事物的引用:

When Fortran programs communicate directly with digital hardware it may be necessary to carry out bit-wise logical operations on bit-patterns. Standard Fortran does not provide any direct way of doing this, since logical variables essentially only store one bit of information and integer variables can only be used for arithmetic. Many systems provide, as an extension, intrinsic functions to perform bit-wise operations on integers. The function names vary: typically they are IAND, IOR, ISHIFT. A few systems provide allow the normal logical operators such as .AND. and .OR. to be used with integer arguments: this is a much more radical extension and much less satisfactory, not only because it reduces portability, but also reduces the ability of the compiler to detect errors in normal arithmetic expressions.



Reference

关于fortran - .or 的遗留代码使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12206727/

相关文章:

fortran - 如何循环访问不同类型且名称仅尾随数字不同的变量

c - 在混合 fortran/C 程序中出现奇怪的崩溃

multithreading - LAPACK 例程线程安全吗?

c++ - 将 Fortran 用户定义类型转换为 C++ 类

types - 使用 % 运算符访问时,Fortran 类型变量为零

performance - 'recursive' 属性如何影响 FORTRAN90 子例程的性能

module - Fortran 模块中类型之间的循环依赖

fortran - MPI_Recv 覆盖不应访问的部分内存

intellij-idea - Intellij 插件 Fortran

arrays - float 在 Fortran 数组构造函数中造成问题