[Rd] getNativeSymbolInfo fails with Fortran symbol.

Setzer.Woodrow at epamail.epa.gov Setzer.Woodrow at epamail.epa.gov
Wed Apr 9 16:44:23 CEST 2008

In the following code routine 'initaquaphy' is defined in Fortran,
and dynamically loaded into R.:


      subroutine initaquaphy(odeparms)

      external odeparms
      double precision pars(19)
      common /myparms/pars

       call odeparms(19, pars)


$ R CMD SHLIB Aquaphy.f
gfortran   -fpic  -g -O2 -c test.f -o test.o
gcc -std=gnu99 -shared -L/usr/local/lib -o test.so test.o  -lgfortran -lm

and linked into the package dll (or so).  Help for is.loaded() and
getNativeSymbolInfo() say not to use symbol.For() to convert
to Fortran-specific symbols.  However, on Linux, getNativeSymbolInfo
is unable to find 'initaquaphy' in 'test.so', but does find
'initaquaphy_'.  Note that is.loaded() works as advertised.  Furthermore,
this code works in Windows, R-2.6.2patched44759.


system("R CMD SHLIB test.f")
is.loaded("initaquaphy", PACKAGE="test")
getNativeSymbolInfo("initaquaphy_", PACKAGE="test")
getNativeSymbolInfo("initaquaphy", PACKAGE="test")
cat("All Done")

Resulting in:

> source("triggerbug.R", echo=TRUE, print.eval=TRUE)

> system("R CMD SHLIB test.f")
gfortran   -fpic  -g -O2 -c test.f -o test.o
gcc -std=gnu99 -shared -L/usr/local/lib -o test.so test.o  -lgfortran -lm

> dyn.load(paste("test",.Platform$dynlib.ext,sep=""))

> is.loaded("initaquaphy", PACKAGE="test")
[1] TRUE

> getNativeSymbolInfo("initaquaphy_", PACKAGE="test")
[1] "initaquaphy_"

<pointer: 0x1c03f0>
[1] "NativeSymbol"

DLL name: test
Filename: /home/setzer/tasks/Programming_Projects/test.so
Dynamic lookup: TRUE

[1] "NativeSymbolInfo"

> getNativeSymbolInfo("initaquaphy", PACKAGE="test")
Error in FUN("initaquaphy"[[1L]], ...) :
  no such symbol initaquaphy in package test

Have I misunderstood the help page, or is this a bug?

--please do not edit the information below--

 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = beta
 major = 2
 minor = 7.0
 year = 2008
 month = 04
 day = 07
 svn rev = 45159
 language = R
 version.string = R version 2.7.0 beta (2008-04-07 r45159)


Search Path:
 .GlobalEnv, package:deSolve, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads,

R. Woodrow Setzer, Ph. D.
National Center for Computational Toxicology
US Environmental Protection Agency
Mail Drop B205-01/US EPA/RTP, NC 27711
Ph: (919) 541-0128    Fax: (919) 541-1194

More information about the R-devel mailing list