What does this Fortran code mean:
IF (J1-3) 20, 20, 21
21 J1 = J1 - 3
20 IF (J2-3) 22, 22, 23
23 J2 = J2 - 3
22 CONTINUE
I\'ve seen in o
This is an arithmetic if statement from FORTRAN 77. Adapted from the FORTRAN 77 specification (emphasis mine):
The form of an arithmetic
IFstatement is:
IF (e) s1 , s2 , s2
where:
eis an integer, real, or double precision expression
s1,s2, ands3are each the statement label of an executable statement that appears in the same program unit as the arithmeticIFstatement. The same statement label may appear more than once in the same arithmeticIFstatement.Execution of an arithmetic
IFstatement causes evaluation of the expressionefollowed by a transfer of control. The statement identified bys1,s2, ors3is executed next as the value ofeis less than zero, equal to zero, or greater than zero, respectively.
For the example in your question, from the last sentence above,
J1-3 < 0 statement 20 will be executedJ1-3 = 0 statement 20 will also be executedJ1-3 > 0 statement 21 will be executedEdit: A modern and much more readable way to write this would be:
if (J1-3 > 0) J1 = J1 - 3
if (J2-3 > 0) J2 = J2 - 3