[Rd] pb with dyn.load - fortran code now attached
Gilles GUILLOT
gilles.guillot at inapg.inra.fr
Wed Oct 26 15:14:40 CEST 2005
Hi,
here are a couple of strange things happening with R.2.2.0 compiled
under Mandrake-10.1
At the begining of the story I have segmentation fault
using package RandomFields in conjuction with some Fortran code of mine
loaded with dyn.load.
One of my fortran programs contains a subroutine named fstat
Trying to trace , I simplified the sequence as much as possible
and I end up with the the simple fortran programs and R code atached
which give the result below.
Any explanation about the strange things below and what
I should do to avoid them would help.
Gilles
#########################################
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()
QUESTION 2:
[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
>is.loaded("fstat")
[1] FALSE
> is.loaded("fstat_")
[1] FALSE
> dyn.load("~/tmp/test1.so")
> is.loaded("fstat")
[1] FALSE
> is.loaded("fstat_")
[1] TRUE
## why ?
> dyn.load("~/tmp/test2.so")
> .Fortran(name="fstat",
+ as.integer(999),
+ as.integer(100),
+ as.integer(200))
[[1]]
[1] 1073913012
[[2]]
[1] 0
[[3]]
[1] 200
## pb in memory management ?
-------------- next part --------------
system("R CMD SHLIB ~/tmp/test1.f")
system("R CMD SHLIB ~/tmp/test2.f")
is.loaded("sub")
is.loaded("sub_")
dyn.load("~/tmp/test1.so")
is.loaded("sub")
is.loaded("sub_")
q()
R
s.loaded("fstat")
is.loaded("fstat_")
dyn.load("~/tmp/test1.so")
is.loaded("fstat")
is.loaded("fstat_")
dyn.load("~/tmp/test2.so")
.Fortran(name="fstat",
as.integer(999),
as.integer(100),
as.integer(200))
More information about the R-devel
mailing list