[R] REading the netCDF format into R

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 22 16:34:00 CET 2000


On Fri, 22 Dec 2000, Rasmus E. Benestad wrote:

> Hi!
> 
> I have been coding a C-program which will read data from the
> netCDF format (a commonly used file format in the geophysical research
> community: see Unidata's URL for explanation:
> http://www.unidata.ucar.edu/packages/netcdf/), and have got to the point
> where I don't know what the error message mean. The C-program is called
> nc2r.c.

First off, have you looked at the netCDF package in the Devel section of
CRAN?

Second, please do not expect us to debug things on a versiuon of R that is
about 6 versions old.  Please get 1.2.0, re-write your code to the current 
standards and try again, as your code will not wokr on the current
systems.  (Actually, neither will netCDF, but I sent Thomas Lumley a
patched version that will.)

> The code is compiled, and I start R:
> 
> R : Copyright 1999, The R Development Core Team
> Version 0.90.1  (December 15, 1999)
          ^^^^^^

> > dyn.load(paste("nc2r", .Platform$dynlib.ext, sep=""))
> Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to
> load shared library "/home/kareb/netcdf/nc2r.so":
>   /home/kareb/netcdf/nc2r.so: undefined symbol: __dso_handle
> 
> The symbol "__dso_handle" I presume is defined in Rinternals.h or some
> R-routines, or am I wrong? 

You are wrong.  It is defined in your shared object, not R.  Use nm to
check this out.

> Are my R-path set incorrectly? Why does R say
> that it cannot load nc2r.so, when this file is in the local directory?

Because it cannot resolve the symbol: it gave you a detailed explanation.

> There were some clashes between definitions in R.h and Rinternals.h, so
> I did not include R.h.

Not any more (and I don;t recall there ever being): please upgrade to a
tolerably recent version of R, like 1.2.0.

> Also, is ther any way of returning more than one object from the C-call
> (ie. the data field, longitude vector, latitude vector, time vector, and
> the missing value)

Yes, return a list just as you would in S code.

[...[

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