Thursday, June 01, 2006

Very bad code.

Just had a look at legacy code that spans several pages in this style:

 DO 13 K = 1,N
    Z(6) = U(K,I)
    U(K,I) = Z(5) * Z(6) - Z(4) * U(K,J)
    U(K,J) = Z(4) * Z(6) + Z(5) * U(K,J)
    IF(K .EQ. I .OR. K .EQ. J) GOTO 13
    H(I,K) = Z(5) * H(K,I) - Z(4) * H(K,J)
    H(J,K) = Z(4) * H(K,I) + Z(5) * H(K,J)
    H(K,I) = H(I,K)
    H(K,J) = H(J,K)
13  CONTINUE

All variables have 1 or two characters and it is full of magic constants and meaningless array indices.

No comments: