Unverified Commit 8a8feaed authored by Bolea Sanchez, Vicente Adolfo's avatar Bolea Sanchez, Vicente Adolfo Committed by GitHub
Browse files

Merge pull request #5028 from ornladios-robot/backport-to-release_212-5025

Backport #5025 to release_212
parents 8b6f8ad8 f681c26f
Loading
Loading
Loading
Loading
+35 −33
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@
 * SPDX-License-Identifier: Apache-2.0
 */


#ifndef ADIOS2_HELPER_ADIOSTYPE_INL_
#define ADIOS2_HELPER_ADIOSTYPE_INL_
#ifndef ADIOS2_HELPER_ADIOSTYPE_H_
@@ -13,6 +12,7 @@

#include <algorithm>   //std::transform
#include <sstream>     //std::ostringstream
#include <type_traits> //std::is_floating_point_v

#include "adios2/common/ADIOSMacros.h"
#include "adiosLog.h"
@@ -110,8 +110,7 @@ template <class T, class U>
std::vector<U> NewVectorTypeFromArray(const T *in, const size_t inSize)
{
    std::vector<U> out(inSize);
    std::transform(in, in + inSize, out.begin(),
                   [](T value) { return static_cast<U>(value); });
    std::transform(in, in + inSize, out.begin(), [](T value) { return static_cast<U>(value); });
    return out;
}

@@ -163,6 +162,10 @@ template <class T>
inline std::string ValueToString(const T value) noexcept
{
    std::ostringstream valueSS;
    if constexpr (std::is_floating_point_v<T>)
    {
        valueSS << std::scientific;
    }
    valueSS << value;
    const std::string valueStr(valueSS.str());
    return valueStr;
@@ -237,8 +240,7 @@ void CheckForNullptr(T *pointer, const std::string hint)
{
    if (pointer == nullptr)
    {
        helper::Throw<std::invalid_argument>("Helper", "adiosType",
                                             "CheckForNullPtr",
        helper::Throw<std::invalid_argument>("Helper", "adiosType", "CheckForNullPtr",
                                             "found null pointer " + hint);
    }
}
+40 −11
Original line number Diff line number Diff line
@@ -918,7 +918,7 @@ int printAttributeValue(core::Engine *fp, core::IO *io, core::Attribute<T> *attr
    DataType adiosvartype = attribute->m_Type;
    if (attribute->m_IsSingleValue)
    {
        print_data((void *)&attribute->m_DataSingleValue, 0, adiosvartype, true);
        print_data((void *)&attribute->m_DataSingleValue, 0, adiosvartype, false);
    }
    else
    {
@@ -926,7 +926,7 @@ int printAttributeValue(core::Engine *fp, core::IO *io, core::Attribute<T> *attr
        size_t nelems = attribute->m_DataArray.size();
        for (size_t j = 0; j < nelems; j++)
        {
            print_data((void *)&attribute->m_DataArray[j], 0, adiosvartype, true);
            print_data((void *)&attribute->m_DataArray[j], 0, adiosvartype, false);
            if (j < nelems - 1)
            {
                fprintf(outf, ", ");
@@ -953,7 +953,7 @@ int printAttributeValue(core::Engine *fp, core::IO *io, core::Attribute<std::str
        }
        if (printDataAnyway)
        {
            print_data((void *)&attribute->m_DataSingleValue, 0, adiosvartype, true);
            print_data((void *)&attribute->m_DataSingleValue, 0, adiosvartype, false);
        }
    }
    else
@@ -969,7 +969,7 @@ int printAttributeValue(core::Engine *fp, core::IO *io, core::Attribute<std::str
            }
            if (printDataAnyway)
            {
                print_data((void *)&attribute->m_DataArray[j], 0, adiosvartype, true);
                print_data((void *)&attribute->m_DataArray[j], 0, adiosvartype, false);
            }
            if (j < nelems - 1)
            {
@@ -3072,18 +3072,47 @@ int print_data(const void *data, int item, DataType adiosvartype, bool allowform
        fprintf(outf, (f ? fmt : "%lld"), ((signed long long *)data)[item]);
        break;

    case DataType::Float:
        fprintf(outf, (f ? fmt : "%g"), ((float *)data)[item]);
    case DataType::Float: {
        float v = ((float *)data)[item];
        if (allowformat)
            fprintf(outf, (f ? fmt : "%g"), v);
        else
        {
            if (-10000.0 < v && v < 100000.0)
                fprintf(outf, "%g", v);
            else
                fprintf(outf, "%e", v);
        }
        break;
    }

    case DataType::Double:
        fprintf(outf, (f ? fmt : "%g"), ((double *)data)[item]);
    case DataType::Double: {
        double v = ((double *)data)[item];
        if (allowformat)
            fprintf(outf, (f ? fmt : "%g"), v);
        else
        {
            if (-10000.0 < v && v < 100000.0)
                fprintf(outf, "%g", v);
            else
                fprintf(outf, "%e", v);
        }
        break;
    }

    case DataType::LongDouble:
        fprintf(outf, (f ? fmt : "%Lg"), ((long double *)data)[item]);
        // fprintf(outf,(f ? fmt : "????????"));
    case DataType::LongDouble: {
        long double v = ((long double *)data)[item];
        if (allowformat)
            fprintf(outf, (f ? fmt : "%Lg"), v);
        else
        {
            if (-10000.0 < v && v < 100000.0)
                fprintf(outf, "%Lg", v);
            else
                fprintf(outf, "%Le", v);
        }
        break;
    }

    case DataType::FloatComplex:
        fprintf(outf, (f ? fmt : "(%g,i%g)"), ((float *)data)[2 * item],
+2 −2
Original line number Diff line number Diff line
COMPARE : FILE : TestBPcmp_set1.bp : FILE : TestBPcmp_set2.bp
DIFFER : NUM_STEPS : 2 <> 3 : TestBPcmp_set1.bp : TestBPcmp_set2.bp
DIFFER : VARIABLE : bpFloats : MIN : 4 <> 6 : TestBPcmp_set1.bp : TestBPcmp_set2.bp
DIFFER : VARIABLE : bpFloats : MAX : 10 <> 11 : TestBPcmp_set1.bp : TestBPcmp_set2.bp
DIFFER : VARIABLE : bpFloats : MIN : 4.000000e+00 <> 6.000000e+00 : TestBPcmp_set1.bp : TestBPcmp_set2.bp
DIFFER : VARIABLE : bpFloats : MAX : 1.000000e+01 <> 1.100000e+01 : TestBPcmp_set1.bp : TestBPcmp_set2.bp
DIFFER : VARIABLE : bpFloats : STEP : 0 : VALUES_SUMMARY : 6 : TestBPcmp_set1.bp : TestBPcmp_set2.bp
DIFFER : VARIABLE : bpFloats : STEP : 1 : VALUES_SUMMARY : 6 : TestBPcmp_set1.bp : TestBPcmp_set2.bp
DIFFER : VARIABLE : bpStep : NUM_STEPS : 2 <> 3 : TestBPcmp_set1.bp : TestBPcmp_set2.bp