Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Fortran 编译错误:位于(1)的名称中的字符无效_Fortran_Fortran90_Gfortran - Fatal编程技术网

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

Fortran 编译错误:位于(1)的名称中的字符无效,fortran,fortran90,gfortran,Fortran,Fortran90,Gfortran,我写 另存为test.f,并使用gfortran-ffree form-Wall-Werror-ffree line length none test.f获得编译错误 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)

我写

另存为test.f,并使用
gfortran-ffree form-Wall-Werror-ffree line length none test.f
获得编译错误

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
怎么了


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

在声明
b
之前缺少逗号:

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

建议:用命名常量替换
real(8)
,比如说,
use,instructive::iso_fortran_env,only:wp=>REAL64
,然后声明
real(wp)::a(N,N)。
最后,以
1.5_wp,2.0e+3_wp
的形式编写文本。
  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