3

I am trying to trigger a FORTRAN code from R. For that I am creating a .so file by giving command R CMD SHLIB filename.f The .so file is created without any warnings(!!) To lead the file in R, I give the following command in R

dyn.load("filename.so")

The file gets loaded as it shows when I give command getLoadedDlls() in R. But when I try to run it using .Fortran("filename") it throws an error

Error in .Fortran("filename") : Fortran symbol name "filename" not in load table

zx8754
  • 52,746
  • 12
  • 114
  • 209
  • Have you read http://stackoverflow.com/q/18767463 ? Essentially it's possible that the compiler will append an "_" (or two) to the end of the routine name. The `.Fortran` may attempt to add this automatically. There are various tools to show you the contents of a "dll" file so you can try to find out what name is actually used, such as http://stackoverflow.com/a/375284 This may help identify if the correct name is being used. – d_1999 Jun 14 '16 at 11:23
  • Sorry I realised you're using a `.so` extension so you're probably on linux, in which case you can try the `nm` command so see what symbols are present in the library. – d_1999 Jun 14 '16 at 11:29
  • Tried `.Call("filename")`? – J_F Jun 14 '16 at 11:37
  • nm filename.so gave me a bunch of output results.Like - " 00000000002067b8 d __CTOR_END__ " and a lot – curious programmer Jun 14 '16 at 11:39
  • Maybe you can try `readelf` (see http://stackoverflow.com/q/34732) or try `nm filename.so | grep -i X` where `X` is the routine name that you're trying to call. – d_1999 Jun 14 '16 at 11:42
  • @J_F .Call ("filename") throws error - "Error in .Call("filename") : C symbol name "filename" not in load table" – curious programmer Jun 14 '16 at 11:43
  • According to this discussion https://stat.ethz.ch/pipermail/r-devel/2011-May/060948.html you could try `.Fortran("filename_")`. But this is only a guess – J_F Jun 14 '16 at 12:13
  • @d_1999 Fortran appended "_" after the routine name.Thanks for the help. – curious programmer Jun 14 '16 at 12:15
  • @curiousprogrammer if that is the solution to your problem then you may wish to answer your own question. – d_1999 Jun 14 '16 at 12:20

0 Answers0