Fortran 中 IF 中的不可分类语句和其他错误
Unclassifiable statement and other errors in an IF in Fortran
我有代码:
if i < n then
x = topsep(1)
y = topsep(2)
realvor(n,1) = x + dx
realvor(n,2) = x + dy
imvor(n,1) = (realvor(n,1)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
imvor(n,2) = (realvor(n,2)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
tf = .TRUE.
else
x = botsep(1)
y = botsep(2)
realvor(n,1) = x + dx
realvor(n,2) = y - dy
imvor(n,1) = (realvor(n,1)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
imvor(n,2) = (realvor(n,2)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
tf = .FALSE.
endif
i
和 n
都定义为整数,我在 n = 1,100
的 do 循环中。这会引发以下错误:
Error: Unclassifiable statement at (1) at the 'if i< n then'
Error: Unexpected ELSE statement at (1) at the 'else'
Error: Expecting END DO statement at (1) at the 'endif'
我看不出这些错误是从哪里来的,无论我如何编写 if 语句(.NE.
等),它似乎都会抛出同样的东西。
你忘了括号!根据 Fortran 标准 (2008, ch. 8.1.7.4),if
语句应为
if ( i < n ) then
我有代码:
if i < n then
x = topsep(1)
y = topsep(2)
realvor(n,1) = x + dx
realvor(n,2) = x + dy
imvor(n,1) = (realvor(n,1)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
imvor(n,2) = (realvor(n,2)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
tf = .TRUE.
else
x = botsep(1)
y = botsep(2)
realvor(n,1) = x + dx
realvor(n,2) = y - dy
imvor(n,1) = (realvor(n,1)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
imvor(n,2) = (realvor(n,2)*(a**2))/((realvor(n,1))**2+(realvor(n,2))**2)
tf = .FALSE.
endif
i
和 n
都定义为整数,我在 n = 1,100
的 do 循环中。这会引发以下错误:
Error: Unclassifiable statement at (1) at the 'if i< n then'
Error: Unexpected ELSE statement at (1) at the 'else'
Error: Expecting END DO statement at (1) at the 'endif'
我看不出这些错误是从哪里来的,无论我如何编写 if 语句(.NE.
等),它似乎都会抛出同样的东西。
你忘了括号!根据 Fortran 标准 (2008, ch. 8.1.7.4),if
语句应为
if ( i < n ) then