Skip to content

Commit cbb9de5

Browse files
committed
add OpenPMD.cpp
1 parent f3899ff commit cbb9de5

8 files changed

Lines changed: 73 additions & 16 deletions

File tree

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ add_subdirectory (Expression)
8080
add_subdirectory (Types)
8181
add_subdirectory (Partition)
8282
add_subdirectory (Stream)
83+
add_subdirectory (Stream/HDF5)
84+
add_subdirectory (Stream/Format)
8385
8486
8587
if (ENABLE_SOLVERS)

src/Stream/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ set (_SRCS
55
set (_HDRS
66
BasicStreams.h
77
BasicFileStream.h
8-
StreamFormat.h
9-
OpenPMD.h
108
)
119

1210
include_DIRECTORIES (
@@ -18,6 +16,7 @@ add_ippl_headers (${_HDRS})
1816

1917
install (FILES ${_HDRS} DESTINATION include/Stream)
2018

19+
2120
# vi: set et ts=4 sw=4 sts=4:
2221

2322
# Local Variables:

src/Stream/Format/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set (_SRCS
2+
OpenPMD.cpp
23
)
34

45
set (_HDRS

src/Stream/Format/Format.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef IPPL_IOS_STANDARD_H
2-
#define IPPL_IOS_STANDARD_H
1+
#ifndef IPPL_STREAM_FORMAT_H
2+
#define IPPL_STREAM_FORMAT_H
33

44
#include "Utility/ParameterList.h"
55

src/Stream/Format/OpenPMD.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "Stream/Format/OpenPMD.h"
2+
3+
namespace ippl {
4+
5+
void OpenPMD::header(ParameterList* param) const {
6+
// default parameter list
7+
ParameterList pl;
8+
pl.add<std::string>("version", version);
9+
pl.add<std::string>("author", "none");
10+
pl.add<std::string>("software", "none");
11+
pl.add<std::string>("softwareVersion", "none");
12+
pl.add<std::string>("softwareDependencies", "none");
13+
pl.add<std::string>("date", this->date());
14+
pl.add<std::string>("machine", "none");
15+
pl.add<std::string>("comment", "none");
16+
17+
if (param != nullptr) {
18+
pl.merge(*param);
19+
}
20+
21+
*param = pl;
22+
}
23+
24+
std::string OpenPMD::date() const {
25+
std::time_t time = std::time({});
26+
char timeString[std::size("YYYY-MM-DD HH:mm:ss zzzzz")];
27+
std::strftime(std::data(timeString), std::size(timeString), "%F %T %z",
28+
std::localtime(&time));
29+
return timeString;
30+
}
31+
} // namespace ippl

src/Stream/Format/OpenPMD.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#ifndef IPPL_STREAM_FORMAT_OPEN_PMD_H
77
#define IPPL_STREAM_FORMAT_OPEN_PMD_H
88

9+
#include <ctime>
10+
#include <string>
11+
912
#include "Stream/Format/Format.h"
1013

1114
namespace ippl {
@@ -14,17 +17,12 @@ namespace ippl {
1417
public:
1518
OpenPMD() = default;
1619

17-
void header(ParameterList* param) const override {
18-
std::cout << "This file is written in OpenPMD standard." << std::endl;
19-
20-
param->add<std::string>("version", "1.1.0");
21-
param->add<std::string>("author", "none");
22-
param->add<std::string>("software", "Ippl");
23-
param->add<std::string>("softwareVersion", "2.1.0");
24-
param->add<std::string>("data", "YYYY-MM-DD HH:mm:ss tz");
25-
param->add<std::string>("machine", "machine");
26-
param->add<std::string>("comment", "");
27-
}
20+
void header(ParameterList* param) const override;
21+
22+
private:
23+
const std::string version = "1.1.0";
24+
25+
std::string date() const;
2826
};
2927
} // namespace ippl
3028

src/Stream/HDF5/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
set (_SRCS
2+
)
3+
4+
set (_HDRS
5+
Stream.h
6+
ParticleStream.h
7+
ParticleStream.hpp
8+
)
9+
10+
include_DIRECTORIES (
11+
${CMAKE_CURRENT_SOURCE_DIR}
12+
)
13+
14+
add_ippl_sources (${_SRCS})
15+
add_ippl_headers (${_HDRS})
16+
17+
install (FILES ${_HDRS} DESTINATION include/Stream/HDF5)
18+
19+
# vi: set et ts=4 sw=4 sts=4:
20+
21+
# Local Variables:
22+
# mode: cmake
23+
# cmake-tab-width: 4
24+
# indent-tabs-mode: nil
25+
# require-final-newline: nil
26+
# End:

src/Stream/HDF5/Stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ namespace ippl {
131131
const T& value = pair.second;
132132

133133
H5::DataSpace dspace(H5S_SCALAR); // FIXME We might also write arrays etc.
134-
std::cout << "key " << key << std::endl;
134+
135135
H5::DataType type = core::get_hdf5_type(value);
136136

137137
H5::Attribute attr = this->h5file_m.createAttribute(key, type, dspace);

0 commit comments

Comments
 (0)