尝试读取文件的末尾地址

问题描述 投票:0回答:1

在Fortran 95中编写一个非常简单的读取文件。该文件中只有三个数字,每当我运行代码时,.exe文件都会显示“ error: attempt to read end-of-file at address”,这是为什么继续发生的任何线索?

代码是:

program readdata

implicit none

!Delcaration of variables

real :: x,y,z

!Main part

open (10, file='C:\Users\matth\OneDrive\Documents\Tutorialcode\array.txt',ACCESS='SEQUENTIAL', STATUS='OLD', FORM='FORMATTED')

read (10, *) x, y, z

print *,x,y,z

close (10)

end program readdata
formatting fortran unexpectendoffile
1个回答
0
投票

我已使用GNU Fortran将您的代码加载到Eclipse IDE中。

我确认代码已编译,没有错误或警告,并按公告运行。

带有一个array.txt文件:

1.00, 2.00, 3.00

我得到输出:

1.00, 2.00, 3.00

我得到一个空文件:

At line 13 of file ../readdata.f90 (unit = 10, file = 'C:\Users\franc\array.txt')
Fortran runtime error: End of file

Error termination. Backtrace:

Could not print backtrace: libbacktrace could not find executable to open
#0  0xffffffff
#1  0xffffffff
#2  0xffffffff
#3  0xffffffff
#4  0xffffffff
#5  0xffffffff
#6  0xffffffff
#7  0xffffffff
#8  0xffffffff
#9  0xffffffff
#10  0xffffffff
#11  0xffffffff
#12  0xffffffff
#13  0xffffffff
#14  0xffffffff

所以,我怀疑您的文件是否缺少某些值。

也请参见:

Fortran 90 - Attempt to read past end of file

© www.soinside.com 2019 - 2024. All rights reserved.