From ripley at stats.ox.ac.uk  Fri Feb  6 23:45:34 2009
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 6 Feb 2009 22:45:34 +0000 (GMT)
Subject: [Rd] Use of cfortran.h?
In-Reply-To: <46869.97.124.28.229.1233959110.squirrel@webmail02.uottawa.ca>
References: <46869.97.124.28.229.1233959110.squirrel@webmail02.uottawa.ca>
Message-ID: <alpine.LFD.2.00.0902062234230.7397@gannet.stats.ox.ac.uk>

All you need to do is to write a fortran-callable wrapper for a C 
interface: there are F77_* macros to allow this.  They do not work on 
every possible platform, but they work on the platforms R runs on 
(since building R relies on them).

E.g. intpr (a call to R's print routines from Fortran) provides a good 
prototype.  It is in src/main/xxxpr.f an print.c (it would be simpler 
if Fortran character types were not involved).

I don't suppose you are comtemplating complex variables, but if you 
were, a great deal of care is needed in the C/Fortran interfaces.

On Fri, 6 Feb 2009, nashjc at uottawa.ca wrote:

> I'm planning to try to use Mike Powell's new BOBYQA optimization routine
> to see if it is a good candidate to eventually replace Nelder-Mead as the
> optim() default. (Don't panic -- this won't happen quickly.) Mike writes
> f77 code. After some chasing about, I've realized that because
> optimization codes need to call the objective function written in R, they
> need to use a language that can do this. C can, Fortran cannot.
>
> There is, however, a package cfortran that allows for mixed coding in C
> and Fortran. This might not be the ultimate solution -- e.g., it may not
> be Windows usable. However, it could be a useful tool to try out some
> programs that are already available in Fortran.
>
> My query is to ask if anyone has experience they can share in using
> cfortran.h. I'd also welcome (off-list may be best) input on directions
> for improving or at least tidying optim() and many related capabilities in
> R.
>
> John Nash
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
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



[Rd] Use of cfortran.h?
Prof Brian Ripley