File: ExampleWritePlugin.h

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • 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 (91 lines) | stat: -rw-r--r-- 2,704 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * ExampleWritePlugin.h Simple file writing engine. Creates directory
 * (called "ExamplePlugin" by default, but can be changed with engine parameter
 * "DirName") and writes variable info to vars.txt and actual data to data.txt.
 *
 *  Created on: Jul 5, 2021
 *      Author: Chuck Atkins <chuck.atkins@kitware.com>
 *              Caitlin Ross <caitlin.ross@kitware.com>
 */

#ifndef EXAMPLEWRITEPLUGIN_H_
#define EXAMPLEWRITEPLUGIN_H_

#include "plugin_engine_write_export.h"

#include <fstream>
#include <memory>
#include <string>

#include "adios2/common/ADIOSMacros.h"
#include "adios2/common/ADIOSTypes.h"
#include "adios2/core/IO.h"
#include "adios2/engine/plugin/PluginEngineInterface.h"
#include "adios2/helper/adiosComm.h"
#include "adios2/helper/adiosType.h"

namespace adios2
{
namespace plugin
{

/** An engine interface to be used by the plugin infrastructure */
class ExampleWritePlugin : public PluginEngineInterface
{
public:
    ExampleWritePlugin(core::IO &io, const std::string &name, const Mode openMode,
                       helper::Comm comm);
    virtual ~ExampleWritePlugin();

    /** Indicates beginning of a step **/
    StepStatus BeginStep(StepMode mode, const float timeoutSeconds = -1.0) override;

    /** Indicates end of a step **/
    void EndStep() override;

    /** Return the current step **/
    size_t CurrentStep() const override;

    /** Execute deferred mode Puts **/
    void PerformPuts() override;

protected:
    void Init() override;

#define declare(T)                                                                                 \
    void DoPutSync(core::Variable<T> &variable, const T *values) override;                         \
    void DoPutDeferred(core::Variable<T> &variable, const T *values) override;
    ADIOS2_FOREACH_STDTYPE_1ARG(declare)
#undef declare

    void DoClose(const int transportIndex = -1) override;

private:
    std::ofstream m_DataFile;
    std::ofstream m_VarFile;
    size_t m_CurrentStep = 0;

    void WriteVarsFromIO();

    template <typename T>
    void WriteVariableInfo(core::Variable<T> &variable);

    template <typename T>
    void WriteArray(core::Variable<T> &variable, const T *values);
};

} // end namespace plugin
} // end namespace adios2

extern "C" {

PLUGIN_ENGINE_WRITE_EXPORT adios2::plugin::ExampleWritePlugin *
EngineCreate(adios2::core::IO &io, const std::string &name, const adios2::Mode mode,
             adios2::helper::Comm comm);
PLUGIN_ENGINE_WRITE_EXPORT void EngineDestroy(adios2::plugin::ExampleWritePlugin *obj);
}

#endif /* EXAMPLEWRITEPLUGIN_H_ */