Skip to content

Commit 6fb6a68

Browse files
committed
highfive sync
1 parent 5933e40 commit 6fb6a68

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

src/diagnostic/detail/h5writer.hpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,13 @@ class H5Writer
5050

5151
static constexpr auto dimension = GridLayout::dimension;
5252
static constexpr auto interpOrder = GridLayout::interp_order;
53-
static constexpr auto READ_WRITE = HiFile::ReadWrite | HiFile::Create;
53+
static constexpr auto READ_WRITE = HiFile::AccessMode::OpenOrCreate;
5454

5555
// flush_never: disables manual file closing, but still occurrs via RAII
5656
static constexpr std::size_t flush_never = 0;
5757

5858
template<typename Hierarchy, typename Model>
59-
H5Writer(Hierarchy& hier, Model& model, std::string const hifivePath,
60-
unsigned _flags /* = HiFile::ReadWrite | HiFile::Create | HiFile::Truncate */)
59+
H5Writer(Hierarchy& hier, Model& model, std::string const hifivePath, HiFile::AccessMode _flags)
6160
: flags{_flags}
6261
, filePath_{hifivePath}
6362
, modelView_{hier, model}
@@ -69,8 +68,8 @@ class H5Writer
6968
template<typename Hierarchy, typename Model>
7069
static auto make_unique(Hierarchy& hier, Model& model, initializer::PHAREDict const& dict)
7170
{
72-
std::string filePath = dict["filePath"].template to<std::string>();
73-
unsigned flags = READ_WRITE;
71+
std::string filePath = dict["filePath"].template to<std::string>();
72+
HiFile::AccessMode flags = READ_WRITE;
7473
if (dict.contains("mode") and dict["mode"].template to<std::string>() == "overwrite")
7574
flags |= HiFile::Truncate;
7675
return std::make_unique<This>(hier, model, filePath, flags);
@@ -95,7 +94,7 @@ class H5Writer
9594
return fileStr + ".h5";
9695
}
9796

98-
auto makeFile(std::string const filename, unsigned file_flag)
97+
auto makeFile(std::string const filename, HiFile::AccessMode const file_flag)
9998
{
10099
return std::make_unique<HighFiveFile>(filePath_ + "/" + filename, file_flag);
101100
}
@@ -169,7 +168,7 @@ class H5Writer
169168
auto& modelView() { return modelView_; }
170169

171170
std::size_t minLevel = 0, maxLevel = 10; // TODO hard-coded to be parametrized somehow
172-
unsigned flags;
171+
HiFile::AccessMode flags;
173172

174173

175174
private:
@@ -179,7 +178,7 @@ class H5Writer
179178
ModelView modelView_;
180179
Attributes fileAttributes_;
181180

182-
std::unordered_map<std::string, unsigned> file_flags;
181+
std::unordered_map<std::string, HiFile::AccessMode> file_flags;
183182

184183
std::unordered_map<std::string, std::shared_ptr<H5TypeWriter<This>>> typeWriters_{
185184
{"info", make_writer<InfoDiagnosticWriter<This>>()},

src/hdf5/detail/h5/h5_file.hpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace PHARE::hdf5::h5
1414
{
1515
using HiFile = HighFive::File;
16-
16+
using FileOp = HighFive::File::AccessMode;
1717

1818

1919

@@ -43,7 +43,7 @@ class HighFiveFile
4343
{
4444
public:
4545
template<typename FileAccessProps>
46-
static auto createHighFiveFile(std::string const path, unsigned flags, bool para,
46+
static auto createHighFiveFile(std::string const path, FileOp flags, bool para,
4747
FileAccessProps& fapl)
4848
{
4949
if (para)
@@ -61,18 +61,15 @@ class HighFiveFile
6161
return HiFile{path, flags, fapl};
6262
}
6363

64-
HighFiveFile(std::string const path, unsigned flags = HiFile::ReadWrite, bool para = true)
64+
HighFiveFile(std::string const path, FileOp flags = HiFile::ReadWrite, bool para = true)
6565
: fapl_{}
6666
, h5file_{createHighFiveFile(path, flags, para, fapl_)}
6767
{
6868
}
6969

7070
~HighFiveFile() {}
7171

72-
NO_DISCARD HiFile& file()
73-
{
74-
return h5file_;
75-
}
72+
NO_DISCARD HiFile& file() { return h5file_; }
7673

7774

7875
template<typename T, std::size_t dim = 1>

tests/diagnostic/test_diagnostics.hpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ using namespace PHARE;
1616
using namespace PHARE::diagnostic;
1717
using namespace PHARE::diagnostic::h5;
1818

19-
constexpr unsigned NEW_HI5_FILE
20-
= HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Truncate;
19+
constexpr auto NEW_HI5_FILE = HighFive::File::AccessMode::Overwrite;
2120

2221

2322
template<typename GridLayout, typename Field, typename FieldFilter = PHARE::FieldNullFilter>
@@ -48,7 +47,7 @@ struct Hi5Diagnostic
4847
using Writer_t = H5Writer<ModelView_t>;
4948

5049
Hi5Diagnostic(Hierarchy& hierarchy, HybridModel& hybridModel, std::string out,
51-
unsigned flags = NEW_HI5_FILE)
50+
auto const flags = NEW_HI5_FILE)
5251
: hierarchy_{hierarchy}
5352
, model_{hybridModel}
5453
, out_{out}
@@ -92,8 +91,8 @@ struct Hi5Diagnostic
9291

9392
Hierarchy& hierarchy_;
9493
HybridModel& model_;
95-
std::string out_;
96-
unsigned flags_;
94+
std::string const out_;
95+
HiFile::AccessMode const flags_;
9796

9897
DiagnosticsManager<Writer_t> dMan;
9998
Writer_t& writer;

tests/simulator/test_diagnostics.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ def _test_dump_diags(self, dim, **simInput):
206206

207207
h5_version = h5_file["py_attrs"].attrs["highfive_version"].split(".")
208208
self.assertTrue(len(h5_version) == 3)
209-
self.assertTrue(all(i.isdigit() for i in h5_version))
209+
# semver patch version may contain "-beta" so ignore
210+
self.assertTrue(all(i.isdigit() for i in h5_version[:2]))
210211

211212
self.assertTrue(
212213
ph.simulation.deserialize(

0 commit comments

Comments
 (0)