HDF5 Connection Type Native vs. IEEE

I'm just picking up HDF5, and I'm a little confused by the difference between creating data for memory and creating data for a file. Who cares?

In this example, creating data of a composite type requires that the data be created in memory and placed in a file:

 /*
 * Create the memory data type. 
 */
s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
H5Tinsert(s1_tid, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT);
H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE);
H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT);

/* 
 * Create the dataset.
 */
dataset = H5Dcreate(file, DATASETNAME, s1_tid, space, H5P_DEFAULT);

/*
 * Wtite data to the dataset; 
 */
status = H5Dwrite(dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1);

However, in another example , the author also creates composite data for a file that indicates a different data type. For example, when you create a data type for the memory type used serial_no H5T_NATIVE_INT , but when you create a data type for a file used serial_no H5T_STD_I64BE . Why is he doing this?

    /*
 * Create the compound datatype for memory.
 */
memtype = H5Tcreate (H5T_COMPOUND, sizeof (sensor_t));
status = H5Tinsert (memtype, "Serial number",
            HOFFSET (sensor_t, serial_no), H5T_NATIVE_INT);
status = H5Tinsert (memtype, "Location", HOFFSET (sensor_t, location),
            strtype);
status = H5Tinsert (memtype, "Temperature (F)",
            HOFFSET (sensor_t, temperature), H5T_NATIVE_DOUBLE);
status = H5Tinsert (memtype, "Pressure (inHg)",
            HOFFSET (sensor_t, pressure), H5T_NATIVE_DOUBLE);

/*
 * Create the compound datatype for the file.  Because the standard
 * types we are using for the file may have different sizes than
 * the corresponding native types, we must manually calculate the
 * offset of each member.
 */
filetype = H5Tcreate (H5T_COMPOUND, 8 + sizeof (hvl_t) + 8 + 8);
status = H5Tinsert (filetype, "Serial number", 0, H5T_STD_I64BE);
status = H5Tinsert (filetype, "Location", 8, strtype);
status = H5Tinsert (filetype, "Temperature (F)", 8 + sizeof (hvl_t),
            H5T_IEEE_F64BE);
status = H5Tinsert (filetype, "Pressure (inHg)", 8 + sizeof (hvl_t) + 8,
            H5T_IEEE_F64BE);

/*
 * Create dataspace.  Setting maximum size to NULL sets the maximum
 * size to be the current size.
 */
space = H5Screate_simple (1, dims, NULL);

/*
 * Create the dataset and write the compound data to it.
 */
dset = H5Dcreate (file, DATASET, filetype, space, H5P_DEFAULT, H5P_DEFAULT,
            H5P_DEFAULT);
status = H5Dwrite (dset, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);

What is the difference between these two methods?

+5
source share
2

http://www.hdfgroup.org/HDF5/doc/UG/UG_frame11Datatypes.html:

H5T_NATIVE_INT C int. Intel , H5T_STD_I32LE, MIPS H5T_STD_I32BE.

, H5T_NATIVE_INT . , , , H5T_NATIVE_INT .

, int, , . H5T_STD_I64BE H5T_STD_I32LE. H5T_NATIVE_INT Intel, H5T_STD_I32LE. MIPS, H5T_STD_I32BE, .

+5

, HDF5 , .

, NATIVE - , C- ( HDF5). , h5dump, NATIVE, (H5T_STD_I32LE -). NATIVE, , , C HDF5 , .

, , , , . H5T_STD_I32BE, - H5T_NATIVE_INT little-endian, HDF5 . .

:

  • H5Dcreate() .
  • / H5Dread() H5Dwrite().

, , /.

, . , , , NATIVE, .

. , BE-writer LE- , . H5T_STD_I32LE, .

: HOFFSET (s, m) . , .

HDF5, 6 : https://support.hdfgroup.org/HDF5/doc/UG/HDF5_Users_Guide-Responsive%20HTML5/index.html

H5T API : https://support.hdfgroup.org/HDF5/doc/RM/RM_H5Front.html

0

All Articles