Re: [Rd] call fortran in R

From: Simon Urbanek <>
Date: Thu 04 Aug 2005 - 18:18:04 GMT

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

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.o -L/usr/local/lib/gcc/powerpc-apple-darwin6.8/3.4.2 - lg2c -lSystem -lcc_dynamic -framework R

gammu:urbanek$ nm |grep T
00000fec T _ffoo_

R> dyn.load("")
R> .Fortran("ffoo",as.double(10))
[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...

Simon mailing list Received on Fri Aug 05 04:21:44 2005

This archive was generated by hypermail 2.1.8 : Mon 24 Oct 2005 - 22:27:34 GMT