Skip to content
Snippets Groups Projects

HDF5 minimal example

Merged Tobias Meisel requested to merge without_odds into main
1 file
+ 4
4
Compare changes
  • Side-by-side
  • Inline
+ 4
4
@@ -30,21 +30,21 @@ int main(int argc, char** argv)
// Let's create some sample data!
// MPI ranks have (100 + rank) integers worth of data
std::vector<int> v(100, comm_rank);
std::vector<int> v(100 + comm_rank, comm_rank);
// The extent of the dataspace in the file can be computed accordingly.
hsize_t size = 100*comm_size; //+ comm_size*(comm_size-1)/2 ;
hsize_t size = 100*comm_size+ comm_size*(comm_size-1)/2 ;
printf("Size %d", size);
// Make a dataset!
// I can't believe that takes 10 lines of code :-(
hsize_t infty = H5S_UNLIMITED;
hsize_t infty = 406;
hid_t fspace = H5Screate_simple(1, &size, &infty);
assert(fspace >= 0);
hid_t dcpl = H5Pcreate(H5P_DATASET_CREATE);
assert(dcpl >= 0);
assert(H5Pset_chunk(dcpl, 1, &CHUNK_SIZE) >= 0);
//assert(H5Pset_chunk(dcpl, 1, &CHUNK_SIZE) >= 0);
hid_t dset = H5Dcreate(file, "1D", H5T_STD_I32LE, fspace, H5P_DEFAULT, dcpl,
H5P_DEFAULT);
assert(dset >= 0);
Loading