[Rcpp-devel] Prior art on R packages using Rcpp/C++ to call a Fortran(90->2008) library, using iso_c_binding

Dirk Eddelbuettel edd at debian.org
Sun Aug 18 18:47:48 CEST 2013


Hi Jean-Michel,

On 18 August 2013 at 06:44, Jean-Michel.Perraud at csiro.au wrote:
| I am seeking existing code/documentation for such a situation. General advice very welcome.
| 
| Technically a few precisions:
| - the Fortran library is(will be) substantial in size, and compiled with gfortran or Intel fortran (i.e. not when building the R package)
| - I intend to write an interop layer in C/C++ calling a Fortran API using the Fortran iso_c_binding module for interop. this C/C++ layer would be the entry point for things like R or Python
| - I'd like to use Rcpp to access from R, in preference C code to do the data marshalling. I intend to pass more than numeric/character vector hence wanting to use Rcpp instead of .C, .Fortran and .Call.
| 

That should definitely work. You can always call Fortran via C calling
conventions from C (or from C++ behaving like C), and you can still use Rcpp
to get your data from/to R more easily.

You could even think of something like RcppArmadillo as an example as it
"eventually" calls BLAS routines.

| I picked up one previous thread on this mailing list (http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-January/005147.html), but the package pointed to in a reply ('rexpokit' at http://r-forge.r-project.org/scm/?group_id=1427), but do not see a practical use of Rcpp in the code.

Exactly what is your question?  At the end of the day this may just be about
calling an external library from code acccessed with Rcpp -- so even the GSL
examples would fit.

Try to mock something reproducible up if you have questions.  Calling a BLAS
routine which adds two vectors, or does a vec/mat multiplication, may be a
good exercise for you too.  

Let us know if you have concrete questions, I am sure we can help you with this.

Cheers, Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list