Sunday, August 26, 2012

Funny code comments

Funny code comments is a perennial topic of conversation over group lunch. This one was found by Casper, in the Fock2 subroutine.  It's part of the MOPAC6 six code I implemented in GAMESS back in 1992, but I didn't add it.  Perhaps Mr MOPAC?

C---C THIS FORMS THE TWO-ELECTRON TWO-CENTER REPULSION PART OF THE FOCK
C---C MATRIX.  THE CODE HERE IS HARD TO FOLLOW,
C---C AND IMPOSSIBLE TO MODIFY!,
C---C BUT IT WORKS,

Have you come across funny code comment?

2 comments:

Jimmy Charnley Kromann said...

Funnt fact. The code it mentions is commented out and the reason being:


C THE ARRAY WJ AND WK IS NOT INITIALIZED, AND
C PROBABLY WE NEVER EXECUTED THIS CODE ABOVE

Anders Steen Christensen said...

How about this one?

C
C Routine per il calcolo della matrice XX (interazione tra
C pseudo-cariche virtuali elettroniche e il potenziale elettronico
C del soluto) usando la DERIVATA SECONDA della matrice densita'
C rispetto alle componenti IC1 e IC2 del campo elettrico esterno
C (con frequenza Wt=W1+W2):
C XX(Wt)mn = sum_i[ V(m,n;i) d2[QSE_i(W1,W2)]/dExdEy ]
C d2[QSE_i(W1,W2)]/dExdEy =
C sum_m,n{ d2[D(W1,W2)mn]/dExdEy qse_i(Wt)mn }
C dove Ex,Ey sono le componenti x,y del campo elettrico esterno.
C
C Il fattore di normalizzazione deve essere anch'esso derivato.
C d2[Q(W1,W2)_norm]/dExdEy = d2QSE(W1,W2)/dExdEy * FE(0)
C + QSE(0) * d2FE(W1,W2)/dExdEy
C + [dFE(W1)/dEx]*[dQSE(W2)/dEy]
C + [dFE(W2)/dEy]*[dQSE(W1)/dEx]
C d2FE(W1,W2)/dExdEy = - {FE(0)**2 *
C sum(i) [d2QSE_i(W1,W2)/dExdEy]} / Qteorica +
C 2 * [dFE(W1)/dEx * dFE(W2)/dEy ] / FE(0)
C dove QSE sono le cariche di polarizzazione NON normalizzate.
C
C Viene usata per il calcolo delle polarizzabilita' e
C iperpolarizzabilita' A FREQUENZA W in soluzione.
C
C La matrice d2D(W1,W2)/dExdEy e' passata in D.
C
C d[QSE_i(0)]/dEx = a(i)sum_j[ DMATM1(i,j)
C {sum_m,n[ dD(m,n)/Ex(-dV(m,n;i)/dn) ]}
C d[QSE_i(W)]/dEx = a(i)sum_j[ DMFR(i,j)
C {sum_m,n[ dD(m,n)dEx(-dV(m,n;i)/dn) ]}
C


Found in the pcmpol.src