Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fortran has this type of If ?

  1. Nov 4, 2012 #1
    Fortran has this type of "If"?

    I was reading a code from a thesis, obviously the quality of the scan was not good and I reached to this point in the image below, that the programmer uses "If" statements:


    I am not sure if he uses a "=" sign or a"-" sign for his statement. I mean this is "If (SPFR - .1) 21, 21, 2" or (SPFR = .1) 21, 21, 2"?
    do we have such a thing in fortran for an If statement using a minus sign?

    Thanks Frotran Masters!
  2. jcsd
  3. Nov 4, 2012 #2


    Staff: Mentor

    Re: Fortran has this type of "If"?

    The symbol is -, not =. This is a very old style in Fortran, and it's called an "arithmetic if" statement.

    It's equivalent to these statements:

    if (SPFR - .1 < 0) goto 21
    if (SPFR - .1 == 0) goto 21
    if ((SPFR - .1 > 0) goto 2
    That would be Fortran...
  4. Nov 4, 2012 #3
    Re: Fortran has this type of "If"?

    Thank you so much Mark44, you are awesome! and knowledgeable:)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook