我買了這個共同的煩惱:Fortran派生類型的公共:初始化?
COMMON /REDCOM/ DPREC,NITMA,INDIC,NBERR,NCAR,KMOTLU,
& REDVAR,MOCDER(2)
COMMON /REDCO1/ CTEXT
C
type(double_st) :: DPREC
INTEGER :: NITMA,INDIC,NBERR,NCAR,KMOTLU,REDVAR,MOCDER
CHARACTER(72) :: CTEXT
CHARACTER(4) :: CTEXT4
C
EQUIVALENCE (CTEXT,CTEXT4)
的double_st
派生類型是:
type double_st
sequence
real(kind(0.d0)) :: x,y,z
integer :: acc = -1
end type double_st
試圖編譯一些代碼,包括這個共同的,我得到:
ifort:
./REDCOM.INC(1): error #6005: A derived type object in a COMMON block shall not have default initialization [DPREC]
COMMON /REDCOM/ DPREC,NITMA,INDIC,NBERR,NCAR,KMOTLU,
----------------------^
gfortran:
REDCOM.INC:1.27:
Included at m_abaq4.f:90:
COMMON /REDCOM/ DPREC,NITMA,INDIC,NBERR,NCAR,KMOTLU,
1
Error: Derived type variable 'dprec' in COMMON at (1) may not have default initializer
對Fortran不太瞭解,我不明白問題是什麼,或者如何解決它(我嘗試了谷歌搜索沒有成功)。如果我使用REAL(8)
而不是double_st
,則一切正常。
有人可以幫助我嗎?
事實上,它只適用於ifort,它仍然失敗,gfortran ... – janou195
@ janou195它究竟打印什麼?代碼的外觀如何? –
錯誤消息仍然與我的問題相同。你指的是哪個代碼? – janou195