Read*,*原因单位= 5,文件='stdin'Fortran运行时错误:文件结尾

问题描述

我正在尝试在Fortran 90中创建一个小的代码段以读取用户文件名,我知道它应该很简单,但是我无法弄清楚我在做什么错。 / p>

脚本为:

program test
  implicit none
  Character (Len = 15) :: filename

  Write(*,*) 'Input file name'
  Read(*,*) filename
  Write(*,*) 'So the file is called',filename
end program test

然后我使用gfortran在ubuntu系统上编译它:

$ gfortran test.f90 -o test.exe

它可以正常编译,但是当我运行./test.exe时,会得到以下输出

$ ./test.exe 
Input file name 
At line 6 of file test.f90 (unit = 5,file = 'stdin') 
Fortran runtime error: End of file 

Error termination. Backtrace:
#0  0x7f435e83b32a 

当我期望得到的是:

$ ./test.exe 
Input file name 
[program pauses while user inputs text] 
So the file is called [text the user inputted]

我似乎找不到该错误的示例或如何在线修复它。有人可以告诉我我要去哪里了吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)