我有一個看起來像這樣的功能:宣言和局部變量初始化Fortran中純函數
PURE FUNCTION simulate(initial_state, time_specification)
TYPE(ocean), INTENT(IN) :: initial_state
TYPE(simulation_time), INTENT(IN) :: time_specification
TYPE(ocean) :: simulate
REAL :: t = 0.0
! etc
END FUNCTION simulate
gfortran 4.8.1告訴我,
REAL :: t = 0.0
1
Error: Initialization of variable at (1) is not allowed in a PURE procedure
據我瞭解,我應該只要它們沒有SAVE屬性,就可以在純函數中使用局部變量。那麼我做錯了什麼?
http://stackoverflow.com/questions/3352741/fortran-assignment-on-declaration-and-save-attribute-gotcha –