本文介绍了编译错误:(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 出现编译错误.

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

怎么了?

编译器是GNU Fortran(GCC)版本6.1.1.

The compiler is GNU Fortran (GCC) version 6.1.1.

推荐答案

在声明 b 之前,您缺少逗号:

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

这篇关于编译错误:(1)名称中的字符无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 01:41