Openpmd-api: Read of Mesh with Constant Record

Created on 18 Sep 2018  路  3Comments  路  Source: openPMD/openPMD-api

Describe the bug
Reading a files with mesh data with constant record components fails.

To Reproduce

I added the following sample file (constant, scalar mesh "rho"): 3_write_serial.h5.tar.gz

#include <openPMD/openPMD.hpp>

int main()
{
    using openPMD;

    Series series = Series(
        "samples/3_write_serial.h5",
        AccessType::READ_ONLY
    );

    return 0;
}

fails with:

HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 0:
  #000: ../../../src/H5A.c line 438 in H5Aopen(): unable to load attribute info from object header for attribute: 'position'
    major: Attribute
    minor: Unable to initialize object
  #001: ../../../src/H5Oattribute.c line 530 in H5O_attr_open_by_name(): can't locate attribute: 'position'
    major: Attribute
    minor: Object not found
terminate called after throwing an instance of 'std::runtime_error'
  what():  Internal error: Failed to open HDF5 attribute during attribute read

Expected behavior
Should be able to read the position attribute from a constant record component.

Also, if position is indeed missing, we should handle the backend (e..g HDF5) error gracefully and throw ourselves. The read should not crash in the HDF5 layer.

Software Environment:

  • version of openPMD-api: 0.5.0-alpha
  • installed openPMD-api via: from source
  • operating system: Debian GNU/Linux 9.5 (stretch)
  • machine: local laptop
  • name and version of Python implementation: CPython 3.6.6
  • version of HDF5: 1.10.0.1
  • version of ADIOS1: 1.13.1
  • name and version of MPI: OpenMPI 2.0.2
affects latest release bug internal

Most helpful comment

This is probably easier than expected.

The code of interest for reading constant scalar meshes is in Iteration::read(), Mesh::read() and MeshRecordComponent::read().
It looks mostly correct, but lacks a call to open the path for the RecordComponent (the same path that has already been opened for the Record, analogous to the flow for the non-constant scalar mesh).
As the underlying Writable does not know its corresponding location in the HDF5 file, the attribute read for position fails.

I can only test this later today, but my first shot will be to replace code in Iteration::read() with

if( value != end && shape != end )
{
    MeshRecordComponent& mrc = m[MeshRecordComponent::SCALAR];
    mrc.parent = m.parent;
    IOHandler->enqueue(IOTask(&mrc, pOpen));
    IOHandler->flush();
    *mrc.m_isConstant = true;
}

All 3 comments

cc @C0nsultant any idea what's wrong here? Looks to me like the attribute is properly written in const and non-constant records but the logic for reading might be off in the constant record component case?

@ax3l will look into it when I have some spare time on my hands today.

Without much digging: The reference file looks fine.

This is probably easier than expected.

The code of interest for reading constant scalar meshes is in Iteration::read(), Mesh::read() and MeshRecordComponent::read().
It looks mostly correct, but lacks a call to open the path for the RecordComponent (the same path that has already been opened for the Record, analogous to the flow for the non-constant scalar mesh).
As the underlying Writable does not know its corresponding location in the HDF5 file, the attribute read for position fails.

I can only test this later today, but my first shot will be to replace code in Iteration::read() with

if( value != end && shape != end )
{
    MeshRecordComponent& mrc = m[MeshRecordComponent::SCALAR];
    mrc.parent = m.parent;
    IOHandler->enqueue(IOTask(&mrc, pOpen));
    IOHandler->flush();
    *mrc.m_isConstant = true;
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

PrometheusPi picture PrometheusPi  路  3Comments

KseniaBastrakova picture KseniaBastrakova  路  6Comments

ax3l picture ax3l  路  4Comments

ilomi picture ilomi  路  3Comments

ax3l picture ax3l  路  3Comments