2

I have a question about some code I'm looking at written in Fortran. The section of the code I'm confused about is written below.

DO 40 LL=1,N
DO 40 I=1,N-1,2
IF((LL-I)*(LL-I-1)*(LL-I*2)*(LL-I+N-2)) 22,21,22
NODO=LL-I+1
IF((LL.EQ.1) .AND. (I.EQ.N-1)) NODO=NODO+N

I don't understand the condition for the first IF statement. It just looks like numbers are being multiplied together but that number isn't checked against anything. Then 3 line numbers are written after the IF statement. Do anyone know what this IF statement is doing? The last IF statement makes sense as a condition is actually being checked. Thanks.

  • Very old Fortran that puzzles many people and gets asked about repeatedly: http://stackoverflow.com/questions/6789946/strange-label-usage, http://stackoverflow.com/questions/10758935/fortran-compiler-warning-obsolete-arithmetic-if-statement and http://stackoverflow.com/questions/11124855/fortran-strange-if – M. S. B. Dec 18 '13 at 20:11

1 Answers1

2

The line

IF((LL-I)*(LL-I-1)*(LL-I*2)*(LL-I+N-2)) 22,21,22

is an arithmetic if statement, which is certainly obsolescent (the Fortran standard term for deprecated) and may even have been removed in the latest language standard(s). If the condition evaluates to a negative number program control branches to the line with the first label (ie 22), if it evaluates to 0 to the second label (21), if to a positive value to the third label (22). As you see the three labels need not all be different.

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161