mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
Fix hdf5 source_bank struct size. (#3676)
This commit is contained in:
parent
a62e754bbb
commit
5c4121efd2
26 changed files with 25 additions and 18 deletions
|
|
@ -16,8 +16,9 @@
|
|||
namespace openmc {
|
||||
|
||||
template<typename SiteType>
|
||||
void write_bank_dataset(const char* dataset_name, hid_t group_id,
|
||||
span<SiteType> bank, const vector<int64_t>& bank_index, hid_t banktype
|
||||
void write_bank_dataset(
|
||||
const char* dataset_name, hid_t group_id, span<SiteType> bank,
|
||||
const vector<int64_t>& bank_index, hid_t membanktype, hid_t filebanktype
|
||||
#ifdef OPENMC_MPI
|
||||
,
|
||||
MPI_Datatype mpi_dtype
|
||||
|
|
@ -30,8 +31,8 @@ void write_bank_dataset(const char* dataset_name, hid_t group_id,
|
|||
#ifdef PHDF5
|
||||
hsize_t dims[] {static_cast<hsize_t>(dims_size)};
|
||||
hid_t dspace = H5Screate_simple(1, dims, nullptr);
|
||||
hid_t dset = H5Dcreate(group_id, dataset_name, banktype, dspace, H5P_DEFAULT,
|
||||
H5P_DEFAULT, H5P_DEFAULT);
|
||||
hid_t dset = H5Dcreate(group_id, dataset_name, filebanktype, dspace,
|
||||
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
hsize_t count[] {static_cast<hsize_t>(count_size)};
|
||||
hid_t memspace = H5Screate_simple(1, count, nullptr);
|
||||
|
|
@ -42,7 +43,7 @@ void write_bank_dataset(const char* dataset_name, hid_t group_id,
|
|||
hid_t plist = H5Pcreate(H5P_DATASET_XFER);
|
||||
H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE);
|
||||
|
||||
H5Dwrite(dset, banktype, memspace, dspace, plist, bank.data());
|
||||
H5Dwrite(dset, membanktype, memspace, dspace, plist, bank.data());
|
||||
|
||||
H5Sclose(dspace);
|
||||
H5Sclose(memspace);
|
||||
|
|
@ -52,7 +53,7 @@ void write_bank_dataset(const char* dataset_name, hid_t group_id,
|
|||
if (mpi::master) {
|
||||
hsize_t dims[] {static_cast<hsize_t>(dims_size)};
|
||||
hid_t dspace = H5Screate_simple(1, dims, nullptr);
|
||||
hid_t dset = H5Dcreate(group_id, dataset_name, banktype, dspace,
|
||||
hid_t dset = H5Dcreate(group_id, dataset_name, filebanktype, dspace,
|
||||
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
|
|
@ -75,7 +76,8 @@ void write_bank_dataset(const char* dataset_name, hid_t group_id,
|
|||
H5Sselect_hyperslab(
|
||||
dspace_rank, H5S_SELECT_SET, start, nullptr, count, nullptr);
|
||||
|
||||
H5Dwrite(dset, banktype, memspace, dspace_rank, H5P_DEFAULT, bank.data());
|
||||
H5Dwrite(
|
||||
dset, membanktype, memspace, dspace_rank, H5P_DEFAULT, bank.data());
|
||||
|
||||
H5Sclose(memspace);
|
||||
H5Sclose(dspace_rank);
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@ void write_collision_track_bank(hid_t group_id,
|
|||
hid_t banktype = h5_collision_track_banktype();
|
||||
#ifdef OPENMC_MPI
|
||||
write_bank_dataset("collision_track_bank", group_id, collision_track_bank,
|
||||
bank_index, banktype, mpi::collision_track_site);
|
||||
bank_index, banktype, banktype, mpi::collision_track_site);
|
||||
#else
|
||||
write_bank_dataset("collision_track_bank", group_id, collision_track_bank,
|
||||
bank_index, banktype);
|
||||
bank_index, banktype, banktype);
|
||||
#endif
|
||||
|
||||
H5Tclose(banktype);
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ extern "C" int openmc_statepoint_load(const char* filename)
|
|||
return 0;
|
||||
}
|
||||
|
||||
hid_t h5banktype()
|
||||
hid_t h5banktype(bool memory)
|
||||
{
|
||||
// Create compound type for position
|
||||
hid_t postype = H5Tcreate(H5T_COMPOUND, sizeof(struct Position));
|
||||
|
|
@ -569,7 +569,10 @@ hid_t h5banktype()
|
|||
// - openmc/statepoint.py
|
||||
// - docs/source/io_formats/statepoint.rst
|
||||
// - docs/source/io_formats/source.rst
|
||||
hid_t banktype = H5Tcreate(H5T_COMPOUND, sizeof(struct SourceSite));
|
||||
auto n = sizeof(SourceSite);
|
||||
if (!memory)
|
||||
n = 2 * sizeof(struct Position) + 3 * sizeof(double) + 3 * sizeof(int);
|
||||
hid_t banktype = H5Tcreate(H5T_COMPOUND, n);
|
||||
H5Tinsert(banktype, "r", HOFFSET(SourceSite, r), postype);
|
||||
H5Tinsert(banktype, "u", HOFFSET(SourceSite, u), postype);
|
||||
H5Tinsert(banktype, "E", HOFFSET(SourceSite, E), H5T_NATIVE_DOUBLE);
|
||||
|
|
@ -641,17 +644,19 @@ void write_h5_source_point(const char* filename, span<SourceSite> source_bank,
|
|||
void write_source_bank(hid_t group_id, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index)
|
||||
{
|
||||
hid_t banktype = h5banktype();
|
||||
hid_t membanktype = h5banktype(true);
|
||||
hid_t filebanktype = h5banktype(false);
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
write_bank_dataset("source_bank", group_id, source_bank, bank_index, banktype,
|
||||
mpi::source_site);
|
||||
write_bank_dataset("source_bank", group_id, source_bank, bank_index,
|
||||
membanktype, filebanktype, mpi::source_site);
|
||||
#else
|
||||
write_bank_dataset(
|
||||
"source_bank", group_id, source_bank, bank_index, banktype);
|
||||
write_bank_dataset("source_bank", group_id, source_bank, bank_index,
|
||||
membanktype, filebanktype);
|
||||
#endif
|
||||
|
||||
H5Tclose(banktype);
|
||||
H5Tclose(membanktype);
|
||||
H5Tclose(filebanktype);
|
||||
}
|
||||
|
||||
// Determine member names of a compound HDF5 datatype
|
||||
|
|
@ -672,7 +677,7 @@ std::string dtype_member_names(hid_t dtype_id)
|
|||
void read_source_bank(
|
||||
hid_t group_id, vector<SourceSite>& sites, bool distribute)
|
||||
{
|
||||
hid_t banktype = h5banktype();
|
||||
hid_t banktype = h5banktype(true);
|
||||
|
||||
// Open the dataset
|
||||
hid_t dset = H5Dopen(group_id, "source_bank", H5P_DEFAULT);
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue