Track group insertion order for the whole file

I am trying to write an HDF5 for which I want to track the insertion order for all the groups. However, I can only see properties regarding insertion order for the groups, and not for the whole file.
Setting the approiate flags for the root group only affects that groups (as expected), and not the whole file.

Is there any way to create the file such that it tracks the insertion group for all the groups in the hierarchy?

When you say “the whole file,” do you mean the root group or all groups in the file? For the root group, this can be achieved by going through the file creation property list. Other than reusing the group creation property list (that has H5P_CRT_ORDER_TRACKED set), I’m unaware of a global setting/function to achieve this.


I meant all the groups in the file.

Hi @juanjo.casafranca,

Yes, like @gheber wrote it is not possible to track the order of objects’ creation globally - in other words, it has to be done to every (sub)group you create so that this feature can be achieved.

That said, we were under the assumption that it is not possible to track the order of objects’ creation in the root group (of an HDF5 file). @gheber, would it be possible to share a code snippet that illustrates this as it would be interesting to extend HDFql CREATE FILE operation with it. FYI, we just tested it at our side but without success unfortunately.


#include "hdf5.h"

#include <stdio.h>
#include <stdlib.h>

int main()
  int retval = EXIT_SUCCESS;
  hid_t fcpl, file, root, gcpl;
  unsigned flg = 0;
  if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) == H5I_INVALID_HID) {
    retval = EXIT_FAILURE;
    goto fail_fcpl;
  H5Pset_link_creation_order(fcpl, H5P_CRT_ORDER_TRACKED);
  if ((file = H5Fcreate("my.h5", H5F_ACC_TRUNC, fcpl, H5P_DEFAULT))
      == H5I_INVALID_HID) {
    retval = EXIT_FAILURE;
    goto fail_file;
  if ((root = H5Gopen(file, ".", H5P_DEFAULT)) == H5I_INVALID_HID) {
    retval = EXIT_FAILURE;
    goto fail_root;
  if ((gcpl = H5Gget_create_plist(root)) == H5I_INVALID_HID) {
    retval = EXIT_FAILURE;
    goto fail_gcpl;

  H5Pget_link_creation_order(gcpl, &flg);
  printf("Creation order tracked? %s\n", flg ? "Yes." : "Nada.");
  return retval;

Merry Christmas!

1 Like

Hi @gheber,

Many thanks for the code snippet - we already updated HDFql CREATE FILE operation based on this snippet and it works perfectly!

Merry Christmas :slight_smile: