diff --git a/bindings/CXX11/cxx11/ADIOS.cpp b/bindings/CXX11/cxx11/ADIOS.cpp index 1d76144024..31a2b30c71 100644 --- a/bindings/CXX11/cxx11/ADIOS.cpp +++ b/bindings/CXX11/cxx11/ADIOS.cpp @@ -25,14 +25,13 @@ ADIOS::ADIOS(MPI_Comm comm, const bool debugMode) : ADIOS("", comm, debugMode) { } -#else +#endif ADIOS::ADIOS(const std::string &configFile, const bool debugMode) : m_ADIOS(std::make_shared(configFile, debugMode, "C++")) { } ADIOS::ADIOS(const bool debugMode) : ADIOS("", debugMode) {} -#endif ADIOS::operator bool() const noexcept { return m_ADIOS ? true : false; } diff --git a/bindings/CXX11/cxx11/ADIOS.h b/bindings/CXX11/cxx11/ADIOS.h index dff4a59937..f11328b741 100644 --- a/bindings/CXX11/cxx11/ADIOS.h +++ b/bindings/CXX11/cxx11/ADIOS.h @@ -64,9 +64,9 @@ class ADIOS * @exception std::invalid_argument in debugMode = true if user input is * incorrect */ - ADIOS(const std::string &configFile = "", MPI_Comm comm = MPI_COMM_SELF, + ADIOS(const std::string &configFile, MPI_Comm comm, const bool debugMode = true); -#else +#endif /** * Starting point for non-MPI serial apps. Creates an ADIOS object allowing @@ -87,7 +87,6 @@ class ADIOS * incorrect */ ADIOS(const bool debugMode = true); -#endif /** object inspection true: valid object, false: invalid object */ explicit operator bool() const noexcept; diff --git a/testing/adios2/interface/CMakeLists.txt b/testing/adios2/interface/CMakeLists.txt index b036eee798..0e1214de8d 100644 --- a/testing/adios2/interface/CMakeLists.txt +++ b/testing/adios2/interface/CMakeLists.txt @@ -15,6 +15,9 @@ target_link_libraries(TestADIOSDefineVariable adios2 gtest) add_executable(TestADIOSDefineAttribute TestADIOSDefineAttribute.cpp) target_link_libraries(TestADIOSDefineAttribute adios2 gtest) +add_executable(TestADIOSNoMpi TestADIOSNoMpi.cpp) +target_link_libraries(TestADIOSNoMpi adios2 gtest) + if(ADIOS2_HAVE_MPI) target_link_libraries(TestADIOSInterface MPI::MPI_C) target_link_libraries(TestADIOSInterfaceWrite MPI::MPI_C) @@ -28,3 +31,4 @@ gtest_add_tests(TARGET TestADIOSInterface ${extra_test_args}) gtest_add_tests(TARGET TestADIOSInterfaceWrite ${extra_test_args}) gtest_add_tests(TARGET TestADIOSDefineVariable ${extra_test_args}) gtest_add_tests(TARGET TestADIOSDefineAttribute ${extra_test_args}) +gtest_add_tests(TARGET TestADIOSNoMpi ${extra_test_args}) diff --git a/testing/adios2/interface/TestADIOSNoMpi.cpp b/testing/adios2/interface/TestADIOSNoMpi.cpp new file mode 100644 index 0000000000..8a05ec9c09 --- /dev/null +++ b/testing/adios2/interface/TestADIOSNoMpi.cpp @@ -0,0 +1,29 @@ + +#include + +#include + +/** + * Basic test to see that writing and reading a simple BP3 file works without + * initializing MPI + */ +TEST(ADIOSInterface, ADIOSNoMpi) +{ + adios2::ADIOS adios(adios2::DebugON); + { + adios2::IO io = adios.DeclareIO("TestIOWrite"); + adios2::Engine engine = io.Open("test.bp", adios2::Mode::Write); + engine.Close(); + } + { + adios2::IO io = adios.DeclareIO("TestIORead"); + adios2::Engine engine = io.Open("test.bp", adios2::Mode::Read); + engine.Close(); + } +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}