NEC2 was originally written in Fortran and there have been two different ports to C from the original Fortran (xnec2c and necpp).
The variable and function names are similar (usually exactly identical). However, the authors chose different data structures for global values.
Is there a way to diff these two implementations to see if there are any actual differences, not just differences in naming convention?
It seems that it could be possible, refactoring tools like Coccinelle have some structural awareness and understand datatypes.
If so, then bugs in one program or the other caused by author error can be detected by through such a static analysis. A human could then then be compare the C code implementations to the original Fortran to see which one is correct, or if the syntactically different representation was computationally equivalent. Note that this is static analysis, we just want to know if the code structure (branches and expressions and therefore datatypes) are the same.
For example, these two samples compute the same thing but the storage of variables icon1 and ind1 differ:
if( -icon1[iprx] != jx )
ind1=2;
else
{
xi= fabsl( cabj* cab[iprx]+ sabj* sab[iprx]+ salpj* salp[iprx]);
if( (xi < 0.999999) || (fabsl(bi[iprx]/b-1.) > 1.e-6) )
ind1=2;
else
ind1=0;
}
versus
if( -data.icon1[iprx] != jx )
dataj.ind1=2;
else
{
xi= fabs( dataj.cabj* data.cab[iprx]+ dataj.sabj*
data.sab[iprx]+ dataj.salpj* data.salp[iprx]);
if( (xi < 0.999999) ||
(fabs(data.bi[iprx]/dataj.b-1.0) > 1.0e-6) )
dataj.ind1=2;
else
dataj.ind1=0;
} /* if( -data.icon1[iprx] != jx ) */