yuntan_t
yuntan_t

Reputation: 61

Compilation error: Invalid character in name at (1)

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.

Upvotes: 1

Views: 3481

Answers (1)

Alexander Vogt
Alexander Vogt

Reputation: 18098

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

Upvotes: 3

Related Questions