Unclassifiable statement and other errors in an IF in Fortran

你。 提交于 2019-12-20 03:52:19

问题


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.


回答1:


You forgot the parenthesis! According to the Fortran standard (2008, ch. 8.1.7.4), the if statement should read

if ( i < n ) then


来源:https://stackoverflow.com/questions/28781861/unclassifiable-statement-and-other-errors-in-an-if-in-fortran

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!