[Rd] pb with dyn.load - fortran code now attached

Paul Roebuck roebuck at mdanderson.org
Wed Oct 26 20:10:52 CEST 2005


On Wed, 26 Oct 2005, Prof Brian Ripley wrote:

> On Wed, 26 Oct 2005, Paul Roebuck wrote:
>
> > On Wed, 26 Oct 2005, Gilles GUILLOT wrote:
> >
> >> QUESTION 1:
> >> [guillot at laplace guillot]$ R
> >> R : Copyright 2005, The R Foundation for Statistical Computing
> >> Version 2.2.0  (2005-10-06 r35749)
> >> ISBN 3-900051-07-0
> >>
> >> >system("R CMD SHLIB ~/tmp/test1.f")
> >> g77   -fPIC  -g -O2 -c /home/guillot/tmp/test1.f -o /home/guillot/tmp/test1.o
> >> gcc -shared -L/usr/local/lib
> >> -o /home/guillot/tmp/test1.so /home/guillot/tmp/test1.o  -lg2c -lm -lgcc_s
> >>> system("R CMD SHLIB ~/tmp/test2.f")
> >> g77   -fPIC  -g -O2 -c /home/guillot/tmp/test2.f -o /home/guillot/tmp/test2.o
> >> gcc -shared -L/usr/local/lib
> >> -o /home/guillot/tmp/test2.so /home/guillot/tmp/test2.o  -lg2c -lm -lgcc_s
> >>>
> >>> is.loaded("sub")
> >> [1] FALSE
> >>> is.loaded("sub_")
> >> [1] FALSE
> >>>
> >> ## OK
> >>> dyn.load("~/tmp/test1.so")
> >>> is.loaded("sub")
> >> [1] FALSE
> >>> is.loaded("sub_")
> >> [1] TRUE
> >>>
> >> ## it seems it does not comply with the 'value' section of the help
> >> ## of function is.loaded:
> >> ## "it needs the
> >> ##    name you would give to '.C' or '.Fortran' and *not* that remapped
> >> ##    by 'symbol.C' and 'symbol.For'."
> >> ##
> >> ## am i missing something ?
> >>> q()
> >
> > The is.loaded method needs the argument to look exactly
> > like the associated output from 'nm' (i.e., symbol name).
> >
> > $ nm ~/tmp/test1.so | grep sub
> >
> > Thus, you are manually asking for the following
> >
> >> is.loaded(symbol.For("sub"))
> >
> > The call to .Fortran use the (lowercase) name of the subroutine
> > as it would appear in the Fortran source code.
> >
> > .Fortran("sub", ...)
>
> Not at all the whole story.  First (unfortunately), the case mapping is
> OS-dependent and even compiler-dependent.  Second, look at stats.so which
> has
>
> 00030cf0 T supsmu_
>
> yet
>
> > is.loaded("supsmu_")
> [1] FALSE
> > is.loaded("supsmu")
> [1] TRUE
>
> That is a Fortran entry point, and it complies with the description
> quoted.
>
> What is.loaded() needs depends on how the symbol would be found
> and so it is not much use.

My example using symbol.For was outdated as I haven't
used the function in some time. I would suggest a
modification to the man page for this method though.

Rather than using the vague word 'nowadays'
     available for use in '.C' or '.Fortran': nowadays it needs the
it might mention when this change took place.
     available for use in '.C' or '.Fortran': as of R-2.x.x, it needs the

I know it occurred after R-1.9.1 but don't know when.

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)



More information about the R-devel mailing list