Compilation error: Invalid character in name at (1)

吃可爱长大的小学妹 提交于 2021-02-17 03:54:07

问题


I wrote

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

saved as test.f, and got compilation error with 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

What's wrong?

The compiler is GNU Fortran (GCC) version 6.1.1.


回答1:


You are missing a comma before the declaration of 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


来源:https://stackoverflow.com/questions/38398512/compilation-error-invalid-character-in-name-at-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!