[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.:

test.f:


      subroutine initaquaphy(odeparms)

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

       call odeparms(19, pars)

      return
      end

$ 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.

triggerbug.R:

system("R CMD SHLIB test.f")
dyn.load(paste("test",.Platform$dynlib.ext,sep=""))
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")
$name
[1] "initaquaphy_"

$address
<pointer: 0x1c03f0>
attr(,"class")
[1] "NativeSymbol"

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

attr(,"class")
[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--

Version:
 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)

Locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

R. Woodrow Setzer, Ph. D.
National Center for Computational Toxicology
http://www.epa.gov/comptox
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