kharm/hdf5_utils.hpp
// Write a single value of hdf5_type to a file
Write a single value of hdf5_type to a file
Write a single value of hdf5_type to a file
int H5F::write_single_val(const void *val, const char *name, hsize_t hdf5_type)
{
    char path[STRLEN];
    strncpy(path, cur_dir, STRLEN);
    strncat(path, name, STRLEN - strlen(path));
    if (DEBUG)
        fprintf(stderr, "Adding val %s\n", path);
    hid_t scalarspace = H5Screate(H5S_SCALAR);
    hid_t plist_id = H5Pcreate(H5P_DATASET_CREATE);
    hid_t dset_id = H5Dcreate(file_id, path, hdf5_type, scalarspace, H5P_DEFAULT,
                              plist_id, H5P_DEFAULT);
    H5Pclose(plist_id);
    plist_id = H5Pcreate(H5P_DATASET_XFER);
#if USE_MPI
    H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
#endif
    herr_t err = H5Dwrite(dset_id, hdf5_type, scalarspace, scalarspace, plist_id, val);
    if (err < 0)
        FAIL(err, "hdf5_write_single_val", path);
    H5Dclose(dset_id);
    H5Pclose(plist_id);
    H5Sclose(scalarspace);
    return 0;
}
int H5F :: write_single_val ( const void * val , const char * name , hsize_t hdf5_type ) { char path [ STRLEN ] ; strncpy ( path , cur_dir , STRLEN ) ; strncat ( path , name , STRLEN - strlen ( path ) ) ; if ( DEBUG ) fprintf ( stderr , " \n " , path ) ; hid_t scalarspace = H5Screate ( H5S_SCALAR ) ; hid_t plist_id = H5Pcreate ( H5P_DATASET_CREATE ) ; hid_t dset_id = H5Dcreate ( file_id , path , hdf5_type , scalarspace , H5P_DEFAULT , plist_id , H5P_DEFAULT ) ; H5Pclose ( plist_id ) ; plist_id = H5Pcreate ( H5P_DATASET_XFER ) ; #if USE_MPI H5Pset_dxpl_mpio ( plist_id , H5FD_MPIO_COLLECTIVE ) ; #endif herr_t err = H5Dwrite ( dset_id , hdf5_type , scalarspace , scalarspace , plist_id , val ) ; if ( err < 0 ) FAIL ( err , " " , path ) ; H5Dclose ( dset_id ) ; H5Pclose ( plist_id ) ; H5Sclose ( scalarspace ) ; return 0 ; }
Write a single value of hdf5_type to a file
Write a single value of hdf5_type to a file
// Add current path to the dataset name // Declare scalar spaces // Conduct transfer // Close spaces (TODO could definitely keep these open instead of re-declaring)