Fortran IF statement with numbers / labels and not with another expression

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 saw in the old project, and I don’t know what IF is with numbers (labels).

+6
source share
1 answer

This is a description of the arithmetic if from FORTRAN 77. Adapted from the FORTRAN 77 specification (focus):

The form of the arithmetic operator if :

IF (e) s1 , s2 , s2

  • where: e is an integer, real or double exact expression

  • s1 , s2 and s3 are the operator tag of the executable operator, which appears in the same program module as the if arithmetic operator. The same operator label may appear more than once in the same if arithmetic expression.

Performing an arithmetic if causes an evaluation of the expression e , followed by a transfer of control. The operation indicated by s1 , s2 or s3 is performed as follows, since the value of e less than zero, equal to zero or greater than zero, respectively.

For example, in your question, from the previous sentence above,

  • If instruction J1-3 < 0 is executed
  • If instruction J1-3 = 0 20 will also be executed
  • If the statement J1-3 > 0 21 is executed

Change A modern and much more convenient way to record:

 if (J1-3 > 0) J1 = J1 - 3 if (J2-3 > 0) J2 = J2 - 3 
+7
source

Source: https://habr.com/ru/post/918584/


All Articles