[Rd] advice on F77_SUB and F77_CALL
jing hua zhao
jinghuazhao at hotmail.com
Thu Dec 16 17:26:58 CET 2004
I would like to have your advice on how to call C from Fortran. Essentially
I have a Fortran program for numerical optimisation that often uses object
function as its function/subrouine arguements. However, it appears most
examples of F77_SUB concern about arrays/matrices and not function -- I
could work directly with C with help of f2c but it would be very nice to
keep the familiar Fortran code intact. I have tried to remove the argument
and keep it in an Fortran EXTERNAL statement. The Fortran routine is
appealing to me as it handles nonlinear constraints.
I tried to work it out like this: use .Call from R to call a C wrapper which
processes the environment and parses R expressions, use F77_CALL to call the
Fortran routines which in turn uses an objective function in C -- I use
global variables to pass the environment and R function from the C wrapper
to C objective function. I have problem with F77_CALL, however.
This sounds a bit confusing though simple conceptually. I am grateful of any
example or idea.
More information about the R-devel