Fortran读取语句不提供编译错误 [英] Fortran read statement gives no compilation error
问题描述
程序测试
字符(len)为什么gfortran在读取语句时不显示任何编译错误? = 2):: x
read x
end program
编译器不会发出错误,因为所有单独的行都是有效的,并且错误只能在运行时检测到。你可能会认为 read 会从某处读取数据并将其存储在
x
中,但这不是发生。声明
阅读x
符合Fortran 2008标准中的R910(cl 9.6.1)。具体而言, read-stmt 的一种可能性是:
阅读格式 input-item-list ]
符合 Why is gfortran not showing any compilation error for the read statement here?
The compiler does not issue an error because all individual lines are valid and the error can only be detected at runtime. You may think that matches R910 in the Fortran 2008 standard (cl 9.6.1). Specifically, one possibility of read-stmt is: READ format [, input-item-list] which will match
这篇关于Fortran读取语句不提供编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!读取x
,将
$ p $ 在文件read.f90的第3行(单元= 5,file ='stdin')
Fortran运行时错误:格式为
的初始左括号丢失program test
character(len=2) :: x
read x
end program
read
is going to read data from somewhere and store it in x
, but that is not what is happening. The statementread x
read x
, interpreting x
as a format. You can confirm this by running your program, which produces the runtime error:At line 3 of file read.f90 (unit = 5, file = 'stdin')
Fortran runtime error: Missing initial left parenthesis in format