Setzer.Woodrow at epamail.epa.gov
2008-Apr-09 14:44 UTC
[Rd] getNativeSymbolInfo fails with Fortran symbol.
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
Prof Brian Ripley
2008-Apr-10 07:33 UTC
[Rd] getNativeSymbolInfo fails with Fortran symbol.
It's a bug -- unlike is.loaded, getNativeSymbolInfo seems unaware of Fortran names unless registered. Will be fixed in 2.7.0. On Wed, 9 Apr 2008, Setzer.Woodrow at epamail.epa.gov wrote:> > > 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 > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Maybe Matching Threads
- getNativeSymbolInfo("user_unif_rand") returns different results on windows and linux
- problem typcasting return of R_ExternalPtrAddr(SEXP s)
- How to call directly "dotTcl" C-function of the tcltk-package from the C-code of an external package?
- Foreign function call
- How to call directly "dotTcl" C-function of the tcltk-package from the C-code of an external package?