Skip to content

Commit

Permalink
error check HDF5 file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jlippuner committed May 10, 2021
1 parent 86e6a68 commit 079b47c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/outputs/parthenon_hdf5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ struct VarInfo {
const bool is_sparse = (info_code & sparse_flag) > 0;
const bool is_vector = (info_code & vector_flag) > 0;

// first label in compact labe is the variable label, the rest are the component
// first label in compact label is the variable label, the rest are the component
// labels
return VarInfo(labels[0], std::vector<std::string>(labels.begin() + 1, labels.end()),
vlen, is_sparse, is_vector);
Expand Down Expand Up @@ -420,9 +420,17 @@ void PHDF5Output::WriteOutputFileImpl(Mesh *pm, ParameterInput *pin, SimTime *tm
hid_t const acc_file = H5P_DEFAULT;
#endif // ifdef MPI_PARALLEL

// now open the file
H5F const file = H5F::FromHIDCheck(
H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, acc_file));
// now create the file
H5F file;
try {
file = H5F::FromHIDCheck(
H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, acc_file));
} catch (std::exception &ex) {
std::stringstream err;
err << "### ERROR: Failed to create HDF5 output file '" << filename
<< "' with the following error:" << std::endl << ex.what() << std::endl;
PARTHENON_THROW(err)
}

// -------------------------------------------------------------------------------- //
// WRITING ATTRIBUTES //
Expand Down

0 comments on commit 079b47c

Please sign in to comment.