[R] (not) compiling fortran -- dynamic loading problem
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Wed Feb 2 08:49:06 CET 2000
On Tue, 1 Feb 2000, Matthew Wiener wrote:
> Hi, everyone. This may be properly a fortran question rather than an R
> question.
>
> I'm trying to add a few print statements to otherwise working fortran code
> in one of the libraries so I can see what's going on in the code. I have
> no problem doing so on an SGI machine, but under LinuxPPC I've run into a
> problem. The code compiles and creates a shared object (.so), but when I
> issue the "library" command to load the new (printing) version, I get the
> following error:
>
> undefined symbol: do_lio
It's in libg2c.a, in module libg2c.a[dolio.o], on gcc 2.95.2. I just ran
nm over the g77 libraries.
> I assume this must be some fortran i/o function, and perhaps I'm missing a
> library. But I've never seen this symbol before, and I can't find it in
> the info pages for g77 (or on the LinuxPPC mailing lists). Does anyone
> have any idea where I can find this library on LinuxPPC?
>
> (Or do I have the wrong idea about what the problem is?)
You may need to adjust FLIBS. On my gcc/g77 build (Solaris), I have
FLIBS = -L/usr/local/lib -L/usr/ccs/lib -L/usr/lib
-L/ext/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2 -L/usr/ccs/bin -L/usr/ccs/lib
-L/ext/gcc-2.95.2/lib -lg2c -lm
so libg2c does get searched.
However, mixing C and Fortran I/O from R is not a good idea. That's why we
have subroutines dblepr, intpr and realpr for seeing what's going on in the
code. They are documented in the Writing R Extensions manual in the
development version, and I can quote a bit (please ignore the texinfo
markup):
In theory Fortran @code{write} and @code{print} statements can be used,
but its output may not interleave well with that of C, and will be
invisible on GUI interfaces. They are best avoided.
Three subroutines are provided to ease the output of information from
Fortran code.
@example
subroutine dblepr(label, nchar, data, ndata)
subroutine realpr(label, nchar, data, ndata)
subroutine intpr (label, nchar, data, ndata)
@end example
@noindent
Here @code{label} is a character label of up to 255 characters,
@code{nchar} is its length (which can be @code{-1} if the whole label is
to be used), and @code{data} is an array of length at least @code{ndata}
of the appropriate type (@code{double precision}, @code{real} and
@code{integer} respectively). These routines print the label on one
line and then print @code{data} as if it were an @R{} vector on
subsequent line(s). They work with @code{ndata = 0} and so can be used
to print a label alone.
The actual subroutines have been in R for a year or so, but the
documentation is new (like for many things in R).
--
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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list