简体   繁体   English

尝试在地址处读取过去的文件结尾

[英]Attempt to read past end-of-file at address

writing a very simple read file in Fortran 95. The file has only three numbers in it, every time I run the code, the .exe file says " error: attempt to read end-of-file at address ", any clues why this keeps happening?在 Fortran 95 中编写一个非常简单的读取文件。该文件中只有三个数字,每次运行代码时,.exe 文件都会显示“ error: attempt to read end-of-file at address ”,任何线索不断发生?

The code is :代码是:

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

I have loaded your code into my Eclipse IDE, using GNU Fortran.我已使用 GNU Fortran 将您的代码加载到我的 Eclipse IDE 中。

I confirm that the code compiles, without error or warning, and runs as advertised.我确认代码可以编译,没有错误或警告,并按宣传的那样运行。

With an array.txt file of:使用 array.txt 文件:

1.00, 2.00, 3.00

I get output:我得到输出:

1.00, 2.00, 3.00

With an empty file I get:有了一个空文件,我得到:

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

So, my suspicion is over whether your file is missing some values.因此,我怀疑您的文件是否缺少某些值。

Please also see:另请参阅:

Fortran 90 - Attempt to read past end of file Fortran 90 - 尝试读取文件末尾

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM