1

I am not sure which version of Fortran is this piece of code, also I am not very good at it but here is the piece of code that I try to understand...

      DO 55 J=1,N  
      IF(KODE(J)) 55,55,40  ! Can not figure out what this line does
   40 DO 50 I=1,N  
      CH=G(I,J) 
      G(I,J)=-H(I,J)
      H(I,J)=-CH
   50 CONTINUE
   55 CONTINUE

In the loop given above, could you help me to understand what the 2nd line does, specifically the labels 55,55,40

This is a code from a boundary element book that I am trying to understand...

Umut Tabak
  • 1,862
  • 4
  • 26
  • 41

2 Answers2

3

Wow ... I haven't seen that syntax in a while. That is a Fortran Arithmetic IF Statement. The result of KODE(J) is a number. If it is less than zero, then the first jump is used, if it is equal to zero, then the second jump is used, otherwise, the third jump is used. This is roughly equivalent to:

X=KODE(J)
IF (X.LT.0) GO TO 55
IF (X.EQ.0) GO TO 55
GO TO 40

My Fortran skills have faded significantly, but this is what I remember.

In this particular case, even simpler for programmer to write

X=KODE(J)
IF (X.LE.0) GO TO 55
GO TO 40
ice1000
  • 6,406
  • 4
  • 39
  • 85
D.Shawley
  • 58,213
  • 10
  • 98
  • 113
1

An "arithmetic if" statement was the IF statement of very early Fortran. The conventional IF statement (aka "logical" if) was introduced in Fortran IV in 1962 (http://en.wikipedia.org/wiki/Fortran#FORTRAN_IV). An arithmetic IF statement is the sign of really old code (FORTRAN II !), or a programmer following such a style.

The Arithmetic If statement was listed as "obsolescent" in Fortran 90 as a warning that the feature might be deleted from the language in the future, and was finally deleted in Fortran 2018.

francescalus
  • 30,576
  • 16
  • 61
  • 96
M. S. B.
  • 28,968
  • 2
  • 46
  • 73