FORTRAN compiler warning: obsolete arithmetic IF statement

前端 未结 3 954
被撕碎了的回忆
被撕碎了的回忆 2021-01-27 12:16

I have a gfortran error:

Warning: Obsolete: arithmetic IF statement at (1) 

What does this mean? In the source (old source):

6         


        
相关标签:
3条回答
  • 2021-01-27 12:35

    Check here:

    http://www.ibiblio.org/pub/languages/fortran/ch1-5.html

    "The Arithmetic IF is considered harmful."

    Your statement,

    if (s12 - 1.0) 13, 13, 12 is an Arithmetic IF, and is considered bad programming.

    0 讨论(0)
  • 2021-01-27 12:43

    Quoth Wikipedia:

    "..the Fortran statement defines three different branches depending on whether the result of an expression was negative, zero, or positive, in said order..."

    "..was finally labeled obsolescent in Fortran 90."

    0 讨论(0)
  • 2021-01-27 12:48

    Arithmetic if is a peculiar feature of FORTRAN

    it works as follows.

     IF (expr) label1, label2, label3
    

    If the value of the expression is

    less than 0, jump to label1 
    equal to 0, jump to label2
    greater than 0, jump to label3
    

    In newer FORTRAN standards this feature is obsolete

    In your code you can replace it with

          IF (s12 - 1.0 .gt. 0 ) GOTO 12
    13    z = s1 / s12
    
    0 讨论(0)
提交回复
热议问题