[R] Loading to R of Fortran DLL

Thomas Lumley
Fri, 18 Jan 2002 16:38:43 -0000

On Sat, 19 Jan 2002 baba at mxr.mesh.ne.jp wrote:

> Dear R-ers
>
> Could you tell me how to build DLL from Fortran source and use the DLL in
R?
>
> Environments:
> Windows 98
> Fortran compiler : DIGITAL Visual Fortran Optimizing Compiler Version: V5.0
> R v1.2.3
     ^^^^^
  that isn't the problem, but you really should upgrade at least once a
year.


> EXAMPLE SOURCE : FOO.FOR
> -------------------------------------
> 		SUBROUTINE FOO(I,J)
> 		INTEGER I,J
> 		I=0
> 		J=I+1
> 		END
> -------------------------------------
>

>
> R> print(dyn.load("FOO.DLL"))
> NULL
> R>
>
> I could not load FOO.DLL. I am not sure whether FOO.DLL is bad or not.

That looks as if you *did* load it. There was no error message, and
dyn.load() is supposed to return NULL (though this could be documented
better).

To check, you can try

   is.loaded(symbol.For("FOO"))

to see if SUBROUTINE FOO is accessible to .Fortran calls.

	-thomas

Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle