Skip to content
Snippets Groups Projects

HDF5 minimal example

Merged Tobias Meisel requested to merge without_odds into main
1 file
+ 9
11
Compare changes
  • Side-by-side
  • Inline
+ 9
11
@@ -29,16 +29,12 @@ int main(int argc, char** argv)
assert(H5Pclose(fapl) >= 0);
// Let's create some sample data!
// Even MPI ranks have (100 + rank) integers worth of data, oddballs don't
// have any data.
std::vector<int> v(100 + comm_rank, comm_rank+10);
// MPI ranks have (100 + rank) integers worth of data
std::vector<int> v(100, comm_rank);
// The extent of the dataspace in the file can be computed accordingly.
hsize_t size = 100 * (comm_size / 2 + comm_size % 2) +
(comm_size - 1) / 2 * ((comm_size - 1) / 2 + 1);
printf("Size %d", size);
size = comm_size * 100 + (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!
@@ -62,14 +58,16 @@ int main(int argc, char** argv)
offset =
comm_rank / 2 * 100 + (comm_rank - 1) / 2 * ((comm_rank - 1) / 2 + 1);
offset = comm_rank*100+(comm_rank)*(comm_rank-1)/2;
offset = comm_rank*100; //+(comm_rank)*(comm_rank-1)/2;
printf("offset %d of rank %d \n", offset, comm_rank);
assert(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, &offset, NULL, &one,
&blk) >= 0);
assert(H5Sselect_none(mspace) >= 0);
assert(H5Sselect_none(fspace) >= 0);
assert(H5Sselect_all(mspace) >= 0);
offset = comm_rank * 100;
assert(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, &offset, NULL, &one,
&blk) >= 0);
assert(H5Dwrite(dset, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT,
v.data()) >= 0);
Loading