****************************************************************************************
Details of the configurations on which I performed testing follow:
R 2.1.1 on WinXP Pro SP2 ITA
PC1: AMD 64 3700+ 1GB RAM
PC2: AMD AthlonXP 2400+ 512Mb RAM
Compaq Visual Fortran pro 6.6C
****************************************************************************************
To give an idea I attach a brief example on how to reproduce this:
Create two simple subroutines 'foo' and 'foobis' that, say, give the
sum of the elements of a matrix:
*** file foo.f90 starts
***********************************************************************
SUBROUTINE foo(X,M,N,S)
!DEC$ ATTRIBUTES DLLEXPORT,C,REFERENCE,ALIAS:'foo_' :: FOO
IMPLICIT NONE
integer:: M,N
real*8:: X(M,N),S
S = sum(X);
END SUBROUTINE foo
SUBROUTINE foobis(M,N,S)
!DEC$ ATTRIBUTES DLLEXPORT,C,REFERENCE,ALIAS:'foobis_' :: FOOBIS
IMPLICIT NONE
integer:: M,N
real*8:: X(M,N),S
X = 1;
S = sum(X);
END SUBROUTINE foobis
*** file foo.f90 ends
***********************************************************************
Notice that the matrix X is an input argument in foo and an internal
variable in foobis.
After compiling and linking turn to R:
**************************************************************************
dyn.load("foo.dll");
is.loaded(symbol.For("foo"));
is.loaded(symbol.For("foobis"));
M <- 10;
N <- 10;
X <- matrix(1,M,N);
.Fortran("foo",X,as.integer(M),as.integer(N),S=as.double(0))$S;
.Fortran("foobis",as.integer(M),as.integer(N),S=as.double(0))$S;
[1] 100
## no problem here with small matrices, let's increase the size
M <- 3000;
N <- 100;
X <- matrix(1,M,N);
.Fortran("foo",X,as.integer(M),as.integer(N),S=as.double(0))$S;
[1] 3e+05 ## OK
.Fortran("foobis",as.integer(M),as.integer(N),S=as.double(0))$S;
## *** R GUI CRASHES WITH A STACK OVERFLOW ERROR ***
****************************************************************************
Any suggestion would be greatly appreciated, I apologize if this
problem has already been addressed previously, I did not notice it.
Many thanks in advance,
Simone