Re: [Rd] Calling Fortran90 code from R

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

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 ************************
> dyn.load("foo.so")
> is.loaded("foo")
>
> TRUE
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



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel 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