[dataset in custom data type, Fortran]

Dear all,

I’m trying to create an HDF5 dataset with a custom datatype in Fortran. Please find attached a minimalistic example. The layout of the data is the following: it is a 1D array of “triples”, (x,y,z) coordinates. 1D array is of size 10 and the triple is of size 3. I’m able to write the data into an HDF5 file. However, when I try to check the contents of the newly written file with an “h5dump” utility it shows me different numbers. Am I doing something wrong at the data writing stage or the “h5dump” is just incapable of reading my data in a custom data type? Thank you and have a good day ahead!

h5_datatype.f90 (2.53 KB)

Dear all,

I have figured out the problem. First, I need to use the Native Fortran datatype for real numbers H5T_NATIVE_REAL. Second, the array dimensions of the main data structure beads have to be swapped. Instead of allocate(beads(spaceDims(1),arrTypeDime(1))) I should use allocate(beads(arrTypeDims(1),spaceDims(1))). The relevant lines of the correct code:

allocate(beads(arrTypeDims(1),spaceDims(1)), stat=info)


! Create 1D array datatype
call H5Tarray_create_f(H5T_NATIVE_REAL, arrTypeRank, arrTypeDims, &
                       arrTypeID, info)

Thank you!