【问题标题】:Fortran Compile Error: Unclassifiable statementFortran 编译错误:无法分类的语句
【发布时间】:2014-03-08 11:34:48
【问题描述】:

有人可以帮我解决以下问题吗?我是 Fortran 新手,正在尝试使用 GCC for Windows 运行以下内容。

program jacobi
implicit none
double precision, dimension(:,:), allocatable :: u, u_n
double precision :: Res_2, Res_inf
integer :: i,j,mesh,unit
mesh=64

Res_2=0
allocate(u(0:mesh,0:mesh))
allocate(u_n(0:mesh,0:mesh))
u=0
u_n=0
u(:,0)=1
u_n(:,0)=1
unit=12

open(unit, file="array.txt", access='append', status='old')

do while (Res_2>1D-10)
    Res_2=0
    do (i=1,mesh-1)
        do (j=1,mesh-1)
            u(i,j)=0.25D0*(u_n(i+1,j)+u_n(i-1,j)+u_n(i,j-1))
        end do
    end do
    Res_inf=-4D0*maxval((u-u_n))
    do (i=1,mesh-1)
        do (j=1,mesh-1)
            Res_2=Res_2+(-4D0*(u(i,j)-u_n(i,j)))**2
        end do
    end do
    Res_2=sqrt(Res_2)
    write(1,*) Res_2
end do
close(unit)

end program jacobi

我在编译时不断收到这些错误:

jacobi.f95:21.2:

  do (i=1,mesh-1)
  1
Error: Unclassifiable statement at (1)
jacobi.f95:22.3:

   do (j=1,mesh-1)
   1
Error: Unclassifiable statement at (1)
jacobi.f95:25.5:

  end do
     1
Error: Expecting END PROGRAM statement at (1)
jacobi.f95:27.2:

我是否使用了错误的 do 循环?我是否错误地声明了变量 'i,j'?

【问题讨论】:

    标签: compiler-errors fortran fortran95


    【解决方案1】:

    语句中的括号,例如

    do (i=1,mesh-1)
    

    不可接受,Fortran 中的正确形式是

    do i=1,mesh-1
    

    由于没有看到(有效的)do 语句,编译器后来抱怨发现不匹配的end do 语句。修复do 语句,关于期待end program 语句的错误应该消失了。

    【讨论】:

    • 修复了它。非常感谢!非常感谢。
    猜你喜欢
    • 2011-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-08
    • 2013-05-02
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    相关资源
    最近更新 更多