Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement followed by 5,4,4

Status
Not open for further replies.

Bob90

Programmer
Aug 5, 2011
2
GB
Hi,

I'm new to Fortran. I have a F77 program that has a line

if(VARIABLE-1)5,4,4

What does this do? (I have labels 4 and 5 below if that helps)

I think it checks if Variable > 1, as 0 = false, then goes to labels 5, 4, 4, but that makes no sense.

Obviously searching Google brings nothing as if statements are too common.

Thanks in advance
 
OK, simples really.

If <0 goto first label
if 0 goto second label
if >0 toto third label.

Sorry!
 
It is the original if statement from Fortran I, based on the assembler at that time. The old machines like IBM, Prime and Data General had a compare instruction followed by a 3 way jump. It is legal up to F77 but not in F90 and above.

Fortran does not have reserved words so it allows a variable to be called if. So you could have an array called if and see a statement like

Code:
if (if(m) .gt. 5) if (if(m-1)) 10, 20, 30
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top