Fortran中的IF中的不可分类的语句和其他错误 [英] Unclassifiable statement and other errors in an IF in Fortran
问题描述
我有代码:
如果我< n然后
x = topsep(1)
y = topsep(2)
realvor(n,1)= x + dx
realvor(n,2)= x + dy $ b $ 2(realvor(n,2))** 2(realvor(n,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
的循环中。这会抛出以下错误:
lockquote
错误:在'if i < n然后'
错误:'else'处的意外的ELSE语句
错误:期望在'endif'处的(1)处的END DO语句
无论我如何编写if语句( .NE。
等),它似乎抛出了相同的东西。
你忘了括号!根据Fortran标准(2008,第8.1.7.4节), if if
语句应为
if(i
I have the code:
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
Both i
and n
are defined as integers and I am inside a do loop for n = 1,100
. This throws up the following errors:
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'
I can't see where these errors are coming from, no matter how I write the if statement (.NE.
etc.) it seems to throw up the same things.
You forgot the parenthesis! According to the Fortran standard (2008, ch. 8.1.7.4), the if
statement should read
if ( i < n ) then
这篇关于Fortran中的IF中的不可分类的语句和其他错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!