From bhh at xs4all.nl  Tue May  9 14:32:42 2017
From: bhh at xs4all.nl (Berend Hasselman)
Date: Tue, 9 May 2017 14:32:42 +0200
Subject: [Rd] registering Fortran routines in R packages
In-Reply-To: <1CDAFD25-E227-42EA-A689-87B3036434AB@gmail.com>
References: <1CDAFD25-E227-42EA-A689-87B3036434AB@gmail.com>
Message-ID: <93D3A75D-290F-49B3-9E37-FD88F78E2BEF@xs4all.nl>


> On 9 May 2017, at 13:44, Christophe Dutang <dutangc at gmail.com> wrote:
> 
> Dear list,
> 
> I?m trying to register Fortran routines in randtoolbox (in srt/init.c file), see https://r-forge.r-project.org/scm/viewvc.php/pkg/randtoolbox/src/init.c?view=markup&root=rmetrics. 
> 
> Reading https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-native-routines and looking at what is done in stats package, I first thought that the following code will do the job:
> 
> static const R_FortranMethodDef FortEntries[] = {
> {"halton", (DL_FUNC) &F77_NAME(HALTON),  7},
> {"sobol", (DL_FUNC) &F77_NAME(SOBOL),  11},
> {NULL, NULL, 0}
> };
> 
> But I got error messages when building : use of undeclared identifier ?SOBOL_?. I also tried in lower case sobol and halton.
> 
> Looking at expm package https://r-forge.r-project.org/scm/viewvc.php/pkg/src/init.c?view=markup&revision=94&root=expm, I try  
> 
> static const R_FortranMethodDef FortEntries[] = {
> {"halton", (DL_FUNC) &F77_SUB(HALTON),  7},
> {"sobol", (DL_FUNC) &F77_SUB(SOBOL),  11},
> {NULL, NULL, 0}
> };
> 
> But the problem remains the same.
> 
> Is there a way to have header file for Fortran codes? how to declare routines defined in my Fortran file src/LowDiscrepancy.f?
> 

lowercase routine names? manual does mention that.

Berend Hasselman


> Any help appreciated
> 
> Regards, Christophe
> ---------------------------------------
> Christophe Dutang
> LMM, UdM, Le Mans, France
> web: http://dutangc.free.fr
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] registering Fortran routines in R packages
Berend Hasselman