简体   繁体   English

Fortran运行时错误:读取输入数据时文件结束

[英]Fortran runtime error: End of file when reading input data

I'm currently running a code and I'm always getting to the same end. 我目前正在运行代码,而且我总是要达到同一个目的。 I am trying to read an input file and it returns the error: 我正在尝试读取输入文件,它返回错误:

Fortran runtime error: End of file Fortran运行时错误:文件结尾

In an other post they said to put in the iostat specifier so now my code looks like this: 在另一篇文章中,他们说要放入iostat说明符,所以现在我的代码如下:

INTEGER    :: m
INTEGER    :: st

Open(Unit = 13,action='read',file='Data_Inp.dat',status='old')
read (13,*, iostat = st) m
write (*,*) st
write (*,*) m

ALLOCATE(winkel(m),energie(m))

Do i = 1,m
  read(13,*),winkel(i),energie(i)
End Do

And the input file looks like this: 输入文件如下所示:

12
-17.83 -0.019386527878
-15.83 -0.020125057233
-12.83 -0.020653853148
-11.83 -0.020840036028
-9.83 -0.020974157405
-8.83 -0.021056401707
-6.83 -0.021065517811
-5.83 -0.020992571816
-4.83 -0.020867828448
-1.83 -0.02069158012

Now the terminal prints a -1 for iostat and a constantly changing number for m. 现在,终端将为iostat打印-1,并为m打印一个不断变化的数字。

如果第一个读取命令引起错误,请检查输入文件中“ 12”之前或之后的多余字符,尤其是在一个平台(Windows?)上创建并在另一个平台(Linux?Mac?)上使用的情况下。

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

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