主题:怎么读数列文件谢谢
dingsheng1206
[专家分:0] 发布于 2010-09-18 10:21:00
请问我怎么读取数列文件呢,比如,我想读一纵列数列a.txt
1
2
3
4
5
再把它复制到另一文件b.txt中,并使它显示在屏幕上,我写的程序是这样的,可是报错,请高手指教啊,谢谢哦
program xvelocity
open(1,file="E:\a.txt")
open(2,file="E:\b.txt")
do while(.not.eof(1))
do i=1,5
read(1,'(i10)')a(i)
write(2,'(i10)')a(i)
enddo
enddo
rewind(1)
do while(.not.eof(1))
do i=1,5
read(1,'(i10)')a(i)
write(*,*)a(i)
enddo
enddo
end
回复列表 (共3个回复)
沙发
asymptotic [专家分:16630] 发布于 2010-09-18 12:18:00
!. the Fortran 2003 Standard does not allow EOF intrinsic procedure, replace it with barnching specifier read(unit = *, fmt = *, end = label)
2. the DO-Construct with an iteration count must be omitted
i = 1
do while (.true.)
read(unit = input_unit, fmt = *, end = 80) IA(i)
i = i + 1
end do !
80 close(unit = input_unit)
板凳
dingsheng1206 [专家分:0] 发布于 2010-09-18 13:47:00
[quote]!. the Fortran 2003 Standard does not allow EOF intrinsic procedure, replace it with barnching specifier read(unit = *, fmt = *, end = label)
2. the DO-Construct with an iteration count must be omitted
i = 1
do while (.true.)
read(unit = input_unit, fmt = *, end = 80) IA(i)
i = i + 1
end do !
80 close(unit = input_unit)[/quote]
不懂你什么意思啊,
但是如果我只读一个变量,比如,文件A中只有一个数1也可以用EOF,而且我试过,结果可以复制到B文件上,谢谢你,
3 楼
dingsheng1206 [专家分:0] 发布于 2010-09-18 14:51:00
[quote]!. the Fortran 2003 Standard does not allow EOF intrinsic procedure, replace it with barnching specifier read(unit = *, fmt = *, end = label)
2. the DO-Construct with an iteration count must be omitted
i = 1
do while (.true.)
read(unit = input_unit, fmt = *, end = 80) IA(i)
i = i + 1
end do !
80 close(unit = input_unit)[/quote]
谢谢,我懂了,
我来回复