[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #OON-349097]: adapting netCDF for ROOT from CERN



> User Help:
>
> I'm not sure who to contact concerning what I want to
> do with netCDF, so I am sending to this email address.

You have found the correct place! ;-)

>
> I would appreciate if you would direct this to the
> proper resource, if this is the wrong forum.
>
> I would like to adapt netCDF to be used with ROOT from
> CERN; ie. in a ROOT session, be able to read and
> manipulate netCDF files. Specifically, I want to open,
> process,  and save data from AIA/ANDI mass
> spectrometry files.
>

I believe what you want to do is to write code for ROOT, and link to the netCDF
library. For this you will not have to figure out how to build netCDF yourself,
but just build it and figure out how to link to it from ROOT.

> I found on /sourceforge.net/projects/andi the
> ms10aux.c ms10enum.c ms10io.c and ms10io.h and ms10.h
> files. I have successfully compiled them for inclusion
> with cdf2ascii.c, provided in COMSPARI, GPL software
> from Katz/Hau.
>
> ROOT uses C++, and I compiled the ms10*.* files with
> g++ with out warnings. The cdf2ascii.c source would
> not compile with g++.
>
> With help from C. Holms who has worked on ROOT
> development, I was able to create a shared ROOT
> library, but then could not open netCDF files.
>
> What I want to do is adapt netCDF files for use with
> ROOT as AstroROOT has provided an interface for
> astronomers to use ROOT with FITS, a standard file
> format for images.  Using the 'wrapper' code [or what
> ever the adaptation is], FITS files can be read and
> saved in standard ROOT file formates, such as TTree.
>
> I was able to build a working c++ netCDF exe using the
> follow commands, at the top of the Makefile, and with
> the following files (I picked what appeared to be the
> required files from all of the files in the netCDF
> source.)
>
>

It seems unlikely to me that this is a good idea. Why not use the build system
already included with netCDF?

However, to answer your question, the easiest way to get the information you
need is to build netCDF and examine the output of "make all" to see how netCDF
is built. This can and does change with new releases.

While we guarantee that the API will not change, we do sometimes change the
names and contents of the source code files, since this does not affect library
users.

> # Here's what the hand-crafted Makefile did to build
> cxx:
> # c++ -c -g -O2 -I../libsrc -I.   -Df2cFortran
> netcdf.cpp
> # c++ -c -g -O2 -I../libsrc -I.   -Df2cFortran
> ncvalues.cpp
> # ar cru libnetcdf_c++.a netcdf.o ncvalues.o
> # ranlib libnetcdf_c++.a
> # c++ -c -g -O2 -I../libsrc -I.   -Df2cFortran
> nctst.cpp
> # c++ -o nctst -g -O2  nctst.o libnetcdf_c++.a
> -L../libsrc -lnetcdf
>
>
> .deps
> attr.c
> attr.m4
> COPYRIGHT
> config.h
> dim.c
> error.c
> fbits.h
> ffio.c
> libnetcdf_c++.a
> libvers.c
> nc3convert.h
> nc.c
> nc.h
> ncio.h
> nctst
> nctst_64bit_offset.nc
> nctst_classic.nc
> nctst.cpp
> nctst.o
> ncvalues.cpp
> ncvalues.h
> ncvalues.o
> ncx.c
> ncx.h
> ncx.m4
> netcdf.3
> netcdf3.h
> netcdf.cpp
> netcdfcpp.h
> netcdf.h
> netcdf.hh
> netcdf.o
> NetCDF.so
> onstack.h
> posixio.c
> putget.c
> putget.m4
> rnd.h
> string.c
> t_nc.c
> tst_failure.cpp
> v1hpg.c
> v2i.c
> var.c
>
> This was able to compile and pass the two C++ tests.
>
> Of course I need to know what is required for a C/C++
> build, including all tests not related to Fortran, in
> order to ensure that the installation works.

NetCDF tests are run in the nc_test directory, as well as the libsrc and cxx
directories. I suggest you run "make check" to see the exact tests.

You can turn off all fortran builds or tests with the --disable-f77 option to
configure. You might also want to use --disable-utilities and
--disable-examples to cause the build and test of ncdump/ncgen and the netCDF
examples to be skipped, to simplify the build. (Although these also function as
tests of the C and C++ APIs.)
>
> I would appreciate any information that could be
> provided as to what I need to include in order to
> build a working, robust C++ interface that I can then
> learn to adapt to ROOT. For example, what do the .deps
> files do? Are they required? All seem to be contain
> the word dummy.

Robust is the issue!

Whatever you do will not work with netCDF-4.0, which is due out soon, and
complicates the build process quite a bit. I don't think you need to get that
involved with building netCDF.

>
> I assume that with a working C/C++ build I can figure
> out how to include the AIA/ANDI files. It seems that a
> .so is the correct method of including mass spec
> support.

NetCDF can be built as a shared library, if that is what you need. Use the
--enable-shared option to configure.

Perhaps what you want to do is build netCDF and just link to it...

>
> ROOT has a significant /test directory. It seems that,
> when I know the files required for C/C++ testing, I
> will be able to include those in the /test directory.
>
> Thanking you in advance for any help you can provide.
> It seems that netCDF 4.0 with HDF5 support would allow
> ROOT users the same flexibility as GDL (and IDL) for
> data processing.
>
>

I think what you want to do is use the netCDF library, but not try and include
any of it's code in with your code. Just link to it and use it from your ROOT
application. Then, when we release new versions, you can just drop them in, and
they will work without any extra effort on your part.

Getting the C and C++ APIs to build and test correctly and portably on many
platforms is non-trivial. If you have to do that, it will mean possibly a lot
of work for you every time we do a release.

You will have my sympathies, because I do the current netCDF build! ;-)

Thanks,

Ed

Ticket Details
===================
Ticket ID: OON-349097
Department: Support netCDF
Priority: Normal
Status: Closed