diff --git a/source/adios2/CMakeLists.txt b/source/adios2/CMakeLists.txt index 3bd8861811fcdb0cf4812ccd591e53c957331c4e..de3e5c2b4087496ae1696eba0eec46121e095a22 100644 --- a/source/adios2/CMakeLists.txt +++ b/source/adios2/CMakeLists.txt @@ -4,6 +4,8 @@ #------------------------------------------------------------------------------# add_library(adios2 + core/Attribute.cpp core/Attribute.tcc + core/AttributeBase.cpp core/ADIOS.cpp core/Engine.cpp core/IO.cpp core/IO.tcc diff --git a/source/adios2/core/Attribute.cpp b/source/adios2/core/Attribute.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e473101dcaec65e405c397f8e6122526d19a8f3 --- /dev/null +++ b/source/adios2/core/Attribute.cpp @@ -0,0 +1,17 @@ +/* + * Distributed under the OSI-approved Apache License, Version 2.0. See + * accompanying file Copyright.txt for details. + * + * Attribute.cpp : needed for template separation using Attribute.tcc + * + * Created on: Aug 3, 2017 + * Author: William F Godoy godoywf@ornl.gov + */ + +#include "Attribute.h" +#include "Attribute.tcc" + +namespace adios2 +{ + +} // end namespace adios2 diff --git a/source/adios2/core/Attribute.h b/source/adios2/core/Attribute.h index 7ed3cc7799ccd394014dc82e3aa84129f4384f86..bddd3c8087a9a22fc86b6a283215c9e8cb4eea9e 100644 --- a/source/adios2/core/Attribute.h +++ b/source/adios2/core/Attribute.h @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * Attribute.h : template class + * Attribute.h : template class that defines typed attributes * * Created on: Aug 1, 2017 * Author: William F Godoy godoywf@ornl.gov @@ -45,4 +45,4 @@ public: } // end namespace adios2 -#endif /* SOURCE_ADIOS2_CORE_ATTRIBUTE_H_ */ +#endif /* ADIOS2_CORE_ATTRIBUTE_H_ */ diff --git a/source/adios2/core/Attribute.tcc b/source/adios2/core/Attribute.tcc index 47343256f652ee08587822e8858ebcb5ba3d331f..6e771fc15591229787d44f7256aa9cef42419266 100644 --- a/source/adios2/core/Attribute.tcc +++ b/source/adios2/core/Attribute.tcc @@ -31,7 +31,7 @@ namespace adios2 \ template <> \ Attribute<T>::Attribute(const std::string &name, const T &value) \ - : AttributeBase(name, GetType<T>(), 1), m_DataValue() \ + : AttributeBase(name, GetType<T>(), 1), m_DataValue(value) \ { \ } @@ -39,3 +39,5 @@ ADIOS2_FOREACH_ATTRIBUTE_TYPE_1ARG(declare_type) #undef declare_type } // end namespace adios2 + +#endif /* ADIOS2_CORE_ATTRIBUTE_TCC_ */ diff --git a/source/adios2/core/AttributeBase.h b/source/adios2/core/AttributeBase.h index cf09b54f3b58767e7a6b9b695cd74c72d7b17daf..a1a6b7c5ad7e8ca1ccef596154e2c4af8c0a5030 100644 --- a/source/adios2/core/AttributeBase.h +++ b/source/adios2/core/AttributeBase.h @@ -11,6 +11,13 @@ #ifndef ADIOS2_CORE_ATTRIBUTEBASE_H_ #define ADIOS2_CORE_ATTRIBUTEBASE_H_ +/// \cond EXCLUDE_FROM_DOXYGEN +#include <string> +/// \endcond + +#include "adios2/ADIOSConfig.h" +#include "adios2/ADIOSTypes.h" + namespace adios2 { diff --git a/source/adios2/core/IO.cpp b/source/adios2/core/IO.cpp index 4fd7b69fca46345f860c3976d3552bf0a12333f0..260c6e77a27e6c87ab24aace8776a7fe4723f979 100644 --- a/source/adios2/core/IO.cpp +++ b/source/adios2/core/IO.cpp @@ -287,11 +287,22 @@ void IO::CheckTransportType(const std::string type) const // Explicitly instantiate the necessary public template implementations #define define_template_instantiation(T) \ - template Variable<T> &IO::DefineVariable<T>( \ - const std::string &, const Dims, const Dims, const Dims, const bool); \ + template Variable<T> &IO::DefineVariable<T>(const std::string &, \ + const Dims &, const Dims &, \ + const Dims &, const bool); \ template Variable<T> &IO::GetVariable<T>(const std::string &); ADIOS2_FOREACH_TYPE_1ARG(define_template_instantiation) #undef define_template_instatiation +#define declare_template_instantiation(T) \ + template Attribute<T> &IO::DefineAttribute<T>(const std::string &, \ + const T *, const size_t); \ + template Attribute<T> &IO::DefineAttribute<T>(const std::string &, \ + const T &); \ + template Attribute<T> &IO::GetAttribute(const std::string &); + +ADIOS2_FOREACH_ATTRIBUTE_TYPE_1ARG(declare_template_instantiation) +#undef declare_template_instantiation + } // end namespace adios diff --git a/source/adios2/core/IO.h b/source/adios2/core/IO.h index a738fd7bc71f1e7deba72b2717a41c39e1624bc6..3e501c3cad198f0a84dd8cf4d4cfbb9d2c7020a1 100644 --- a/source/adios2/core/IO.h +++ b/source/adios2/core/IO.h @@ -118,8 +118,8 @@ public: * @return reference to Variable object */ template <class T> - Variable<T> &DefineVariable(const std::string &name, const Dims shape = {}, - const Dims start = {}, const Dims count = {}, + Variable<T> &DefineVariable(const std::string &name, const Dims &shape = {}, + const Dims &start = {}, const Dims &count = {}, const bool constantShape = false); /** @@ -136,13 +136,14 @@ public: */ template <class T> - VariableCompound & - DefineVariableCompound(const std::string &name, const Dims shape = Dims{}, - const Dims start = Dims{}, const Dims count = Dims{}, - const bool constantShape = false); + VariableCompound &DefineVariableCompound(const std::string &name, + const Dims &shape = Dims{}, + const Dims &start = Dims{}, + const Dims &count = Dims{}, + const bool constantShape = false); /** - * Define attribute from contiguous data array + * Define attribute from contiguous data array owned by an application * @param name must be unique for the IO object * @param array pointer to user data * @param elements number of data elements @@ -153,7 +154,7 @@ public: const size_t elements); /** - * Define attribute from a single variable + * Define attribute from a single variable making a copy * @param name must be unique for the IO object * @param value single data value * @return reference to internal Attribute @@ -340,8 +341,8 @@ private: // Explicit declaration of the public template methods #define declare_template_instantiation(T) \ extern template Variable<T> &IO::DefineVariable<T>( \ - const std::string &name, const Dims, const Dims, const Dims, \ - const bool constantShape); \ + const std::string &, const Dims &, const Dims &, const Dims &, \ + const bool); \ extern template Variable<T> &IO::GetVariable<T>(const std::string &name); ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation) @@ -349,14 +350,15 @@ ADIOS2_FOREACH_TYPE_1ARG(declare_template_instantiation) #define declare_template_instantiation(T) \ extern template Attribute<T> &IO::DefineAttribute<T>( \ - const std::string &name, const T *array, const size_t elements); \ - extern template Attribute<T> &IO::DefineAttribute<T>( \ - const std::string &name, const T &value); + const std::string &, const T *, const size_t); \ + extern template Attribute<T> &IO::DefineAttribute<T>(const std::string &, \ + const T &); \ + extern template Attribute<T> &IO::GetAttribute(const std::string &); ADIOS2_FOREACH_ATTRIBUTE_TYPE_1ARG(declare_template_instantiation) #undef declare_template_instantiation -} // end namespace adios +} // end namespace adios2 #include "adios2/core/IO.inl" diff --git a/source/adios2/core/IO.inl b/source/adios2/core/IO.inl index 9dd0f53f29f414aaa8dd0b4503c19ad1ac5e5eff..075fc19cff4094069a522056c2547009a040b7cd 100644 --- a/source/adios2/core/IO.inl +++ b/source/adios2/core/IO.inl @@ -21,10 +21,10 @@ namespace adios2 { template <class T> -VariableCompound &IO::DefineVariableCompound(const std::string &name, - const Dims shape, const Dims start, - const Dims count, - const bool constantShape) +VariableCompound & +IO::DefineVariableCompound(const std::string &name, const Dims &shape, + const Dims &start, const Dims &count, + const bool constantShape) { if (m_DebugMode) { diff --git a/source/adios2/core/IO.tcc b/source/adios2/core/IO.tcc index 572fa53bfba548a8729851796f42e844e474818c..1589afa04492fcd6dcba33eb367f6202cac7a585 100644 --- a/source/adios2/core/IO.tcc +++ b/source/adios2/core/IO.tcc @@ -26,8 +26,8 @@ namespace adios2 { template <class T> -Variable<T> &IO::DefineVariable(const std::string &name, const Dims shape, - const Dims start, const Dims count, +Variable<T> &IO::DefineVariable(const std::string &name, const Dims &shape, + const Dims &start, const Dims &count, const bool constantShape) { if (m_DebugMode) diff --git a/source/adios2/core/Variable.cpp b/source/adios2/core/Variable.cpp index 55777209f8e5382653e6d185106d1eff596c8d94..86b5e3d165d79ef6da78cd90db00ca49e64ea6fd 100644 --- a/source/adios2/core/Variable.cpp +++ b/source/adios2/core/Variable.cpp @@ -2,7 +2,7 @@ * Distributed under the OSI-approved Apache License, Version 2.0. See * accompanying file Copyright.txt for details. * - * Variable.cpp needed for template separation using Variable.tcc + * Variable.cpp : needed for template separation using Variable.tcc * * Created on: Jun 8, 2017 * Author: William F Godoy godoywf@ornl.gov @@ -14,4 +14,4 @@ namespace adios2 { -} // end namespace adios +} // end namespace adios2 diff --git a/source/adios2/core/Variable.h b/source/adios2/core/Variable.h index 8f5482857bffc4f94d4b49d626b831a266fd480c..fa040c8aa59f548fd04f77fe175c87a46294b326 100644 --- a/source/adios2/core/Variable.h +++ b/source/adios2/core/Variable.h @@ -18,8 +18,6 @@ #include <vector> /// \endcond -#include "adios2/ADIOSMacros.h" -#include "adios2/core/Transform.h" #include "adios2/core/VariableBase.h" namespace adios2 @@ -50,8 +48,8 @@ public: * @param constantShape * @param debugMode */ - Variable<T>(const std::string &name, const Dims shape, const Dims start, - const Dims count, const bool constantShape, + Variable<T>(const std::string &name, const Dims &shape, const Dims &start, + const Dims &count, const bool constantShape, const bool debugMode); ~Variable<T>() = default; diff --git a/source/adios2/core/Variable.tcc b/source/adios2/core/Variable.tcc index 603b9300dd31114ddfdc47c6b49e2c2e4be69e0d..51d919849b424c30b0589fcb35d16c8dd8919ca3 100644 --- a/source/adios2/core/Variable.tcc +++ b/source/adios2/core/Variable.tcc @@ -22,8 +22,8 @@ namespace adios2 #define declare_type(T) \ \ template <> \ - Variable<T>::Variable(const std::string &name, const Dims shape, \ - const Dims start, const Dims count, \ + Variable<T>::Variable(const std::string &name, const Dims &shape, \ + const Dims &start, const Dims &count, \ const bool constantShape, const bool debugMode) \ : VariableBase(name, GetType<T>(), sizeof(T), shape, start, count, \ constantShape, debugMode) \ diff --git a/source/adios2/core/VariableBase.cpp b/source/adios2/core/VariableBase.cpp index d98f572d15db6b399d008e6d5c4364cbbd29f91c..775944e0a775fb2f0ff635c36b50ec790cdf54f0 100644 --- a/source/adios2/core/VariableBase.cpp +++ b/source/adios2/core/VariableBase.cpp @@ -21,8 +21,8 @@ namespace adios2 { VariableBase::VariableBase(const std::string &name, const std::string type, - const size_t elementSize, const Dims shape, - const Dims start, const Dims count, + const size_t elementSize, const Dims &shape, + const Dims &start, const Dims &count, const bool constantDims, const bool debugMode) : m_Name(name), m_Type(type), m_ElementSize(elementSize), m_Shape(shape), m_Start(start), m_Count(count), m_ConstantDims(constantDims), @@ -41,7 +41,7 @@ size_t VariableBase::TotalSize() const noexcept return GetTotalSize(m_Count); } -void VariableBase::SetSelection(const Dims start, const Dims count) +void VariableBase::SetSelection(const Dims &start, const Dims &count) { if (m_DebugMode) { diff --git a/source/adios2/core/VariableBase.h b/source/adios2/core/VariableBase.h index 61fc093dfd72f5860565edc4eb5da69d5ec72611..f169a3299d8251eda7f6d599e6ec2b042673c15d 100644 --- a/source/adios2/core/VariableBase.h +++ b/source/adios2/core/VariableBase.h @@ -63,8 +63,8 @@ public: unsigned int m_AvailableSteps = 1; VariableBase(const std::string &name, const std::string type, - const size_t elementSize, const Dims shape, const Dims start, - const Dims count, const bool constantShape, + const size_t elementSize, const Dims &shape, const Dims &start, + const Dims &count, const bool constantShape, const bool debugMode); virtual ~VariableBase() = default; @@ -82,7 +82,7 @@ public: size_t TotalSize() const noexcept; /** Set the local dimension and global offset of the variable */ - void SetSelection(const Dims start, const Dims count); + void SetSelection(const Dims &start, const Dims &count); /** Overloaded version of SetSelection using a SelectionBoundingBox */ void SetSelection(const SelectionBoundingBox &selection); diff --git a/source/adios2/helper/adiosType.inl b/source/adios2/helper/adiosType.inl index 5c4243b965b168a164bfd1e5e4239ab93ac20ae3..7cea13451b7f0c472ad409c34aaee0d1c7a891c4 100644 --- a/source/adios2/helper/adiosType.inl +++ b/source/adios2/helper/adiosType.inl @@ -27,6 +27,13 @@ inline std::string GetType<void>() noexcept { return "unknown"; } + +template <> +inline std::string GetType<std::string>() noexcept +{ + return "string"; +} + template <> inline std::string GetType<char>() noexcept { diff --git a/testing/adios2/interface/CMakeLists.txt b/testing/adios2/interface/CMakeLists.txt index e68ccfa6187ab17710e4bca93579ede6ded95079..c446f5eef939d5f86583f37b3085fc436be5bbbb 100644 --- a/testing/adios2/interface/CMakeLists.txt +++ b/testing/adios2/interface/CMakeLists.txt @@ -9,5 +9,9 @@ target_link_libraries(TestADIOSInterfaceWrite adios2 gtest gtest_main) add_executable(TestADIOSDefineVariable TestADIOSDefineVariable.cpp) target_link_libraries(TestADIOSDefineVariable adios2 gtest gtest_main) +add_executable(TestADIOSDefineAttribute TestADIOSDefineAttribute.cpp) +target_link_libraries(TestADIOSDefineAttribute adios2 gtest gtest_main) + gtest_add_tests(TARGET TestADIOSInterfaceWrite) -gtest_add_tests(TARGET TestADIOSDefineVariable) \ No newline at end of file +gtest_add_tests(TARGET TestADIOSDefineVariable) +gtest_add_tests(TARGET TestADIOSDefineAttribute) \ No newline at end of file diff --git a/testing/adios2/interface/TestADIOSDefineAttribute.cpp b/testing/adios2/interface/TestADIOSDefineAttribute.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e31a439c625b5b9a054cb3e073438c064d44b864 --- /dev/null +++ b/testing/adios2/interface/TestADIOSDefineAttribute.cpp @@ -0,0 +1,591 @@ +#include <cstdint> + +#include <iostream> +#include <stdexcept> + +#include <adios2.h> + +#include <gtest/gtest.h> + +class ADIOSDefineAttributeTest : public ::testing::Test +{ +public: + ADIOSDefineAttributeTest() : adios(true), io(adios.DeclareIO("TestIO")) {} + +protected: + // virtual void SetUp() { } + + // virtual void TearDown() { } + + adios2::ADIOS adios; + adios2::IO &io; +}; + +TEST_F(ADIOSDefineAttributeTest, DefineAttributeNameException) +{ + auto &attributeString1 = + io.DefineAttribute<std::string>("attributeString", "-1"); + + EXPECT_THROW(auto &attributeString2 = + io.DefineAttribute<std::string>("attributeString", "0"), + std::invalid_argument); + + EXPECT_THROW(auto &attributeString2 = + io.GetAttribute<std::string>("NoExistingAttribute"), + std::invalid_argument); + + EXPECT_NO_THROW(auto &attributeString3 = + io.GetAttribute<std::string>("attributeString")); +} + +TEST_F(ADIOSDefineAttributeTest, DefineAttributeTypeByValue) +{ + // Define ADIOS global value + auto &attributeString = + io.DefineAttribute<std::string>("attributeString", "-1"); + auto &attributeChar = io.DefineAttribute<char>("attributeChar", '0'); + auto &attributeUChar = + io.DefineAttribute<unsigned char>("attributeUChar", '1'); + auto &attributeShort = io.DefineAttribute<short>("attributeShort", 2); + auto &attributeUShort = + io.DefineAttribute<unsigned short>("attributeUShort", 3); + auto &attributeInt = io.DefineAttribute<int>("attributeInt", 4); + auto &attributeUInt = io.DefineAttribute<unsigned int>("attributeUInt", 5); + auto &attributeLInt = io.DefineAttribute<long int>("attributeLInt", 6); + auto &attributeULInt = + io.DefineAttribute<unsigned long int>("attributeULInt", 7); + auto &attributeLLInt = + io.DefineAttribute<long long int>("attributeLLInt", 8); + auto &attributeULLInt = + io.DefineAttribute<unsigned long long int>("attributeULLInt", 9); + auto &attributeFloat = io.DefineAttribute<float>("attributeFloat", 10); + auto &attributeDouble = io.DefineAttribute<double>("attributeDouble", 11); + auto &attributeLDouble = + io.DefineAttribute<long double>("attributeLDouble", 12); + + // Verify the return type is as expected + ::testing::StaticAssertTypeEq<decltype(attributeString), + adios2::Attribute<std::string> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeChar), + adios2::Attribute<char> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUChar), + adios2::Attribute<unsigned char> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeShort), + adios2::Attribute<short> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUShort), + adios2::Attribute<unsigned short> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeInt), + adios2::Attribute<int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUInt), + adios2::Attribute<unsigned int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLInt), + adios2::Attribute<long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeULInt), + adios2::Attribute<unsigned long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLLInt), + adios2::Attribute<long long int> &>(); + ::testing::StaticAssertTypeEq< + decltype(attributeULLInt), + adios2::Attribute<unsigned long long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeFloat), + adios2::Attribute<float> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeDouble), + adios2::Attribute<double> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLDouble), + adios2::Attribute<long double> &>(); + + // Verify the members are correct + ASSERT_EQ(attributeString.m_DataArray, nullptr); + EXPECT_EQ(attributeString.m_Name, "attributeString"); + EXPECT_EQ(attributeString.m_DataValue, "-1"); + EXPECT_EQ(attributeString.m_Elements, 1); + EXPECT_EQ(attributeString.m_Type, "string"); + + ASSERT_EQ(attributeChar.m_DataArray, nullptr); + EXPECT_EQ(attributeChar.m_Name, "attributeChar"); + EXPECT_EQ(attributeChar.m_DataValue, '0'); + EXPECT_EQ(attributeChar.m_Elements, 1); + EXPECT_EQ(attributeChar.m_Type, "char"); + + ASSERT_EQ(attributeUChar.m_DataArray, nullptr); + EXPECT_EQ(attributeUChar.m_Name, "attributeUChar"); + EXPECT_EQ(attributeUChar.m_DataValue, '1'); + EXPECT_EQ(attributeUChar.m_Elements, 1); + EXPECT_EQ(attributeUChar.m_Type, "unsigned char"); + + ASSERT_EQ(attributeShort.m_DataArray, nullptr); + EXPECT_EQ(attributeShort.m_Name, "attributeShort"); + EXPECT_EQ(attributeShort.m_DataValue, 2); + EXPECT_EQ(attributeShort.m_Elements, 1); + EXPECT_EQ(attributeShort.m_Type, "short"); + + ASSERT_EQ(attributeUShort.m_DataArray, nullptr); + EXPECT_EQ(attributeUShort.m_Name, "attributeUShort"); + EXPECT_EQ(attributeUShort.m_DataValue, 3); + EXPECT_EQ(attributeUShort.m_Elements, 1); + EXPECT_EQ(attributeUShort.m_Type, "unsigned short"); + + ASSERT_EQ(attributeInt.m_DataArray, nullptr); + EXPECT_EQ(attributeInt.m_Name, "attributeInt"); + EXPECT_EQ(attributeInt.m_DataValue, 4); + EXPECT_EQ(attributeInt.m_Elements, 1); + EXPECT_EQ(attributeInt.m_Type, "int"); + + ASSERT_EQ(attributeUInt.m_DataArray, nullptr); + EXPECT_EQ(attributeUInt.m_Name, "attributeUInt"); + EXPECT_EQ(attributeUInt.m_DataValue, 5); + EXPECT_EQ(attributeUInt.m_Elements, 1); + EXPECT_EQ(attributeUInt.m_Type, "unsigned int"); + + ASSERT_EQ(attributeLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeLInt.m_Name, "attributeLInt"); + EXPECT_EQ(attributeLInt.m_DataValue, 6); + EXPECT_EQ(attributeLInt.m_Elements, 1); + EXPECT_EQ(attributeLInt.m_Type, "long int"); + + ASSERT_EQ(attributeULInt.m_DataArray, nullptr); + EXPECT_EQ(attributeULInt.m_Name, "attributeULInt"); + EXPECT_EQ(attributeULInt.m_DataValue, 7); + EXPECT_EQ(attributeULInt.m_Elements, 1); + EXPECT_EQ(attributeULInt.m_Type, "unsigned long int"); + + ASSERT_EQ(attributeLLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeLLInt.m_Name, "attributeLLInt"); + EXPECT_EQ(attributeLLInt.m_DataValue, 8); + EXPECT_EQ(attributeLLInt.m_Elements, 1); + EXPECT_EQ(attributeLLInt.m_Type, "long long int"); + + ASSERT_EQ(attributeULLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeULLInt.m_Name, "attributeULLInt"); + EXPECT_EQ(attributeULLInt.m_DataValue, 9); + EXPECT_EQ(attributeULLInt.m_Elements, 1); + EXPECT_EQ(attributeULLInt.m_Type, "unsigned long long int"); + + ASSERT_EQ(attributeFloat.m_DataArray, nullptr); + EXPECT_EQ(attributeFloat.m_Name, "attributeFloat"); + EXPECT_EQ(attributeFloat.m_DataValue, 10); + EXPECT_EQ(attributeFloat.m_Elements, 1); + EXPECT_EQ(attributeFloat.m_Type, "float"); + + ASSERT_EQ(attributeDouble.m_DataArray, nullptr); + EXPECT_EQ(attributeDouble.m_Name, "attributeDouble"); + EXPECT_EQ(attributeDouble.m_DataValue, 11); + EXPECT_EQ(attributeDouble.m_Elements, 1); + EXPECT_EQ(attributeDouble.m_Type, "double"); + + ASSERT_EQ(attributeLDouble.m_DataArray, nullptr); + EXPECT_EQ(attributeLDouble.m_Name, "attributeLDouble"); + EXPECT_EQ(attributeLDouble.m_DataValue, 12); + EXPECT_EQ(attributeLDouble.m_Elements, 1); + EXPECT_EQ(attributeLDouble.m_Type, "long double"); +} + +TEST_F(ADIOSDefineAttributeTest, DefineAttributeTypeByReference) +{ + // Define ADIOS global value + const std::vector<std::string> vString{"-1", "0", "+1"}; + const std::vector<char> vChar = {0, 0 + 1, 0 + 2}; + const std::vector<unsigned char> vUChar = {1, 1 + 1, 1 + 2}; + const std::vector<short> vShort = {2, 2 + 1, 2 + 2}; + const std::vector<unsigned short> vUShort = {3, 3 + 1, 3 + 2}; + const std::vector<int> vInt = {4, 4 + 1, 4 + 2}; + const std::vector<unsigned int> vUInt = {5, 5 + 1, 5 + 2}; + const std::vector<long int> vLInt = {6, 6 + 1, 6 + 2}; + const std::vector<unsigned long int> vULInt = {7, 7 + 1, 7 + 2}; + const std::vector<long long int> vLLInt = {8, 8 + 1, 8 + 2}; + const std::vector<unsigned long long int> vULLInt = {9, 9 + 1, 9 + 2}; + const std::vector<float> vFloat = {10, 10 + 1, 10 + 2}; + const std::vector<double> vDouble = {11, 11 + 1, 11 + 2}; + const std::vector<long double> vLDouble = {12, 12 + 1, 12 + 2}; + + auto &attributeString = + io.DefineAttribute<std::string>("attributeString", vString.data(), 3); + + auto &attributeChar = + io.DefineAttribute<char>("attributeChar", vChar.data(), 3); + auto &attributeUChar = + io.DefineAttribute<unsigned char>("attributeUChar", vUChar.data(), 3); + auto &attributeShort = + io.DefineAttribute<short>("attributeShort", vShort.data(), 3); + auto &attributeUShort = io.DefineAttribute<unsigned short>( + "attributeUShort", vUShort.data(), 3); + auto &attributeInt = + io.DefineAttribute<int>("attributeInt", vInt.data(), 3); + auto &attributeUInt = + io.DefineAttribute<unsigned int>("attributeUInt", vUInt.data(), 3); + auto &attributeLInt = + io.DefineAttribute<long int>("attributeLInt", vLInt.data(), 3); + auto &attributeULInt = io.DefineAttribute<unsigned long int>( + "attributeULInt", vULInt.data(), 3); + auto &attributeLLInt = + io.DefineAttribute<long long int>("attributeLLInt", vLLInt.data(), 3); + auto &attributeULLInt = io.DefineAttribute<unsigned long long int>( + "attributeULLInt", vULLInt.data(), 3); + auto &attributeFloat = + io.DefineAttribute<float>("attributeFloat", vFloat.data(), 3); + auto &attributeDouble = + io.DefineAttribute<double>("attributeDouble", vDouble.data(), 3); + auto &attributeLDouble = + io.DefineAttribute<long double>("attributeLDouble", vLDouble.data(), 3); + + // Verify the return type is as expected + ::testing::StaticAssertTypeEq<decltype(attributeString), + adios2::Attribute<std::string> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeChar), + adios2::Attribute<char> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUChar), + adios2::Attribute<unsigned char> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeShort), + adios2::Attribute<short> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUShort), + adios2::Attribute<unsigned short> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeInt), + adios2::Attribute<int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUInt), + adios2::Attribute<unsigned int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLInt), + adios2::Attribute<long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeULInt), + adios2::Attribute<unsigned long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLLInt), + adios2::Attribute<long long int> &>(); + ::testing::StaticAssertTypeEq< + decltype(attributeULLInt), + adios2::Attribute<unsigned long long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeFloat), + adios2::Attribute<float> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeDouble), + adios2::Attribute<double> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLDouble), + adios2::Attribute<long double> &>(); + + // Verify the dimensions, name, and type are correct + ASSERT_NE(attributeString.m_DataArray, nullptr); + EXPECT_EQ(attributeString.m_DataArray[0], "-1"); + EXPECT_EQ(attributeString.m_DataArray[1], "0"); + EXPECT_EQ(attributeString.m_DataArray[2], "+1"); + EXPECT_EQ(attributeString.m_Name, "attributeString"); + ASSERT_EQ(attributeString.m_DataValue.empty(), true); + EXPECT_EQ(attributeString.m_Elements, 3); + EXPECT_EQ(attributeString.m_Type, "string"); + + ASSERT_NE(attributeChar.m_DataArray, nullptr); + EXPECT_EQ(attributeChar.m_DataArray[0], 0); + EXPECT_EQ(attributeChar.m_DataArray[1], 0 + 1); + EXPECT_EQ(attributeChar.m_DataArray[2], 0 + 2); + EXPECT_EQ(attributeChar.m_Name, "attributeChar"); + EXPECT_EQ(attributeChar.m_Elements, 3); + EXPECT_EQ(attributeChar.m_Type, "char"); + + ASSERT_NE(attributeUChar.m_DataArray, nullptr); + EXPECT_EQ(attributeUChar.m_DataArray[0], 1); + EXPECT_EQ(attributeUChar.m_DataArray[1], 1 + 1); + EXPECT_EQ(attributeUChar.m_DataArray[2], 1 + 2); + EXPECT_EQ(attributeUChar.m_Name, "attributeUChar"); + EXPECT_EQ(attributeUChar.m_Elements, 3); + EXPECT_EQ(attributeUChar.m_Type, "unsigned char"); + + ASSERT_NE(attributeShort.m_DataArray, nullptr); + EXPECT_EQ(attributeShort.m_DataArray[0], 2); + EXPECT_EQ(attributeShort.m_DataArray[1], 2 + 1); + EXPECT_EQ(attributeShort.m_DataArray[2], 2 + 2); + EXPECT_EQ(attributeShort.m_Name, "attributeShort"); + EXPECT_EQ(attributeShort.m_Elements, 3); + EXPECT_EQ(attributeShort.m_Type, "short"); + + ASSERT_NE(attributeUShort.m_DataArray, nullptr); + EXPECT_EQ(attributeUShort.m_DataArray[0], 3); + EXPECT_EQ(attributeUShort.m_DataArray[1], 3 + 1); + EXPECT_EQ(attributeUShort.m_DataArray[2], 3 + 2); + EXPECT_EQ(attributeUShort.m_Name, "attributeUShort"); + EXPECT_EQ(attributeUShort.m_Elements, 3); + EXPECT_EQ(attributeUShort.m_Type, "unsigned short"); + + ASSERT_NE(attributeInt.m_DataArray, nullptr); + EXPECT_EQ(attributeInt.m_DataArray[0], 4); + EXPECT_EQ(attributeInt.m_DataArray[1], 4 + 1); + EXPECT_EQ(attributeInt.m_DataArray[2], 4 + 2); + EXPECT_EQ(attributeInt.m_Name, "attributeInt"); + EXPECT_EQ(attributeInt.m_Elements, 3); + EXPECT_EQ(attributeInt.m_Type, "int"); + + ASSERT_NE(attributeUInt.m_DataArray, nullptr); + EXPECT_EQ(attributeUInt.m_DataArray[0], 5); + EXPECT_EQ(attributeUInt.m_DataArray[1], 5 + 1); + EXPECT_EQ(attributeUInt.m_DataArray[2], 5 + 2); + EXPECT_EQ(attributeUInt.m_Name, "attributeUInt"); + EXPECT_EQ(attributeUInt.m_Elements, 3); + EXPECT_EQ(attributeUInt.m_Type, "unsigned int"); + + ASSERT_NE(attributeLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeLInt.m_DataArray[0], 6); + EXPECT_EQ(attributeLInt.m_DataArray[1], 6 + 1); + EXPECT_EQ(attributeLInt.m_DataArray[2], 6 + 2); + EXPECT_EQ(attributeLInt.m_Name, "attributeLInt"); + EXPECT_EQ(attributeLInt.m_Elements, 3); + EXPECT_EQ(attributeLInt.m_Type, "long int"); + + ASSERT_NE(attributeULInt.m_DataArray, nullptr); + EXPECT_EQ(attributeULInt.m_DataArray[0], 7); + EXPECT_EQ(attributeULInt.m_DataArray[1], 7 + 1); + EXPECT_EQ(attributeULInt.m_DataArray[2], 7 + 2); + EXPECT_EQ(attributeULInt.m_Name, "attributeULInt"); + EXPECT_EQ(attributeULInt.m_Elements, 3); + EXPECT_EQ(attributeULInt.m_Type, "unsigned long int"); + + ASSERT_NE(attributeLLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeLLInt.m_DataArray[0], 8); + EXPECT_EQ(attributeLLInt.m_DataArray[1], 8 + 1); + EXPECT_EQ(attributeLLInt.m_DataArray[2], 8 + 2); + EXPECT_EQ(attributeLLInt.m_Name, "attributeLLInt"); + EXPECT_EQ(attributeLLInt.m_Elements, 3); + EXPECT_EQ(attributeLLInt.m_Type, "long long int"); + + ASSERT_NE(attributeULLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeULLInt.m_DataArray[0], 9); + EXPECT_EQ(attributeULLInt.m_DataArray[1], 9 + 1); + EXPECT_EQ(attributeULLInt.m_DataArray[2], 9 + 2); + EXPECT_EQ(attributeULLInt.m_Name, "attributeULLInt"); + EXPECT_EQ(attributeULLInt.m_Elements, 3); + EXPECT_EQ(attributeULLInt.m_Type, "unsigned long long int"); + + ASSERT_NE(attributeFloat.m_DataArray, nullptr); + EXPECT_EQ(attributeFloat.m_DataArray[0], 10); + EXPECT_EQ(attributeFloat.m_DataArray[1], 10 + 1); + EXPECT_EQ(attributeFloat.m_DataArray[2], 10 + 2); + EXPECT_EQ(attributeFloat.m_Name, "attributeFloat"); + EXPECT_EQ(attributeFloat.m_Elements, 3); + EXPECT_EQ(attributeFloat.m_Type, "float"); + + ASSERT_NE(attributeDouble.m_DataArray, nullptr); + EXPECT_EQ(attributeDouble.m_DataArray[0], 11); + EXPECT_EQ(attributeDouble.m_DataArray[1], 11 + 1); + EXPECT_EQ(attributeDouble.m_DataArray[2], 11 + 2); + EXPECT_EQ(attributeDouble.m_Name, "attributeDouble"); + EXPECT_EQ(attributeDouble.m_Elements, 3); + EXPECT_EQ(attributeDouble.m_Type, "double"); + + ASSERT_NE(attributeLDouble.m_DataArray, nullptr); + EXPECT_EQ(attributeLDouble.m_DataArray[0], 12); + EXPECT_EQ(attributeLDouble.m_DataArray[1], 12 + 1); + EXPECT_EQ(attributeLDouble.m_DataArray[2], 12 + 2); + EXPECT_EQ(attributeLDouble.m_Name, "attributeLDouble"); + EXPECT_EQ(attributeLDouble.m_Elements, 3); + EXPECT_EQ(attributeLDouble.m_Type, "long double"); +} + +TEST_F(ADIOSDefineAttributeTest, GetAttribute) +{ + // Define ADIOS global value + const std::vector<std::string> vString{"-1", "0", "+1"}; + const std::vector<char> vChar = {0, 0 + 1, 0 + 2}; + const std::vector<unsigned char> vUChar = {1, 1 + 1, 1 + 2}; + const std::vector<short> vShort = {2, 2 + 1, 2 + 2}; + const std::vector<unsigned short> vUShort = {3, 3 + 1, 3 + 2}; + const std::vector<int> vInt = {4, 4 + 1, 4 + 2}; + const std::vector<unsigned int> vUInt = {5, 5 + 1, 5 + 2}; + const std::vector<long int> vLInt = {6, 6 + 1, 6 + 2}; + const std::vector<unsigned long int> vULInt = {7, 7 + 1, 7 + 2}; + const std::vector<long long int> vLLInt = {8, 8 + 1, 8 + 2}; + const std::vector<unsigned long long int> vULLInt = {9, 9 + 1, 9 + 2}; + const std::vector<float> vFloat = {10, 10 + 1, 10 + 2}; + const std::vector<double> vDouble = {11, 11 + 1, 11 + 2}; + const std::vector<long double> vLDouble = {12, 12 + 1, 12 + 2}; + + { + io.DefineAttribute<std::string>("attributeString", vString.data(), 3); + io.DefineAttribute<char>("attributeChar", vChar.data(), 3); + io.DefineAttribute<unsigned char>("attributeUChar", vUChar.data(), 3); + io.DefineAttribute<short>("attributeShort", vShort.data(), 3); + io.DefineAttribute<unsigned short>("attributeUShort", vUShort.data(), + 3); + io.DefineAttribute<int>("attributeInt", vInt.data(), 3); + io.DefineAttribute<unsigned int>("attributeUInt", vUInt.data(), 3); + io.DefineAttribute<long int>("attributeLInt", vLInt.data(), 3); + io.DefineAttribute<unsigned long int>("attributeULInt", vULInt.data(), + 3); + io.DefineAttribute<long long int>("attributeLLInt", vLLInt.data(), 3); + io.DefineAttribute<unsigned long long int>("attributeULLInt", + vULLInt.data(), 3); + io.DefineAttribute<float>("attributeFloat", vFloat.data(), 3); + io.DefineAttribute<double>("attributeDouble", vDouble.data(), 3); + io.DefineAttribute<long double>("attributeLDouble", vLDouble.data(), 3); + } + + auto &attributeString = io.GetAttribute<std::string>("attributeString"); + auto &attributeChar = io.GetAttribute<char>("attributeChar"); + auto &attributeUChar = io.GetAttribute<unsigned char>("attributeUChar"); + auto &attributeShort = io.GetAttribute<short>("attributeShort"); + auto &attributeUShort = io.GetAttribute<unsigned short>("attributeUShort"); + auto &attributeInt = io.GetAttribute<int>("attributeInt"); + auto &attributeUInt = io.GetAttribute<unsigned int>("attributeUInt"); + auto &attributeLInt = io.GetAttribute<long int>("attributeLInt"); + auto &attributeULInt = io.GetAttribute<unsigned long int>("attributeULInt"); + auto &attributeLLInt = io.GetAttribute<long long int>("attributeLLInt"); + auto &attributeULLInt = + io.GetAttribute<unsigned long long int>("attributeULLInt"); + auto &attributeFloat = io.GetAttribute<float>("attributeFloat"); + auto &attributeDouble = io.GetAttribute<double>("attributeDouble"); + auto &attributeLDouble = io.GetAttribute<long double>("attributeLDouble"); + + // Verify the return type is as expected + ::testing::StaticAssertTypeEq<decltype(attributeString), + adios2::Attribute<std::string> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeChar), + adios2::Attribute<char> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUChar), + adios2::Attribute<unsigned char> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeShort), + adios2::Attribute<short> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUShort), + adios2::Attribute<unsigned short> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeInt), + adios2::Attribute<int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeUInt), + adios2::Attribute<unsigned int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLInt), + adios2::Attribute<long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeULInt), + adios2::Attribute<unsigned long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLLInt), + adios2::Attribute<long long int> &>(); + ::testing::StaticAssertTypeEq< + decltype(attributeULLInt), + adios2::Attribute<unsigned long long int> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeFloat), + adios2::Attribute<float> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeDouble), + adios2::Attribute<double> &>(); + ::testing::StaticAssertTypeEq<decltype(attributeLDouble), + adios2::Attribute<long double> &>(); + + // Verify the dimensions, name, and type are correct + ASSERT_NE(attributeString.m_DataArray, nullptr); + EXPECT_EQ(attributeString.m_DataArray[0], "-1"); + EXPECT_EQ(attributeString.m_DataArray[1], "0"); + EXPECT_EQ(attributeString.m_DataArray[2], "+1"); + EXPECT_EQ(attributeString.m_Name, "attributeString"); + ASSERT_EQ(attributeString.m_DataValue.empty(), true); + EXPECT_EQ(attributeString.m_Elements, 3); + EXPECT_EQ(attributeString.m_Type, "string"); + + ASSERT_NE(attributeChar.m_DataArray, nullptr); + EXPECT_EQ(attributeChar.m_DataArray[0], 0); + EXPECT_EQ(attributeChar.m_DataArray[1], 0 + 1); + EXPECT_EQ(attributeChar.m_DataArray[2], 0 + 2); + EXPECT_EQ(attributeChar.m_Name, "attributeChar"); + EXPECT_EQ(attributeChar.m_Elements, 3); + EXPECT_EQ(attributeChar.m_Type, "char"); + + ASSERT_NE(attributeUChar.m_DataArray, nullptr); + EXPECT_EQ(attributeUChar.m_DataArray[0], 1); + EXPECT_EQ(attributeUChar.m_DataArray[1], 1 + 1); + EXPECT_EQ(attributeUChar.m_DataArray[2], 1 + 2); + EXPECT_EQ(attributeUChar.m_Name, "attributeUChar"); + EXPECT_EQ(attributeUChar.m_Elements, 3); + EXPECT_EQ(attributeUChar.m_Type, "unsigned char"); + + ASSERT_NE(attributeShort.m_DataArray, nullptr); + EXPECT_EQ(attributeShort.m_DataArray[0], 2); + EXPECT_EQ(attributeShort.m_DataArray[1], 2 + 1); + EXPECT_EQ(attributeShort.m_DataArray[2], 2 + 2); + EXPECT_EQ(attributeShort.m_Name, "attributeShort"); + EXPECT_EQ(attributeShort.m_Elements, 3); + EXPECT_EQ(attributeShort.m_Type, "short"); + + ASSERT_NE(attributeUShort.m_DataArray, nullptr); + EXPECT_EQ(attributeUShort.m_DataArray[0], 3); + EXPECT_EQ(attributeUShort.m_DataArray[1], 3 + 1); + EXPECT_EQ(attributeUShort.m_DataArray[2], 3 + 2); + EXPECT_EQ(attributeUShort.m_Name, "attributeUShort"); + EXPECT_EQ(attributeUShort.m_Elements, 3); + EXPECT_EQ(attributeUShort.m_Type, "unsigned short"); + + ASSERT_NE(attributeInt.m_DataArray, nullptr); + EXPECT_EQ(attributeInt.m_DataArray[0], 4); + EXPECT_EQ(attributeInt.m_DataArray[1], 4 + 1); + EXPECT_EQ(attributeInt.m_DataArray[2], 4 + 2); + EXPECT_EQ(attributeInt.m_Name, "attributeInt"); + EXPECT_EQ(attributeInt.m_Elements, 3); + EXPECT_EQ(attributeInt.m_Type, "int"); + + ASSERT_NE(attributeUInt.m_DataArray, nullptr); + EXPECT_EQ(attributeUInt.m_DataArray[0], 5); + EXPECT_EQ(attributeUInt.m_DataArray[1], 5 + 1); + EXPECT_EQ(attributeUInt.m_DataArray[2], 5 + 2); + EXPECT_EQ(attributeUInt.m_Name, "attributeUInt"); + EXPECT_EQ(attributeUInt.m_Elements, 3); + EXPECT_EQ(attributeUInt.m_Type, "unsigned int"); + + ASSERT_NE(attributeLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeLInt.m_DataArray[0], 6); + EXPECT_EQ(attributeLInt.m_DataArray[1], 6 + 1); + EXPECT_EQ(attributeLInt.m_DataArray[2], 6 + 2); + EXPECT_EQ(attributeLInt.m_Name, "attributeLInt"); + EXPECT_EQ(attributeLInt.m_Elements, 3); + EXPECT_EQ(attributeLInt.m_Type, "long int"); + + ASSERT_NE(attributeULInt.m_DataArray, nullptr); + EXPECT_EQ(attributeULInt.m_DataArray[0], 7); + EXPECT_EQ(attributeULInt.m_DataArray[1], 7 + 1); + EXPECT_EQ(attributeULInt.m_DataArray[2], 7 + 2); + EXPECT_EQ(attributeULInt.m_Name, "attributeULInt"); + EXPECT_EQ(attributeULInt.m_Elements, 3); + EXPECT_EQ(attributeULInt.m_Type, "unsigned long int"); + + ASSERT_NE(attributeLLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeLLInt.m_DataArray[0], 8); + EXPECT_EQ(attributeLLInt.m_DataArray[1], 8 + 1); + EXPECT_EQ(attributeLLInt.m_DataArray[2], 8 + 2); + EXPECT_EQ(attributeLLInt.m_Name, "attributeLLInt"); + EXPECT_EQ(attributeLLInt.m_Elements, 3); + EXPECT_EQ(attributeLLInt.m_Type, "long long int"); + + ASSERT_NE(attributeULLInt.m_DataArray, nullptr); + EXPECT_EQ(attributeULLInt.m_DataArray[0], 9); + EXPECT_EQ(attributeULLInt.m_DataArray[1], 9 + 1); + EXPECT_EQ(attributeULLInt.m_DataArray[2], 9 + 2); + EXPECT_EQ(attributeULLInt.m_Name, "attributeULLInt"); + EXPECT_EQ(attributeULLInt.m_Elements, 3); + EXPECT_EQ(attributeULLInt.m_Type, "unsigned long long int"); + + ASSERT_NE(attributeFloat.m_DataArray, nullptr); + EXPECT_EQ(attributeFloat.m_DataArray[0], 10); + EXPECT_EQ(attributeFloat.m_DataArray[1], 10 + 1); + EXPECT_EQ(attributeFloat.m_DataArray[2], 10 + 2); + EXPECT_EQ(attributeFloat.m_Name, "attributeFloat"); + EXPECT_EQ(attributeFloat.m_Elements, 3); + EXPECT_EQ(attributeFloat.m_Type, "float"); + + ASSERT_NE(attributeDouble.m_DataArray, nullptr); + EXPECT_EQ(attributeDouble.m_DataArray[0], 11); + EXPECT_EQ(attributeDouble.m_DataArray[1], 11 + 1); + EXPECT_EQ(attributeDouble.m_DataArray[2], 11 + 2); + EXPECT_EQ(attributeDouble.m_Name, "attributeDouble"); + EXPECT_EQ(attributeDouble.m_Elements, 3); + EXPECT_EQ(attributeDouble.m_Type, "double"); + + ASSERT_NE(attributeLDouble.m_DataArray, nullptr); + EXPECT_EQ(attributeLDouble.m_DataArray[0], 12); + EXPECT_EQ(attributeLDouble.m_DataArray[1], 12 + 1); + EXPECT_EQ(attributeLDouble.m_DataArray[2], 12 + 2); + EXPECT_EQ(attributeLDouble.m_Name, "attributeLDouble"); + EXPECT_EQ(attributeLDouble.m_Elements, 3); + EXPECT_EQ(attributeLDouble.m_Type, "long double"); +} + +int main(int argc, char **argv) +{ +#ifdef ADIOS2_HAVE_MPI + MPI_Init(nullptr, nullptr); +#endif + + ::testing::InitGoogleTest(&argc, argv); + int result = RUN_ALL_TESTS(); + +#ifdef ADIOS2_HAVE_MPI + MPI_Finalize(); +#endif + + return result; +}