# Fortran 77

**Fortran 77** 是 Fortran 编程语言的一个标准化版本，正式名称为《美国国家标准编程语言 Fortran，X3.9-1978》，因开发工作于 1977 年完成而通常称为 Fortran 77。它取代了此前的 Fortran 标准 ANSI X3.9-1966，于 1978 年在美国获批，并以 ISO 1539:1980 获得国际批准。<sup>[1](https://www.mendeley.com/catalogue/f9cb0a60-acca-3236-9eec-9aa68ddf35f3/)</sup><sup> • </sup><sup>[2](https://jtc1info.org/sd-2-history/jtc1-subcommittees/sc-22/)</sup> Fortran 77 在此后十多年间一直是占主导地位的 Fortran 方言，大量用它编写的科学软件至今仍在编译和维护。

| 关键事实 | 详情 |
|---|---|
| 正式名称 | ANSI X3.9-1978；1977 年完成开发，1978 年发布<sup>[1](https://www.mendeley.com/catalogue/f9cb0a60-acca-3236-9eec-9aa68ddf35f3/)</sup> |
| 国际地位 | 以 ISO 1539:1980 采纳；1991 年被 Fortran 90 取代后撤销<sup>[2](https://jtc1info.org/sd-2-history/jtc1-subcommittees/sc-22/)</sup><sup> • </sup><sup>[3](https://www.iso.org/standard/6127.html)</sup> |
| 相对 Fortran 66 的主要增补 | 块 IF/ELSE IF/ELSE/END IF、CHARACTER 数据类型、OPEN/CLOSE/INQUIRE、直接访问 I/O、PARAMETER、SAVE、IMPLICIT、循环次数为零的 DO 循环<sup>[4](https://flang.llvm.org/docs/FortranFeatureHistory.html)</sup> |
| 源格式 | 仅固定格式：语句标号位于第 1 至 5 列，续行标记位于第 6 列，语句位于第 7 至 72 列<sup>[5](https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6l/index.html)</sup> |
| 兼容性 | 符合标准的 FORTRAN 77 程序在 Fortran 90 下同样符合标准<sup>[6](https://wg5-fortran.org/N001-N1100/N692.pdf)</sup> |
| 知名软件 | 广泛使用的线性代数库 LAPACK 完全以标准 FORTRAN 77 编写<sup>[7](https://www2.math.utah.edu/software/lapack/)</sup> |
| 现代编译 | GNU Fortran 可编译 Fortran 77 代码；`-std=legacy` 接受旧的非标准程序<sup>[8](https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html)</sup> |

## 开发与标准化

Fortran 是第一种被标准化的编程语言。1966 年的标准 ANSI X3.9-1966 实质上是各厂商所提供功能的公共子集，该标准发布后，编译器厂商引入了大量扩展。ANSI 委员会 X3J3 开始修订标准，由此产生的文件定名为 X3.9-1978，于 1978 年在美国获批，1980 年获 ISO 批准。<sup>[2](https://jtc1info.org/sd-2-history/jtc1-subcommittees/sc-22/)</sup><sup> • </sup><sup>[4](https://flang.llvm.org/docs/FortranFeatureHistory.html)</sup> 沃尔特·布雷纳德（Walter Brainerd）1978 年在《ACM 通讯》（*Communications of the ACM*）上发表的文章介绍了新标准的特性及其制定过程。<sup>[1](https://www.mendeley.com/catalogue/f9cb0a60-acca-3236-9eec-9aa68ddf35f3/)</sup>

该标准自己申明的准则是最小化与 1966 年标准的冲突：只有为纠正上一标准中的错误或为语言增添显著能力时，才允许做出破坏 Fortran 66 程序的改动。<sup>[9](https://wg5-fortran.org/ARCHIVE/Fortran77.html)</sup> 1978 年标准还在完整语言之外定义了一个子集语言，这一结构后来被后续标准放弃；Fortran 90 未规定任何子集。<sup>[9](https://wg5-fortran.org/ARCHIVE/Fortran77.html)</sup><sup> • </sup><sup>[6](https://wg5-fortran.org/N001-N1100/N692.pdf)</sup>

## 语言特性

Fortran 77 为一种此前依赖算术 IF 和 GO TO 语句的语言增添了结构化控制流。块 IF 构造写作 `IF (e) THEN`，可带 `ELSE IF` 和 `ELSE` 子句，以 `END IF` 结束，为该语言提供了主要的结构化分支机制。<sup>[4](https://flang.llvm.org/docs/FortranFeatureHistory.html)</sup><sup> • </sup><sup>[9](https://wg5-fortran.org/ARCHIVE/Fortran77.html)</sup> DO 循环有所改变：当循环次数为零时，循环体执行零次，取代了 Fortran 66 至少执行一次的行为。<sup>[10](https://www.deepdyve.com/browse/journals/1061-7264/1982/v1/i1?rows=10&start=0)</sup>

CHARACTER 数据类型是最大的增补之一。它以定长字符串取代了霍列瑞斯常量（新标准删除了后者），并扩展了字符输入、输出和处理的设施。<sup>[4](https://flang.llvm.org/docs/FortranFeatureHistory.html)</sup><sup> • </sup><sup>[9](https://wg5-fortran.org/ARCHIVE/Fortran77.html)</sup> 字符长度说明跟在类型语句之后，如 `CHARACTER S*80`，未指定长度时默认为 1。<sup>[11](https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub69-1.pdf)</sup>

其他增补包括 IMPLICIT、PARAMETER 和 SAVE 语句；OPEN、CLOSE 和 INQUIRE 语句；直接访问输入输出；非 1 的数组维下界；通用内部函数名；以及按字典序进行的字符串比较。<sup>[4](https://flang.llvm.org/docs/FortranFeatureHistory.html)</sup> [递归](https://www.edgepedia.org/zh/recursion)不属于该标准的一部分，尽管一些编译器将其作为非标准选项提供。<sup>[4](https://flang.llvm.org/docs/FortranFeatureHistory.html)</sup>

## 源格式

Fortran 77 程序使用固定格式源，这种布局继承自穿孔卡片。前五列存放语句标号或空白，第 6 列存放续行标记（除零或空白外的任意字符），语句占据第 7 至 72 列；默认情况下第 72 列之后的字符被忽略。<sup>[5](https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6l/index.html)</sup> 第 1 列为 `C`、`*` 或类似字符的行是注释行，短行会补齐至 72 个字符。<sup>[5](https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6l/index.html)</sup> 编译器通常接受制表符格式及标准之外的其他扩展。<sup>[5](https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6l/index.html)</sup><sup> • </sup><sup>[12](https://support.nag.com/nagware/np/r72_doc/manual/compiler_5_2.html)</sup>

1978 年发布的美国军用标准 MIL-STD-1753 规定了 FORTRAN 77 的扩展，这些扩展得到广泛使用：DO WHILE 和 DO/END DO 构造、INCLUDE 语句、IMPLICIT NONE，以及 IAND、IOR、ISHFT 等位操作内部函数。<sup>[13](https://wg5-fortran.org/fearlier.html)</sup><sup> • </sup><sup>[4](https://flang.llvm.org/docs/FortranFeatureHistory.html)</sup>

## 后继版本与过时

Fortran 90 以 ISO/IEC 1539:1991 发布，完整包含了 FORTRAN 77 的语法和语义（有已知限制），因此任何符合标准的 FORTRAN 77 程序在 Fortran 90 下都符合标准。<sup>[6](https://wg5-fortran.org/N001-N1100/N692.pdf)</sup> Fortran 90 将若干 FORTRAN 77 特性列为过时，即冗余但仍在频繁使用：算术 IF 语句、带实数索引的 DO 循环、赋值 GO TO 和赋值格式、分支到 END IF 语句、备用 RETURN、PAUSE 语句以及 H 编辑描述符。<sup>[14](https://heasarc.gsfc.nasa.gov/docs/journal/ogip_fortran3.html)</sup> 后来的标准更进一步；算术 IF 和非块形式的 DO 构造在 Fortran 2018 中被删除。<sup>[15](https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/deleted-and-obsolescent-language-features.html)</sup>

现代编译器仍然接受该方言。[GNU Fortran](https://www.edgepedia.org/zh/gnu-fortran) 实现 Fortran 95，可编译基本上所有符合标准的 Fortran 77 程序；其 `-std=legacy` 选项接受旧的非标准程序，且不对过时扩展发出警告，而严格标准模式会对后续标准中已过时的 Fortran 77 特性发出警告。<sup>[8](https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html)</sup><sup> • </sup><sup>[16](https://gcc.gnu.org/onlinedocs/gfortran/Standards.html)</sup> Oracle 的 Fortran 95 编译器同样可编译大多数遗留 FORTRAN 77 程序，包括使用非标准扩展的程序，其余程序则通过兼容模式处理。<sup>[17](https://docs.oracle.com/cd/E19422-01/819-3686/5_f77.html)</sup>

## 遗留代码与现代化

大量用 Fortran 77 编写的科学软件仍在使用，其中许多并不严格符合标准，因为它们依赖编译器扩展。<sup>[18](https://arxiv.org/abs/2309.02019)</sup> [加州理工学院](https://www.edgepedia.org/zh/california-institute-of-technology)的维克托·德奇克（Viktor Decyk）和查尔斯·诺顿（Charles Norton）开发了一种逐步现代化 Fortran 77 遗留代码的方法，于 2003 年作为 NASA 技术简报发表，既保留了经过验证的遗留软件投资，又增添了现代能力，既可本身作为目的，也可作为全面重写的过渡。<sup>[19](https://ntrs.nasa.gov/citations/20110023890)</sup>

工业迁移项目仍在继续。与核能公司[法马通](https://www.edgepedia.org/zh/framatome)（Framatome）的合作使用岛屿文法解析带有专有 Esope 扩展的 Fortran 77 代码，以构建抽象语法树，后续工作通过模型变换将 Esope 源代码转换为 Fortran 2008。<sup>[18](https://arxiv.org/abs/2309.02019)</sup><sup> • </sup><sup>[20](https://arxiv.org/abs/2601.21755)</sup> StmtTree 等工具包旨在以编程方式解析和转换遗留 Fortran 77 代码。<sup>[21](https://arxiv.org/abs/2407.05652)</sup>

Fortran 77 也仍是核心数值库的基础。LAPACK 是高性能计算机上线性代数的标准库，完全以标准 FORTRAN 77 编写，可在任何支持该标准的机器上不加修改地运行；LAPACK95 后来为其提供了 Fortran 95 接口。<sup>[7](https://www2.math.utah.edu/software/lapack/)</sup><sup> • </sup><sup>[22](https://netlib.sandia.gov/lapack95/lug95/node4.html)</sup>

## References

1. [Brainerd, W. (1978). Fortran 77. Communications of the ACM 21(10), 806–820.](https://www.mendeley.com/catalogue/f9cb0a60-acca-3236-9eec-9aa68ddf35f3/)
2. [SC 22 history, ISO/IEC JTC 1](https://jtc1info.org/sd-2-history/jtc1-subcommittees/sc-22/)
3. [ISO 1539:1980, Programming languages — FORTRAN](https://www.iso.org/standard/6127.html)
4. [A Fortran feature history cheat sheet, The Flang Compiler](https://flang.llvm.org/docs/FortranFeatureHistory.html)
5. [Source Line Formats, FORTRAN 77 Language Reference, Oracle](https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vn6l/index.html)
6. [Fortran 90 final draft, ISO/IEC 1539:1991 (N692), WG5](https://wg5-fortran.org/N001-N1100/N692.pdf)
7. [LAPACK general information, University of Utah](https://www2.math.utah.edu/software/lapack/)
8. [Fortran Dialect Options, The GNU Fortran Compiler](https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html)
9. [FORTRAN 77 Standard text, ANSI X3.9-1978, WG5 archive](https://wg5-fortran.org/ARCHIVE/Fortran77.html)
10. [ACM SIGPLAN Fortran Forum, 1982, DeepDyve](https://www.deepdyve.com/browse/journals/1061-7264/1982/v1/i1?rows=10&start=0)
11. [FIPS PUB 69-1, Programming Language FORTRAN, NIST](https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub69-1.pdf)
12. [Obsolete Extensions, NAG Fortran Compiler Release 7.2](https://support.nag.com/nagware/np/r72_doc/manual/compiler_5_2.html)
13. [Earlier Fortran Standards, WG5](https://wg5-fortran.org/fearlier.html)
14. [OGIP Fortran programming standards, NASA HEASARC](https://heasarc.gsfc.nasa.gov/docs/journal/ogip_fortran3.html)
15. [Deleted and Obsolescent Language Features, Intel Fortran Compiler](https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/deleted-and-obsolescent-language-features.html)
16. [Standards, The GNU Fortran Compiler](https://gcc.gnu.org/onlinedocs/gfortran/Standards.html)
17. [FORTRAN 77 Compatibility: Migrating to Fortran 95, Oracle](https://docs.oracle.com/cd/E19422-01/819-3686/5_f77.html)
18. [Parsing Fortran-77 with proprietary extensions, arXiv:2309.02019](https://arxiv.org/abs/2309.02019)
19. [Modernizing Fortran 77 Legacy Codes, NASA NTRS 20110023890](https://ntrs.nasa.gov/citations/20110023890)
20. [Migrating Esope to Fortran 2008 using model transformations, arXiv:2601.21755](https://arxiv.org/abs/2601.21755)
21. [StmtTree: An Easy-to-Use yet Versatile Fortran Transformation Toolkit, arXiv:2407.05652](https://arxiv.org/abs/2407.05652)
22. [LAPACK95 Users' Guide preface, netlib](https://netlib.sandia.gov/lapack95/lug95/node4.html)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Programming languages › Individual programming languages › C-family and imperative languages

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/fortran-77

English original: https://www.edgepedia.org/fortran-77
