Fortran - 旧(1972)代码中的两分支 IF 语句

发布于 2024-10-13 17:49:47 字数 260 浏览 0 评论 0原文

问候。有谁知道这个 Fortran IF 语句是做什么的?

IF(IJJ-2) ,409,411

我不认为这是一个拼写错误,因为同一程序中还有其他一些错误。我认为这是一个标准算术 IF,只是将“小于 0”分支默认为下一个 executbale 语句,但我对此不确定。我认为这段代码是在 1970-1972 年左右托管在 CDC 6600 上的。我查看了 FORTRAN 77 子集标准,但它指定必须提供所有三个语句标签。非常感谢任何建议。

Greetings. Does anyone know what this Fortran IF statement is doing?

IF(IJJ-2) ,409,411

I don't think it's a typo because there are a few other in the same program. I assumed it was a standard arithmetic IF that simply defaulted the "less than 0" branch to the next exectutbale statement, but I'm not sure about that. I think this code was hosted on a CDC 6600 around 1970-1972. I looked through the FORTRAN 77 subset standard but it specifies all three statement lables must be supplied. Any advice is most appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

烟雨扶苏 2024-10-20 17:49:47

它称为算术 IF 语句,在 Fortran 90 和 95 中已过时。但是,我知道英特尔 Fortran 编译器仍然支持它。如果括号内的表达式小于零,则执行转移到第一个标签。如果等于零,则转移到第二个标签,最后,如果大于零,则转移到第三个标签。我不确定如果标签丢失会发生什么 - 我假设它只是失败了。

因此,您的 IF 语句将转换为现代 Fortran 语言:

IF (IJJ == 2) THEN
    GOTO 409
ELSEIF (IJJ > 2) THEN
    GOTO 411
ENDIF

It's called an arithmetic IF statement and is obsolete in Fortran 90 and 95. However, I know the Intel Fortran Compiler still supports it. If the expression within the parentheses is less than zero then execution transfers to the first label. If equal to zero then the second label, and finally if greater than zero it transfers to the third label. I'm not sure what happens in the case of a missing label - I'm assuming it just falls through.

So your IF statement would translate into modern Fortran as:

IF (IJJ == 2) THEN
    GOTO 409
ELSEIF (IJJ > 2) THEN
    GOTO 411
ENDIF
别理我 2024-10-20 17:49:47

我认为目标行号小于、等于和大于零。
这看起来不像标准的 Fortran,但猜测缺失的行号会
跳至下一条语句。

I think the destination line numbers were for less than, equal to, and greater than zero.
This doesn't look like standard fortran, but at a guess the missing line numbers will
drop through to the next statement.

_畞蕅 2024-10-20 17:49:47

这绝对是非标准的 Fortran。我查了一下,Intel 和 GFortran 编译器都不接受它。 F90 之前的许多 Fortran 编译器都有非标准扩展。我记得DEC编译器有很多扩展。还以此为卖点!它还有助于确保客户忠诚度,因为使用这些扩展的代码无法移植到其他编译器。最好的选择是,如果您能找到编译器附带的手册,它应该记录这一点。祝你好运!

作为一个历史旁注,我记得有人告诉我,当时的一些公司非常嫉妒他们的地盘,以及他们的非标准扩展给他们带来的优势,以至于他们故意阻碍标准进程以推迟 Fortran 的下一个版本(最终被称为F90)。这使得其他语言获得了主导地位,并加速了 Fortran 的衰落。

This is definitely non-standard Fortran. I checked and both the Intel and GFortran compilers will not accept it. Many Fortran compilers back before F90 had non-standard extensions. I remember that the DEC compiler had many extensions. And this was used a selling point! It also helped ensure customer loyalty since code that used these extensions could not be ported to another compilers. Your best bet is if you can find the manual that came with the compiler it should document this. Good Luck!

As an historical side note, I remember being told that some of the companies back then were so jealous of their turf, and the advantage that their non-standard extensions gave them, that they purposely hindered the standards process to delay the next version of Fortran (which was eventually called F90). This allowed other languages to gain dominance and hastened the downfall of Fortran.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文