Fortran:一次从一行读取一个值
我正在使用 FORTRAN 从 ASCII 文本文件中读取数据。该文件每行包含多个数据值,但每行值的数量不是恒定的。
101.5 201.6 21.4 2145.5
45.6 21.2
478.5
...
通常,在读语句之后,Fortran 会转到下一行。我想要做的是一次读取一个数据值。如果它到达行尾,它应该继续阅读下一行。这可能吗?
I am using FORTRAN to read in data from an ASCII text file. The file contains multiple data values per line but the number of values per line is not constant.
101.5 201.6 21.4 2145.5
45.6 21.2
478.5
...
Normally after a read statement, Fortran would go to the next line. What I want to be able to do is read one data value at a time. If it hits the end of the line, it should just continue reading on the next line. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 IRO-bot 在对您的问题的评论中指出的那样,MSB 已经给出了答案,下面我仅提供了一些说明该答案的代码(因为 MSB 的帖子不包含任何代码):
使用您提供的示例行运行此程序时输出是
我希望你会发现这有帮助。
As pointed out by IRO-bot in their comment to your question, the answer has already been given by M.S.B. Below I have merely provided some code illustrating that answer (as M.S.B.'s post contained none):
When running this program using the sample lines you provided the output is
I hope you will find this helpful.