Update: The packages distributed here have been superseded by the new autotoolized ARPACK.

This evening, I ran into a pretty frustrating problem with ARPACK. It aborted without being able to compute an Arnoldi factorization from within one program, but the same snippet of code (with the same matrix!) would work just fine in another.

To make a long story short, I eventually tracked down the root cause: Both LAPACK and ARPACK define a routine called SECOND, but with different call signatures. LAPACK’s copy is a function, whereas ARPACK’s copy is a subroutine. Usually, all goes well, and the linker is intelligent enough to pick the right copy in all instances. I was unfortunate enough to be in a situation where that was not the case. The call to the wrong SECOND messed up the stack, and things got really strange from there. (For example, DLARNV returned a NaN instead of a proper number.)

Hence, the ARPACK-supplied SECOND routine needs to be renamed. The attached ARPACK/LAPACK Symbol Duplication against ARPACK version 96 (a revised version of a quick sed job) realizes this suggestion by renaming the routine to ARSCND (as in “ARpack SeCoND”), which fixed the problem for me. Apparently, somebody else on the Octave team ran into a similar problem, but appeared to get only unhelpful replies.

Hopefully, this posting will save somebody some trouble.

Update: This Debian bug tracks progress on the issue.

Update 2: ARPACK/LAPACK Symbol Duplication of the patch works against ARPACK96 with patch.tar.gz applied. It’s also slightly cleaner: It renames second.f to arscnd.f.

Update 3: I got a reply from Rich Lehoucq acknowledging the bug two years ago, but he never got around to posting my patch. Thus I’m taking the liberty to redistribute an updated version of ARPACK here. The build system has also been updated so that it should work on most modern flavors of Linux without any tweaking.