Can not open HDF5 file created with v1.14.3 on a machine with v1.8.12

Dear all,

This is a beginner’s question.

I have created a very simple HDF5 file on my machine A, which has the HDF5 library v1.14.3 installed. It works fine, i.e. I can read it in in my program, and I can use h5dump, h5debug normally.

Then I copy it to a machine B with the HDF5 library v1.8.12 installed. This does not work at all, i.e. even h5debug will not recognize it as an HDF5 file:

$ h5debug file.hdf5
HDF5-DIAG: Error detected in HDF5 (1.8.12) thread 0:
  #000: ../../src/H5F.c line 1585 in H5Fopen(): unable to open file
    major: File accessibilty
    minor: Unable to open file
  #001: ../../src/H5F.c line 1376 in H5F_open(): unable to read superblock
    major: File accessibilty
    minor: Read failed
  #002: ../../src/H5Fsuper.c line 336 in H5F_super_read(): file signature not found
    major: File accessibilty
    minor: Not an HDF5 file
cannot open file

Can I somehow make the file more compatible with older version when I create it on machine A? Or do I need to update the HDF5 library on machine B?

Any help would be greatly appreciated.

Best wishes,

We have a forward/backward compatibility policy that governs library behavior when accessing files generated with a different format specification version. A lot of detail can be found in this RFC.

The gist is this:

  • (Backward) Newer library versions can access all earlier versions, i.e., v1.14.3 is happy with everything that came before.
  • (Forward) Older library versions can access HDF5 files “from the future” if they do not contain file format features unavailable with the older library version, i.e., accessing a 1.14.3 generated file with 1.8.12 should be fine as long as there’s nothing “fancier” going on.

However, your error message suggests that something else is going on:

#002: ../../src/H5Fsuper.c line 336 in H5F_super_read(): file signature not found

What do you see if you run this command:

od -c example.h5 | head -n 1

It should look like this:

0000000 211   H   D   F  \r  \n 032  \n 003  \b  \b  \0  \0  \0  \0  \0

The signature is the first 8 bytes 211 H D F \r \n 032 \n and the same for all specification versions.

(See the spec.)

Maybe something fishy is going on with the transfer…

OK? G.

1 Like

Thank you for the detailed information and the link, I was not aware of the policy.

When using the suggested od command, I actually noticed that the file was empty. I then noticed this only happened after trying to read in, and then I found the actual problem: I had a copy&paste error in my code, I opened the file with the Overwrite tag instead of ReadOnly etc.

Sorry for that. And thank you in any case, you prevented me from testing a whole lot of other things before noticing this particular stupidity of mine.

1 Like

There is a good example of how to write a file with backward accessibility, here:

1 Like

Thank you, Dave! We’ll keep this in mind.