[Rcpp-devel] Rcpp with C++ and Fortran
Douglas Bates
bates at stat.wisc.edu
Wed Jan 23 21:38:30 CET 2013
Could you clarify a bit, Rodney. When you say you want to "link it with
Fortran code" are you using the word "link" in the sense of linking to
object code or do you mean that you will copy the Fortran source files into
your package's src directory and have them compiled with other source
files? The second, which I would describe as "calling Fortran subroutines
from C++ code", is definitely easier.
To actually call a Fortran subroutine you need to know about appending
underscores on entry point names and the fact that all arguments to Fortran
functions are passed by reference. That is, everything is a pointer. It
might be easiest if you could post the calling sequence of a particular
subroutine so we could show the exact code. I'm happy to carry on the
conversation off-list if this seems like too much noise for this list.
Discussing calling Fortran code on a C++ list is a "keep 'em down on the
farm after they've seen Paris" situation.
On Wed, Jan 23, 2013 at 2:16 PM, Rodney Sparapani <rsparapa at mcw.edu> wrote:
> Hi!
>
> Quick question: has anyone used Rcpp with C++ and Fortran?
>
> Longer version: We have developed some C++ code to do MCMC sampling
> with RcppEigen. It works pretty well: about a 70X speed
> improvement over R code. We have been able to link this with some
> ARMS C code rather easily. However, now we want to link it with
> Fortran code from the DPpackage R package.
>
> I have looked through as many Rcpp docs as I could get my hands, but I
> didn't see anything about Fortran (plus googling). Anyways, what is
> the best way to call Fortran functions from our C++ code that will be
> used via Rcpp/inline? I've played around with f2c to convert the
> Fortran code to C (but it makes me nervous ;o) Should I be working
> from a package skeleton? Basically, any advice is welcome. Thanks!
>
> --
> Rodney Sparapani, PhD Center for Patient Care and Outcomes Research
> Sr. Biostatistician http://www.mcw.edu/pcor
> 4 wheels good, 2 wheels better! Medical College of Wisconsin (MCW)
> WWLD?: What Would Lombardi Do? Milwaukee, WI, USA
> ______________________________**_________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-**project.org<Rcpp-devel at lists.r-forge.r-project.org>
> https://lists.r-forge.r-**project.org/cgi-bin/mailman/**
> listinfo/rcpp-devel<https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130123/69b5c097/attachment.html>
More information about the Rcpp-devel
mailing list