[R] building an R package : where and how should my fortran library be loaded ?

Gilles GUILLOT gilles.guillot at inapg.inra.fr
Fri Oct 22 12:16:22 CEST 2004


Hi ,

I'm currently trying to make available 
a few fortran subroutines and R functions 
(which make interface to these subroutines),
as an R package.
I'm doing it under linux with R 1.9.0 
(but hope to do it for windows too).
I have trouble for loading my fortran code.
Here are the steps involved :

1) In R: 
                                      # Create tree for package
                                        # and include my R functions in it
R> package.skeleton(name="Geneland",
                 list=c("mcmcFmodel",
                   "simFmodel",
                   "rdiscr",
                   "tessel.post"),
                 path="/home/guillot/projets/flux/package/",
                 force=T)

                                        # copy my fortran code in the tree
R>    system("cp /home/guillot/projets/flux/package/fortran/*.f   
/home/guillot/projets/flux/package/Geneland/src/")

R> q()

2) In a Unix shell
$ R CMD build Geneland
$ R CMD check Geneland
$ R CMD build Geneland
$ R CMD INSTALL Geneland

3) Back to R
R> library("Geneland")

So far, it's OK, pure R functions work fine.
But  R functions calling  some Fortran via .Fortran
do not work, I get an error message like :
Error in .Fortran("mcmc", ...
Fortran function name not in load table

If I make 
R> dyn.load("/usr/lib/R/library/Geneland/libs/Geneland.so")

then it works .
I was thinking that my Geneland.so was loaded automatically
by the command library("Geneland")
Obviously, it's not.
Where and how should the library loaded ?


Gilles

_____________________________________________________________________
Gilles GUILLOT
INRA -Département Mathématiques et Informatique Appliquées

Unité de Mixte de Recherche INRA - INAPG - ENGREF
Institut National Agronomique de Paris-Grignon
16 rue Claude Bernard
75231 Paris cedex 5

Aile Claude Bernard
Niveau cours +3 étages
tel : +33 (0)1 44 08 72 71
fax : +33 (0)1 44 08 16 66
http://www.inapg.fr/ens_rech/mathinfo/personnel/guillot/welcome.html
______________________________________________________________________
-- 
_____________________________________________________________________
Gilles GUILLOT
INRA -Département Mathématiques et Informatique Appliquées

Unité de Mixte de Recherche INRA - INAPG - ENGREF
Institut National Agronomique de Paris-Grignon
16 rue Claude Bernard
75231 Paris cedex 5

Aile Claude Bernard
Niveau cours +3 étages
tel : +33 (0)1 44 08 72 71
fax : +33 (0)1 44 08 16 66
http://www.inapg.fr/ens_rech/mathinfo/personnel/guillot/welcome.html




More information about the R-help mailing list