[Rd] calling fortran from C

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Oct 20 17:31:48 CEST 2005


On Thu, 20 Oct 2005, James Bullard wrote:

>
> Hello, I had a question about calling some of R's fortran routines from C.
> Specifically, I would like to call: dqrfit from some C code which will be
> bundled as an R package. I was hoping someone knew of an example in some
> of R's code which does something like this (any fortran call from R's C
> would probably be a sufficient guide). So far I can only find locations
> where R calls the Fortran directly, but this is not an option for me.

Look in the lapack module, and also in the stats package for loess (and 
others, smooth.spline has both C and Fortran components).

> Also, I am trying to gauge the overhead of making this call, does anyone
> have any knowledge of whether there might be some non-trivial constant
> time penalty on making such a call.

Not significant (and C to Fortran is normally no different from C to C). 
In this case you will be calling from a DLL either into an executable or a 
DLL and that will be slower than calling within a DLL, how much depending 
on the platform.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list