igraph / rigraph

igraph R package
https://r.igraph.org
541 stars 200 forks source link

arpack Fortran bounds violation #287

Open ntamas opened 6 years ago

ntamas commented 6 years ago

From @rsbivand on March 17, 2015 10:26

The following generates an error when igraph is installed with Fortran bounds checking imposed (http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Fortran-array-bounds-checking):

library(spdep) # version >= 0.5-86
data(boston)
ab.listb <- nb2listw(boston.soi, style="B")
require(igraph)
B <- as(ab.listb, "symmetricMatrix")
n <- length(boston.soi)
f2 <- function(x, extra=NULL) {as.vector(B %*% x)}
ar1 <- arpack(f2, sym=TRUE, options=list(n=n, nev=2, ncv=8,  which="BE", maxiter=300))
# At line 558 of file dsaup2.f: 
# Fortran runtime error: Index '9' of dimension 1 of array 'bounds' above upper bound of 8
# Running twice with "LA" and "SA" succeeds.

I'd be grateful for an indication as to whether this is likely to be resolved or not; arpack() is useful for finding the boundaries of domains for parameters of spatial processes.

Roger Bivand

Copied from original issue: igraph/igraph#817

ntamas commented 6 years ago

From @gaborcsardi on March 17, 2015 15:25

Hmmm, interesting. I had to do some workarounds for the bounds checking, because ARPACK comes up as a false positive. But the workarounds should not affect the workings of the code, so if this really only happens when bounds checking is on, then this is definitely a bug, thanks for reporting it.

ntamas commented 6 years ago

From @rsbivand on March 17, 2015 21:21

To reproduce, you'd need a recent R-devel (I used 9 March) built normally. Then follow the link to the extensions manual to put the crafted Makevars in ~/.R to inject Fortran bounds checking. Install igraph, noting that bounds are turned on in the gfortran compiling output lines. I suggest removing the crafted Makevars before installing spdep (I did, but there are no direct Fortran calls there, so it shouldn't matter). Once that is done, you should be able to reproduce the problem with the code above. As I noted, the problem is present for symmetric matrices and which="BE", but not when running arpack twice with "LA" and "SA" to get the same output. It looks as though bounds is too short in the "BE" case, but I couldn't see why. I'd be happy to help test if you see where solutions might lie.

Roger