我試圖編譯我的程序與英特爾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