简体   繁体   English

Fortran错误:读取名称列表中的字符时出现“文件结尾”错误

[英]Fortran error: “end of file” while reading character in namelist

I am writing a Fortran application, and I get this problem. 我正在编写一个Fortran应用程序,但出现此问题。 When I define a namelist as following: 当我如下定义名称列表时:

CHARACTER(100) :: INPUT_DIR, OUTPUT_DIR, ROOT_DIR    
NAMELIST /IODIR/ INPUT_DIR, OUTPUT_DIR

and then I read IODIR from file as: 然后我从文件中读取IODIR为:

READ(FUNIT,IODIR, ERR=99)

The data in file is: 文件中的数据为:

&IODIR INPUT_DIR="Input", OUTPUT_DIR="Output" /

But it get error 但是会出错

"End of file". “文件结束”。

It seems like the length of variables is longer than their defined in file. 变量的长度似乎比文件中定义的长度长。 I don't know how to set delimiter for the character variable, or read an unknown character in namelist. 我不知道如何为字符变量设置定界符,或在名称列表中读取未知字符。 I use GNU Fortran to build. 我使用GNU Fortran进行构建。

I had the same problem with the online gfortan compiler, same result from an installed version. 我对在线gfortan编译器有相同的问题,从安装的版本得到的结果相同。 This problem is all over the web, so on the basis of using reliable sources I: Installed gfortran in Windows 10 Bash - all good. 这个问题遍布整个网络,因此,在使用可靠来源的基础上,我:在Windows 10 Bash中安装了gfortran-都不错。 Installed gfortran in Cygwin - all good. 在Cygwin中安装了gfortran-一切都很好。

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

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