编译错误:名称中的字符无效(1)

时间:2016-07-15 14:22:13

标签: fortran fortran90 gfortran

我写了

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。

1 个答案:

答案 0 :(得分:3)

您在声明b

之前缺少逗号
  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 /) !                                              ^ 
    !                                                                        |
    !                                                        comma inserted here