[R] Writing R package that call Fortran codes

Kodalore Vijayan, Vineetha W vwkv13 at mun.ca
Wed Jun 15 22:20:01 CEST 2016


Hi,

I'm trying to write an R package that calls a Fortran subroutine on my  Mac
os x El Capitan with Xcode 7 and gfortran 6.1, R 3.3.0.   I can build and
load the library but when I try to use it in R I get this error:
>library(NEpidemic)
>random_epi(variable_names)

Error in .Fortran("random_epi", : "random_pi" not resolved from current
namespace (NEpidemic).

Then I  tried adding useDynLib(random_epi.f95) in the NAMESPACE file,
additional to useDynLib(NEpidemic). After doing that I couldn't build the
package and it gave me another error:

Error in library.dynam(lib, package, package.lib) :
  shared object ‘random_epi.so’ not found
Error: loading failed
Execution halted
ERROR: loading failed

When I checked my src folder, there is only random_epi.o file.  How can I
fix this issue? Any help would be much appreciated. I'm vey new to both R
and Fortran coding, especially in package building.

Thanks in advance!
Vineetha

	[[alternative HTML version deleted]]



More information about the R-help mailing list