我试图编译以下内容,gfortran 和 ifort 都报告了语法错误:
module test
implicit real*8 (a-h,o-z)
allocatable, save :: A(:)
end module test
这是gfortran -c test.f90
输出:
allocatable, save :: A(:)
1
Error: Invalid character in name at (1)
和ifort -c test.f90
输出:
test.f90(3): error #5277: Syntax error, found ',' following statement keyword
allocatable, save :: A(:)
------------^
test.f90(3): error #5082: Syntax error, found '::' when expecting one of: ( , <END-OF-STATEMENT> ; [
allocatable, save :: A(:)
------------------^
compilation aborted for test.f90 (code 1)
但是,如果没有该save
属性,或者通过添加显式类型,它可以很好地编译:
module test
implicit real*8 (a-h,o-z)
allocatable :: A(:)
end module test
module test
implicit real*8 (a-h,o-z)
real*8, allocatable, save :: A(:)
end module test
由于两个编译器都报告了语法错误,我想知道这是否是一个错误,或者是否有人知道可能出了什么问题?