1
的名字無效字符我寫編譯錯誤:在(1)
program test
implicit none
integer, parameter :: N = 3
real(8), parameter :: &
A(N,N) = reshape((/1.5d0,1d0,1d0,1d0,1.5d0,2d0,1d0,1d0,3d0/), shape(A)) &
b(N) = (/ 5d0,-3d0,8d0 /)
print *, A
end program
保存爲test.f,並得到了編譯錯誤與gfortran -ffree-form -Wall -Werror -ffree-line-length-none test.f
。
test.f:6:24:
A(N,N) = reshape((/1.5d0,1d0,1d0,1d0,1.5d0,2d0,1d0,1d0,3d0/), shape(A)) &
1
Error: Invalid character in name at (1)
test.f:9:12:
print *, A
1
Error: Symbol ‘a’ at (1) has no IMPLICIT type
怎麼了?
編譯器是GNU Fortran(GCC)版本6.1.1。
建議:更換'實(8)'用命名常量,說,'使用,內在:: iso_fortran_env,只有:WP => REAL64',然後聲明'real(wp):: A(N,N)。最後,將文字寫爲'1.5_wp,2.0e + 3_wp',而不是任何其他方式。 – jlokimlin