Fortran IO 文件

Fortran IO files

我正在用fortran写一些IO程序。

我对格式化、未格式化、顺序和直接感到有点困惑。

据我了解,格式化文件是人类可读的(普通 txt 文件),而未格式化的文件是机器可读的。

对于未格式化的文件,我可以使用顺序访问或直接访问。

我可以直接访问格式化文件吗?

是的,您可以直接访问格式化文件。

来自 Fortran 2008 标准,Cl。 9.3.3.3 "Direct access":

2 When connected for direct access, an external file has the following properties.

  • [...]

  • The records of the file are either all formatted or all unformatted. If the sequential access method is also a member of the set of allowed access methods for the file, its endfile record, if any, is not considered to be part of the file while it is connected for direct access. If the sequential access method is not a member of the set of allowed access methods for the file, the file shall not contain an endfile record.