Message-ID: <FFA817C4-8C2B-4854-8C4B-5A338307D455@r-project.org>
Date: 2005-08-04T18:18:04Z
From: Simon Urbanek
Subject: call fortran in R
In-Reply-To: <77DED4C1-017A-4A60-8B81-0E991C97E020@UMontreal.CA>
On Aug 4, 2005, at 1:38 PM, S?bastien Durand wrote:
> Ok, I am presently updating my system.
>
> How do you set
> setenv gcc /usr/local/bin/gfortran.
That won't help even if you do it in bash - this is wrong!
(F77=gfortran is what may help if you want to re-compile R with gcc4).
If you are using CRAN binary, you cannot use gfortran! gcc3 and 4 are
not compatible.
With stock CRAN binary and the supplied g77 (Tiger on a G5) a simple
(silly) example:
gammu:urbanek$ cat fts.f
subroutine ffoo(a)
double precision a(1)
a(1) = 1.0d0
return
end
gammu:urbanek$ R CMD SHLIB fts.f
g77 -fno-common -g -O2 -c fts.f -o fts.o
gcc-3.3 -bundle -flat_namespace -undefined suppress -L/usr/local/lib -
o fts.so fts.o -L/usr/local/lib/gcc/powerpc-apple-darwin6.8/3.4.2 -
lg2c -lSystem -lcc_dynamic -framework R
gammu:urbanek$ nm fts.so |grep T
00000fec T _ffoo_
R> dyn.load("fts.so")
R> .Fortran("ffoo",as.double(10))
[[1]]
[1] 1
R> is.loaded(symbol.For("ffoo"))
[1] TRUE
R> symbol.For("ffoo")
[1] "ffoo_"
So ... there must be something fundamentally wrong with your setup,
otherwise I see no reason why you should have any problems. Maybe you
should send us the code pus exact transcript of your attempt...
Cheers,
Simon