Syntax error when using “X != 0” in Fortran

前端 未结 3 1456
无人共我
无人共我 2021-01-19 00:59

I have a problem with my Fortran program that does nothing more than calculating a prime factorization (or should do). That\'s the error:

C:\\MinGW\\Fortran>         


        
3条回答
  •  执念已碎
    2021-01-19 01:47

    Well, this is Fortran and ! denotes a comment. So the compiler actually sees

    if (prim(i) 
    

    which is no valid statement. The error message you see reflects that.

    "Not equal" in Fortran is /= or .ne.:

     if (prim(i) /= 0 .and. modulo(n, prim(i)) == 0) then
    

    and, later on:

    if (prim(i) /= 0) then
    

提交回复
热议问题