我正在学习Fortran,目前正在fortrantutorials.com上进行练习。我必须运行下面的代码:Fortran文件错误结束
program magic
implicit none
real, dimension(100) :: a,b,c,d
open(10, file='data.txt')
read(10,*) a
b = a*10
c = b-a
d = 1
print*, 'a = ', a
print*, 'b = ', b
print*, 'c = ', c
print*, 'd = ', d
end program magic
它读取以下的data.txt文件:
24
45
67
89
12
99
33
68
37
11
当我运行它,它显示了这个错误:
At line 6 of file test.f95 (unit = 10, file = 'data.txt')
Fortran runtime error: End of file
[Finished in 0.0s with exit code 2]
6号线指的是以下行,并且我已经双重检查'data.txt'和我的fortran文件确实在同一个目录中:
read(10,*) a
我能做些什么来解决这个问题?提前致谢。
data.txt是否有(至少)100行? – francescalus