Fortran Does Fortran Use Arithmetic If Statements?

  • Thread starter Thread starter gholamghar
  • Start date Start date
  • Tags Tags
    Fortran Type
AI Thread Summary
The discussion revolves around the use of "If" statements in Fortran, specifically an old style known as "arithmetic if." The user is uncertain about the syntax in a scanned code snippet, questioning whether the statement uses a minus sign or an equals sign. It is clarified that the symbol is indeed a minus sign, indicating a comparison rather than an equality check. The arithmetic if statement operates by evaluating the expression (SPFR - .1) and directing the flow of the program to different labels based on whether the result is negative, zero, or positive. This style is considered outdated in modern Fortran programming.
gholamghar
Messages
23
Reaction score
0
Fortran has this type of "If"?

Hi,
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:

http://i48.tinypic.com/x5z7n.jpg


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!
 
Technology news on Phys.org


gholamghar said:
Hi,
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:

http://i48.tinypic.com/x5z7n.jpg


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"?
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
gholamghar said:
do we have such a thing in fortran for an If statement using a minus sign?

Thanks Frotran Masters!
That would be Fortran...
 


Mark44 said:
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...

Thank you so much Mark44, you are awesome! and knowledgeable:)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
4
Views
2K
Replies
12
Views
3K
Replies
8
Views
2K
Replies
16
Views
2K
Replies
21
Views
3K
Replies
7
Views
3K
Replies
9
Views
5K
Back
Top