【发布时间】: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