将 sun studio 兼容的 fortran 77 移植到 gcc:READ、FORMAT 中的格式说明符
我有一些旧的 Fortran 77,我正在尝试将其移植到 Windows 上的 gcc。
我正在使用 gfortran 4.4。
该语句使用 READ(FOO, '(F)' , ERR=BAR) BAZ 并且 gcc 正在抱怨 F。从我所看到的看来,F 需要一个与之关联的大小。还有使用类似结构的 FORMAT 语句。
移植这个的正确方法是什么?似乎在 sun studio 编译器上单独使用 F 就适合合适的大小。但 gfortran 抱怨它不是非负或正宽度。
有什么想法如何移植这个吗?
I have some old fortran 77 I'm trying to port to gcc on Windows.
I'm using gfortran 4.4.
The statement uses READ(FOO, '(F)' , ERR=BAR) BAZ and gcc is complaining about F. From what I've seen it looks like F needs a size associated with it. There are also FORMAT statements which use a similar construct.
What is the proper way to port this? It seems like using F alone on sun studio compilers just fits to the proper size. But gfortran complains about it not being a non-negative or positive width.
Any ideas how to port this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是格式化的读取。它应该是 READ(FOO, '(FN.M)' , ERR=BAR) BAZ、N 和 M 特定数字,其中 N 是字符字段宽度,M 是小数点后的位数。输入 M 时数据是否有小数点并不重要,因为小数点将覆盖格式规范。如果您不确定输入数据是否始终符合此严格规范,最好切换到无格式输入:READ(FOO, * , ERR=BAR) BAZ。这也称为列表定向 I/O。这是非常灵活和猜测的,可能更好地匹配扩展“F”所做的事情。 (无格式/列表定向与无格式不同,无格式适用于没有任何位转换的二进制文件。)
This is a formatted read. It should be READ(FOO, '(FN.M)' , ERR=BAR) BAZ, N and M specific numbers, where N is the field width in characters and M is the number of digits after the decimal point. On input M doesn't matter if the data has a decimal point, because the decimal point will override the format specification. If you aren't sure that the input data will always fit within this strict specification, it is probably better to switch to format-free input: READ(FOO, * , ERR=BAR) BAZ. This is also called list-directed i/o. This is very flexible and guessing, probably better matches what the extension "F" was doing. (format-free / list-directed is different from unformatted, which is for binary files without any conversion of the bits.)