Ed's pseudocode for HDF5 approach