Skip to content

Commit

Permalink
fix build errors with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
pnorbert committed Sep 11, 2023
1 parent 704bfa3 commit 04623d4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 27 deletions.
12 changes: 9 additions & 3 deletions include/bout/options_adios.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace bout {

class OptionsADIOS : public OptionsIO {
public:
OptionsADIOS(const std::string& filename, bout::OptionsIO::FileMode mode = bout::OptionsIO::FileMode::replace) {}
explicit OptionsADIOS(const std::string& filename, bout::OptionsIO::FileMode mode = bout::OptionsIO::FileMode::replace) {}
OptionsADIOS(const OptionsADIOS&) = default;
OptionsADIOS(OptionsADIOS&&) = default;
OptionsADIOS& operator=(const OptionsADIOS&) = default;
Expand All @@ -28,9 +28,15 @@ public:
Options read() { throw BoutException("OptionsADIOS not available\n"); }

/// Write options to file
void write(const Options& options) {
void write(const Options& options, const std::string& time_dim) {
throw BoutException("OptionsADIOS not available\n");
}

void verifyTimesteps() const{
throw BoutException("OptionsADIOS not available\n");
}


};

} // namespace bout
Expand All @@ -51,7 +57,7 @@ public:
// Constructors need to be defined in implementation due to forward
// declaration of ADIOSStream
OptionsADIOS();
explicit OptionsADIOS(std::string filename, bout::OptionsIO::FileMode mode =
OptionsADIOS(std::string filename, bout::OptionsIO::FileMode mode =
bout::OptionsIO::FileMode::replace);
~OptionsADIOS();
OptionsADIOS(const OptionsADIOS&) = delete;
Expand Down
6 changes: 1 addition & 5 deletions include/bout/options_io.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@ public:
};

enum class Library {
#if BOUT_HAS_ADIOS
ADIOS,
#endif
#if BOUT_HAS_NETCDF
NetCDF,
#endif
Invalid
};

Expand All @@ -41,7 +37,7 @@ public:
#endif

OptionsIO();
explicit OptionsIO(std::string filename, FileMode mode = FileMode::replace);
OptionsIO(std::string filename, FileMode mode = FileMode::replace);
~OptionsIO();
OptionsIO(const OptionsIO&) = delete;
OptionsIO(OptionsIO&&) noexcept;
Expand Down
8 changes: 6 additions & 2 deletions include/bout/options_netcdf.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ public:
Options read() { throw BoutException("OptionsNetCDF not available\n"); }

/// Write options to file
void write(const Options& options) {
void write(const Options& options, const std::string& time_dim) {
throw BoutException("OptionsNetCDF not available\n");
}

void verifyTimesteps() const{
throw BoutException("OptionsADIOS not available\n");
}
};

} // namespace bout
Expand All @@ -55,7 +59,7 @@ public:
// Constructors need to be defined in implementation due to forward
// declaration of NcFile
OptionsNetCDF();
explicit OptionsNetCDF(std::string filename, FileMode mode = FileMode::replace);
OptionsNetCDF(std::string filename, FileMode mode = FileMode::replace);
~OptionsNetCDF();
OptionsNetCDF(const OptionsNetCDF&) = delete;
OptionsNetCDF(OptionsNetCDF&&) noexcept;
Expand Down
37 changes: 25 additions & 12 deletions src/sys/options/options_adios.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -237,51 +237,64 @@ void ADIOSPutVarVisitor::operator()<std::string>(const std::string& value) {
template <>
void ADIOSPutVarVisitor::operator()<Field2D>(const Field2D& value) {
// Pointer to data. Assumed to be contiguous array
adios2::Dims shape = {(size_t)value.getNx(), (size_t)value.getNy()};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape);
auto mesh = value.getMesh();
adios2::Dims shape = {(size_t)BoutComm::size(), (size_t)value.getNx(), (size_t)value.getNy()};
adios2::Dims start = {(size_t)BoutComm::rank(), 0, 0};
adios2::Dims count = {1, shape[1], shape[2]};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape, start, count);
stream.engine.Put<BoutReal>(var, &value(0, 0));
}

template <>
void ADIOSPutVarVisitor::operator()<Field3D>(const Field3D& value) {
// Pointer to data. Assumed to be contiguous array
adios2::Dims shape = {(size_t)value.getNx(), (size_t)value.getNz()};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape);
adios2::Dims shape = {(size_t)BoutComm::size(), (size_t)value.getNx(), (size_t)value.getNy(), (size_t)value.getNz()};
adios2::Dims start = {(size_t)BoutComm::rank(), 0, 0, 0};
adios2::Dims count = {1, shape[1], shape[2], shape[3]};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape, start, count);
stream.engine.Put<BoutReal>(var, &value(0, 0, 0));
}

template <>
void ADIOSPutVarVisitor::operator()<FieldPerp>(const FieldPerp& value) {
// Pointer to data. Assumed to be contiguous array
adios2::Dims shape = {(size_t)value.getNx(), (size_t)value.getNz()};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape);
adios2::Dims shape = {(size_t)BoutComm::size(), (size_t)value.getNx(), (size_t)value.getNz()};
adios2::Dims start = {(size_t)BoutComm::rank(), 0, 0};
adios2::Dims count = {1, shape[1], shape[2]};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape, start, count);
stream.engine.Put<BoutReal>(var, &value(0, 0));
}

template <>
void ADIOSPutVarVisitor::operator()<Array<BoutReal>>(const Array<BoutReal>& value) {
// Pointer to data. Assumed to be contiguous array
adios2::Dims shape = {(size_t)value.size()};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape);
adios2::Dims shape = {(size_t)BoutComm::size(), (size_t)value.size()};
adios2::Dims start = {(size_t)BoutComm::rank(), 0};
adios2::Dims count = {1, shape[1]};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape, start, count);
stream.engine.Put<BoutReal>(var, value.begin());
}

template <>
void ADIOSPutVarVisitor::operator()<Matrix<BoutReal>>(const Matrix<BoutReal>& value) {
// Pointer to data. Assumed to be contiguous array
auto s = value.shape();
adios2::Dims shape = {(size_t)std::get<0>(s), (size_t)std::get<1>(s)};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape);
adios2::Dims shape = {(size_t)BoutComm::size(), (size_t)std::get<0>(s), (size_t)std::get<1>(s)};
adios2::Dims start = {(size_t)BoutComm::rank(), 0, 0};
adios2::Dims count = {1, shape[1], shape[2]};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape, start, count);
stream.engine.Put<BoutReal>(var, value.begin());
}

template <>
void ADIOSPutVarVisitor::operator()<Tensor<BoutReal>>(const Tensor<BoutReal>& value) {
// Pointer to data. Assumed to be contiguous array
auto s = value.shape();
adios2::Dims shape = {(size_t)std::get<0>(s), (size_t)std::get<1>(s),
adios2::Dims shape = {(size_t)BoutComm::size(), (size_t)std::get<0>(s), (size_t)std::get<1>(s),
(size_t)std::get<2>(s)};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape);
adios2::Dims start = {(size_t)BoutComm::rank(), 0, 0, 0};
adios2::Dims count = {1, shape[1], shape[2], shape[3]};
adios2::Variable<BoutReal> var = stream.io.DefineVariable<BoutReal>(varname, shape, start, count);
stream.engine.Put<BoutReal>(var, value.begin());
}

Expand Down
4 changes: 0 additions & 4 deletions src/sys/options/options_io.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
#include <iostream>
#include <vector>

#if BOUT_HAS_ADIOS
#include "bout/options_adios.hxx"
#endif
#if BOUT_HAS_NETCDF
#include "bout/options_netcdf.hxx"
#endif

namespace bout {

Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test-options-adios/test-options-adios.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main(int argc, char** argv) {
data["field"] = Field3D(3.0);

// Append data to file
OptionsADIOS("time.nc", bout::OptionsIO::FileMode::append).write(data);
OptionsADIOS("time.bp", bout::OptionsIO::FileMode::append).write(data);

BoutFinalise();
};

0 comments on commit 04623d4

Please sign in to comment.