1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
/*=========================================================================
Program: Visualization Toolkit
Module: ADIOSUtilities.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkType.h>
#include <adios.h>
#include <adios_read.h>
#include "ADIOSUtilities.h"
namespace ADIOS
{
//----------------------------------------------------------------------------
WriteError::WriteError(const std::string& msg)
: std::runtime_error(msg.empty() ? adios_get_last_errmsg() : msg)
{
if(msg.empty())
{
adios_clear_error();
}
}
//----------------------------------------------------------------------------
ReadError::ReadError(const std::string& msg)
: std::runtime_error(msg.empty() ? adios_errmsg() : msg)
{
}
namespace Type
{
//----------------------------------------------------------------------------
template<> ADIOS_DATATYPES SizeToInt<1>() { return adios_byte; }
template<> ADIOS_DATATYPES SizeToInt<2>() { return adios_short; }
template<> ADIOS_DATATYPES SizeToInt<4>() { return adios_integer; }
template<> ADIOS_DATATYPES SizeToInt<8>() { return adios_long; }
template<> ADIOS_DATATYPES SizeToUInt<1>() { return adios_unsigned_byte; }
template<> ADIOS_DATATYPES SizeToUInt<2>() { return adios_unsigned_short; }
template<> ADIOS_DATATYPES SizeToUInt<4>() { return adios_unsigned_integer; }
template<> ADIOS_DATATYPES SizeToUInt<8>() { return adios_unsigned_long; }
//----------------------------------------------------------------------------
#define INSTANTIATE(TN, TA) \
template<> ADIOS_DATATYPES NativeToADIOS<TN>() { return TA; }
INSTANTIATE(int8_t, adios_byte)
INSTANTIATE(int16_t, adios_short)
INSTANTIATE(int32_t, adios_integer)
INSTANTIATE(int64_t, adios_long)
INSTANTIATE(uint8_t, adios_unsigned_byte)
INSTANTIATE(uint16_t, adios_unsigned_short)
INSTANTIATE(uint32_t, adios_unsigned_integer)
INSTANTIATE(uint64_t, adios_unsigned_long)
INSTANTIATE(float, adios_real)
INSTANTIATE(double, adios_double)
INSTANTIATE(std::complex<float>, adios_complex)
INSTANTIATE(std::complex<double>, adios_double_complex)
INSTANTIATE(std::string, adios_string)
#undef INSTANTIATE
//----------------------------------------------------------------------------
size_t SizeOf(ADIOS_DATATYPES ta)
{
switch(ta)
{
case adios_byte: return 1;
case adios_short: return 2;
case adios_integer: return 4;
case adios_long: return 8;
case adios_unsigned_byte: return 1;
case adios_unsigned_short: return 2;
case adios_unsigned_integer: return 4;
case adios_unsigned_long: return 8;
case adios_real: return 4;
case adios_double: return 8;
case adios_complex: return 8;
case adios_double_complex: return 16;
case adios_string: return 1;
default: return 0;
}
}
//----------------------------------------------------------------------------
bool IsInt(ADIOS_DATATYPES ta)
{
return ta == adios_byte || ta == adios_short ||
ta == adios_integer || ta == adios_long ||
ta == adios_unsigned_byte || ta == adios_unsigned_short ||
ta == adios_unsigned_integer || ta == adios_unsigned_long;
}
} // End namespace Tye
} // End namespace ADIOS
|