在 Fortran 95 中读取多个文件
我正在用 Fortran 95 编写代码,以读取许多类似于 1.dat、2.dat、......、9999.dat 的文件。我有一个代码,读取 0001.dat、0002.dat、....... 9999.dat。看起来
character*12, fn
..
DO i=1,n
write(fn,*)i
open(1,file=fn)
do j=1,5
read(1,*)x(i,j),y(i,j),z(i,j)
end do
10 format(i4.4,'.dat')
您可以建议我如何才能读取我拥有的文件吗?谢谢你
I am writing codes in Fortran 95, to read a number of files looking like 1.dat, 2.dat, ......, 9999.dat. I have a code that reads 0001.dat, 0002.dat, .......... 9999.dat. It looks like
character*12, fn
..
DO i=1,n
write(fn,*)i
open(1,file=fn)
do j=1,5
read(1,*)x(i,j),y(i,j),z(i,j)
end do
10 format(i4.4,'.dat')
May you suggest me how can I make it possible to read the files that I have please? Thanks.u
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你将格式更改为
我尝试过的格式,例如
,我的文件名中没有前导零,该怎么办?
这顶帽子是您要找的吗?
更新
我明白了...
那么格式应该是
“0”表示左对齐。
我用以下 pgm 测试了它
,这对我有用。
更新2
对我有用。
输出(在 Ubuntu 10.10 上)。
What if you change your format to
I tried this for instance
And I had no leading zeros in my file names.
Is this hat you were looking for ?
Update
I see...
Then the format should be
the '0' means left justified.
I tested it with the following pgm
And that worked for me.
Update 2
Worked for me.
Output (on Ubuntu 10.10).