fortran - 在 Fortran 中,停止内在函数是否期望在标准输出中打印 'STOP'?

标签 fortran gfortran

我经常在 Fortran 中使用 stop 内在函数来因各种原因停止执行(主要是在测试失败后)。

program test1
    stop
end program

除了停止程序执行之外不执行任何操作。

program test2
    stop 'hello'
end program

在标准输出中打印:

STOP hello

我以前从未注意到这种行为。输出中的“hello”之前是否应该出现“STOP”?或者是编译器错误还是......?

我的编译器是gfortran --version:

GNU Fortran (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)
Copyright (C) 2012 Free Software Foundation, Inc.

最佳答案

这不是一个错误。 Fortran 标准指定由 Fortran 处理器决定如何“使停止代码可用”。它建议对错误单元使用格式化输出,但格式(一般意义上)可以是编译器作者认为最好的任何格式。

关于fortran - 在 Fortran 中,停止内在函数是否期望在标准输出中打印 'STOP'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16057205/

相关文章:

memory-leaks - 根据优化级别导致内存泄漏的延迟长度字符变量

fortran - "PROCEDURE attribute conflicts with INTENT attribute"使用模块编译简单的 Fortran 程序时

c - Fortran/C 中间语言问题 : results differ in the 14th digit

fortran - 错误: Non-numeric character in statement at label (1)

Fortran 存储连接字符串

fortran - Fortran 95 : 中的数值精度

python - 使用 F2PY 在多个扩展模块之间共享 Fortran 90 模块数据

gcc - 错误 : Invalid character in name at (1)

Fortran 95 : super large numbers for prime test