From simon.urbanek at r-project.org  Thu Aug  4 20:18:04 2005
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu, 4 Aug 2005 14:18:04 -0400
Subject: [Rd] call fortran in R
In-Reply-To: <77DED4C1-017A-4A60-8B81-0E991C97E020@UMontreal.CA>
References: <BB026B1E-17AE-42A2-B86E-6C74337202D1@UMontreal.CA>
	<834774B3-26D3-4600-9B48-DF6626F8FAC6@frazmtn.com>
	<77DED4C1-017A-4A60-8B81-0E991C97E020@UMontreal.CA>
Message-ID: <FFA817C4-8C2B-4854-8C4B-5A338307D455@r-project.org>

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



[Rd] call fortran in R
Simon Urbanek