任何人都可以在Fortran中找出这些行的错误:
if (i==1) then
u(i,j+1)=u(i,j)-c*dt/2/dx*(u(i+1,j)-u(imax-1,j)) &
+ (c*c*dt*dt)/2/dx/dx*(u(i+1,j)-2*u(i,j)+u(imax-1,j))
Run Code Online (Sandbox Code Playgroud)
这里有更多代码:
select case (case_no)
C.. 1--Lax Wendroff one step scheme
case (1)
write (6,*) 'Entrance for the Lax-Wendroff one step method'
t=dt
do while (t<=18)
do i=1,41
if (i==1) then
u(i,j+1)=u(i,j)-c*dt/2/dx*(u(i+1,j)-u(imax-1,j)) &
+ c*c*dt*dt/2/dx/dx*(u(i+1,j)-2*u(i,j) &
+ u(imax-1,j))
else if (i==41) then
u(i,j+1)=u(i,j)-c*dt/2/dx*(u(i+1,j)-u(i-1,2)) &
+ c*c*dt*dt/2/dx/dx*(u(i+1,j)-2*u(i,j) &
+ u(i-1,2))
else
u(i,j+1)=u(i,j)-c*dt/2/dx*(u(i+1,j)-u(i-1,j)) &
+ c*c*dt*dt/2/dx/dx*(u(i+1,j)-2*u(i,j) &
+u(i-1,j))
end if
j=j+1
t=t+dt
end do
end do
Run Code Online (Sandbox Code Playgroud)
等式太长了,我想用'&'将它分成两行.但编译器说1.在'u(i,j + 1)'处的可分类语句2.在'+'处的名称中的无效字符
我是Fortran的新手.非常感谢.
您已经修复了表单源代码功能(您在第一列中使用C来开始注释)但是您要求自由表单行继续.您需要决定使用哪种源表单(自由表单最好不需要与古代代码保持一致),告诉编译器您以适当的方式使用自由格式(通常使用.f90文件扩展名) )然后确保注释样式,标记拆分和行继续方面与该表单一致.