我试图编译我的程序与英特尔Fortran编译器Linux(版本12.0.3)和我得到这个错误:Fortran编译错误
buggy.f90(206): error #6219: A specification expression object must be a dummy
argument, a COMMON block object, or an object accessible through host or use
association [SPECTRUM]
type(spect) :: spectrum
----------------------------------------^
这是一个模块内。 type(spect)
来自另一个模块,其中我use
在一开始的麻烦模块。这是一些代码;更多细节可以在下面找到。
module non_buggy
implicit none
type axis
character(len=6) :: nucleus
integer :: num_data_points
real :: spectral_width
end type axis
type spect
integer :: num_dim
type(axis), allocatable :: axes(:)
real, allocatable :: intensity(:)
character(len=10) :: type = ''
end type spect
type(spect), target :: spectrum ! might this be a cause of error?
contains
! ...
end module non_buggy
module buggy
use non_buggy
implicit none
contains
subroutine no_problem_here()
type(spect) :: spectrum ! compiles beautifully
! ...
end subroutine no_problem_here
subroutine problem()
type(spect) :: spectrum ! does not compile, but no error if I change the variable name
! ...
end subroutine problem
end module buggy
我看了一下是什么错误意味着,但我有什么,我在我的代码正在做的,不适用的印象 - 没有数组边界是在这些线路中指定。由于错误消失了,如果我将第二次出现的spectrum
重命名为其他内容,我想知道该问题是否与模块non_buggy
中的模块变量spectrum
有关(但是,即使我注释掉该行,错误仍然存在其中声明了模块变量)。如果Fortran专家能够澄清这个问题,我将非常感激。
非常感谢!
该错误是在别的地方。我甚至尝试编译你的模块。但我相信问题的根源在别的地方。因为你分享代码的和平没有任何问题。如果可能,请更多代码。 – Wildcat
@kemiisto你是对的!我发现这个问题,它在编译器指出的线下面三行。我确实在数组边界声明中使用了'频谱'的一部分 - 当然,编译时没有指定大小... – canavanin