[Rd] Calling Fortran90 code from R
hartwig.deneke at gmail.com
Tue Dec 29 13:44:22 CET 2009
2009/12/29 Simone Giannerini <sgiannerini at gmail.com>:
> Dear Hartwig,
> I think there are many packages that use F90 code and you should really be
> able to call it by following the advices in the R-exts
> manual. There are no major differences with F77 and you do not need a C
> wrapper. Maybe you might start with a simple example like this one.
....(helpful example removed)...
> open R ************************
Dear Simone (and others reading),
first of all thanks for your helpful example. While I did something
similar yesterday, it did give me a simple example to start from which
worked, and find a nice approach to solving my problems. A brief
summary of the origin of my problems, which are related to the use of
Fortran90 module declarations.
It is perfectly possible to call Fortran90 code compiled with
gfortran. Compiling a subroutine/function "foo" will produce a symbol
"foo_" in the dynamic library. If, however, the subroutine is
contained in a module named "modname", the symbol will be called
"__modname_MOD_foo". In this case, it will not be found by the
".Fortran" call or a call to "is.loaded", at least I have not found
any way to do this. However, for my purposes, I have simply added a
set of wrapper subroutines to the library (which I planned to add
anyway for other reasons, in particular to reduce the number of
arguments), which forwards the calls to the module functions, and
everything seems to work all right.
More information about the R-devel