File: stream.cpp

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 33,764 kB
  • sloc: cpp: 175,964; ansic: 160,510; f90: 14,630; yacc: 12,668; python: 7,275; perl: 7,126; sh: 2,825; lisp: 1,106; xml: 1,049; makefile: 579; lex: 557
file content (75 lines) | stat: -rw-r--r-- 1,897 bytes parent folder | download | duplicates (2)
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
/*
 * stream.cpp
 *
 *  Created on: Nov 2018
 *      Author: Norbert Podhorszki
 */

#include "adios2/common/ADIOSConfig.h"

#include "adiosStream.h"
#include "stream.h"

#ifdef ADIOS2_HAVE_HDF5_PARALLEL
#include "hdf5Stream.h"
#endif

ioGroup::~ioGroup() {}
Stream::Stream(const std::string &streamName, const adios2::Mode mode)
: streamName(streamName), mode(mode)
{
}
Stream::~Stream() {}

void Stream::fillArray(std::shared_ptr<VariableInfo> ov, double value)
{
    if (ov->type == "double")
    {
        double *a = reinterpret_cast<double *>(ov->data.data());
        for (size_t i = 0; i < ov->datasize / ov->elemsize; ++i)
        {
            a[i] = value;
        }
    }
    else if (ov->type == "float")
    {
        float v = static_cast<float>(value);
        float *a = reinterpret_cast<float *>(ov->data.data());
        for (size_t i = 0; i < ov->datasize / ov->elemsize; ++i)
        {
            a[i] = v;
        }
    }
    else if (ov->type == "int")
    {
        int v = static_cast<int>(value);
        int *a = reinterpret_cast<int *>(ov->data.data());
        for (size_t i = 0; i < ov->datasize / ov->elemsize; ++i)
        {
            a[i] = v;
        }
    }
}

std::shared_ptr<Stream> openStream(const std::string &streamName, std::shared_ptr<ioGroup> iogroup,
                                   const adios2::Mode mode, IOLib iolib, MPI_Comm comm,
                                   bool iotimer, size_t appid)
{
    std::shared_ptr<Stream> sp;
    switch (iolib)
    {
    case IOLib::ADIOS: {
        auto s = adiosStream(streamName, iogroup->adiosio, mode, comm, iotimer, appid);
        sp = std::make_shared<adiosStream>(s);
        break;
    }
#ifdef ADIOS2_HAVE_HDF5_PARALLEL
    case IOLib::HDF5: {
        auto s = hdf5Stream(streamName, mode, comm);
        sp = std::make_shared<hdf5Stream>(s);
        break;
    }
#endif
    }
    return sp;
}