Re: [Rd] Calling Fortran90 code from R

From: Hartwig Deneke <>
Date: Tue, 29 Dec 2009 13:44:22 +0100

2009/12/29 Simone Giannerini <>:
> 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 ************************
> dyn.load("")
> is.loaded("foo")
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.

Kind Regards,
Hartwig mailing list Received on Tue 29 Dec 2009 - 12:46:44 GMT

This archive was generated by hypermail 2.2.0 : Tue 29 Dec 2009 - 22:01:16 GMT