[Rd] call fortran in R

Simon Urbanek simon.urbanek at r-project.org
Thu Aug 4 20:18:04 CEST 2005


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



More information about the R-devel mailing list