I think we did get your explanation. We are (trying to) tell you to write a C++ function (declared in an extern “C” block that you can call from openmpi. This C++ wrapper function will be able to call Root.
Hi,
Excuse me, please, if I am being annoying, but I know that C++ functions can be called from C and viceversa.
However, I will never be capable to use the Giuseppe Vacanti’s program to convert hdf5 files to root ones if I don’t have neither the C++ headers nor the C++ libraries for HDF5:
H5Cpp.h and libhdf5_cpp.so don’t exist in my system, but hdf5.h and libhdf5.so.
[quote=“delaossa”]Hi,
Excuse me, please, if I am being annoying, but I know that C++ functions can be called from C and viceversa.
However, I will never be capable to use the Giuseppe Vacanti’s program to convert hdf5 files to root ones if I don’t have neither the C++ headers nor the C++ libraries for HDF5:
H5Cpp.h and libhdf5_cpp.so don’t exist in my system, but hdf5.h and libhdf5.so.
Cheers, Alberto[/quote]
Yes, you won’t be able to use his program. But you ought to be able to use it to figure out how to write your own. If you don’t want to do that, then maybe your effort would best be spent finding the libraries so that his will work for you as is.
Ok! That’s what I thought… thanks.
Anyway, I managed to compile C++ libraries for HDF5 and then, I could finally run this program as it is (pure C++).
However, it is not working properly with my data files and I don’t know why.
It fails in line 89:
const int nm = type.getNmembers();
throwing the following message:
[quote]HDF5-DIAG: Error detected in HDF5 (1.8.7) thread 0: #000: H5Tfields.c line 90 in H5Tget_nmembers(): cannot return member number
major: Invalid arguments to routine
minor: Inappropriate type #001: H5Tfields.c line 131 in H5T_get_nmembers(): operation not supported for type class
major: Invalid arguments to routine
minor: Inappropriate type
terminate called after throwing an instance of ‘H5::DataTypeIException’
Abort[/quote]
Here I attach the file which I am trying to convert: gamma.h5.tar.gz (842 Bytes)
It is a very simple one with just 1 dataset called ‘gamma_|charge|’ under the main ‘/’ group.
Any clues?
Hello all,
After several days struggling with the HDF5 to ROOT conversion, I have created a program based on the original one posted by Giuseppe Vacanti:hdf2root.tar.gz (3.74 KB)
It converts the whole HDF5 structure into TTrees:
For every Group in the HDF5 file, hdf2root creates a TTree (named as the orginal Group) which stores the info contained in the original DataSets. Moreover, the Attributes of the Group are stored in another TTree (named as the original group plus “_att”), together with the Attributes of every DataSet in the Group.
The program is thought to work in any kind of HDF5 file and make a “general” conversion.
It works in all the data files I have tested, which amounts to 4 or 5 different types (only!).
A clear limitation would be how to handle more complex DataTypes. Up to know, only simple types are supported, but this could be enough for many users (it is actually enough for the files I have to handle!).
The usage is quite simple:
hdf2root just needs the original HDF5 file as input to create a root file with the same name. If you want a different output name, put it in as a second argument. If the –seq is set, hdf2root create the TTrees for the DataSets in sequential mode. This means that the first dimension of the data set is used like an “event index” (if you know what I mean…).
I aim you (interested people) to take a look and send some feedback.
One could start with the example file I posted in a previous post in this thread (gamma.h5).
Warning: I am only experiencing problems with the conversion of hdf5_strings mostly present in Attributes.
The size of these objects is not 1 to 1 with their length and, as a result, larger strings of characters are stored in root unnecessarily. This could be a problem of the particular hdf5 files I am using, instead of the converter itself.
I tried to compile the program you attached but I get the msg below. I am guessing that I am missing mpif77. I tried to install that through yum searching for openmpi but none of the packages I found help. Do you know if mpif77 is compatible with SLC6?
======================================
[wht34@icarus hdf2root]$ make
make: mpif77: Command not found
Linking hdf2root
hdf2root.o: In function main': /home/wht34/MyCodes/hdf2root/hdf2root.cpp:394: undefined reference toH5check_version’
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/…/…/…/…/lib64/libhdf5_cpp.so: undefined reference to H5Tunregister' /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libhdf5_cpp.so: undefined reference toH5set_free_list_limits’
Try this new version:hdf2root.tar.gz (4.86 KB)
You will need a root installation and the HDF5 libraries for C++.
There are a configuration script where you can define the paths to the needed libraries.
Let me know wether you succeed to compile and or not.
I modified the env.sh file to point to my root installation directory. I am not sure if I pointed the hdf5 interface correctly but they’re the only hdf5 libraries I found on my computer. Make is still complaining about
undefined reference to `H5check_version’ and so on with all these H5 commands being undefined.
The compiler also has to know where the headers for HDF5 are.
If in the configuration script you define the environment variable HDF5CPP, the Makefile would define the path to the HDF5 headers in this way: $HDF5CPP/include.
The code compiles now but I run into this runtime error now. I have libhdf5_cpp.so.6 but not 8 in my /usr/lib64.
[wht34@icarus hdf2root]$ ./hdf2root --ver lux10_20130611T0605_f000001_eb00014.hdf5 lux10_20130611T0605_f000001_eb00014.hdf5.root
./hdf2root: error while loading shared libraries: libhdf5_cpp.so.8: cannot open shared object file: No such file or directory
[wht34@icarus hdf2root]$ ldd hdf2root.e | grep libhdf5_cpp.so.8
libhdf5_cpp.so.8 => not found
If the hdf5 libraries are located at /usr/local/hdf5/lib, the include files should be at /usr/local/hdf5/include.
In the configuration script you should define:
export HDF5CPP= /usr/local/hdf5
export LD_LIBRARY_PATH=$HDF5CPP/lib:$LD_LIBRARY_PATH
By the way, in which system are you trying to build the program?
DYLD_LIBRARY_PATH is used for macos, for linux systems it is LD_LIBRARY_PATH the variable which holds the path to the needed libraries.
Hello,
Thanks to your interest I have updated the code into a more professional fashion.
I have tried it and it works in both linux and mac os platforms.
Give it a try: github.com/delaossa/hdf2root
In the config folder there are various examples of configuration files.
Pick up the most similar to your system and modify it accordingly.
Good luck!
The git version of your code compiles fine but the executable still doesn’t do anything to the hdf5 test file.
It’ll just say converting … , but no root output comes out with hdf2root test.hdf5 test.root.
Here’s the log for the compilation and my env.sh file.