Skip to content
Snippets Groups Projects
ADIOS.h 4.76 KiB
Newer Older
/*
 * ADIOS.h
 *
 *  Created on: Oct 3, 2016
 *      Author: wfg
 */

#ifndef ADIOS_H_
#define ADIOS_H_

/// \cond EXCLUDE_FROM_DOXYGEN
#include <string>
#include <memory> //shared_ptr and unique_ptr
#else
  #include "public/mpidummy.h"
#include "core/CGroup.h"
wfg's avatar
wfg committed
#include "core/CTransport.h"
#include "core/CTransform.h"
#include "public/SSupport.h"


namespace adios
{
/**
 * @brief Unique class interface between user application and ADIOS library
wfg's avatar
wfg committed
public: // PUBLIC Constructors and Functions define the User Interface with ADIOS
    #ifdef HAVE_MPI
    MPI_Comm m_MPIComm; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C
    #else
    MPI_Comm m_MPIComm = 0; ///< only used as reference to MPI communicator passed from parallel constructor, MPI_Comm is a pointer itself. Public as called from C
    #endif

wfg's avatar
wfg committed
     * @brief ADIOS empty constructor. Used for non XML config file API calls.
     * @brief Serial constructor for XML config file
     * @param xmlConfigFile passed to m_XMLConfigFile
     * @param debugMode true: on, false: off (faster, but unsafe)
    ADIOS( const std::string xmlConfigFile, const bool debugMode = false );
     * @brief Parallel constructor for XML config file and MPI
     * @param xmlConfigFile passed to m_XMLConfigFile
     * @param mpiComm MPI communicator ...const to be discussed
     * @param debugMode true: on, false: off (faster, but unsafe)
    ADIOS( const std::string xmlConfigFile, const MPI_Comm mpiComm, const bool debugMode = false );
wfg's avatar
wfg committed
     * @brief Parallel MPI communicator without XML config file
     * @param mpiComm MPI communicator passed to m_MPIComm*
     * @param debugMode true: on, false: off (faster)
    ADIOS( const MPI_Comm mpiComm, const bool debugMode = false );
wfg's avatar
wfg committed
    ~ADIOS( ); ///< virtual destructor overriden by children's own destructors
wfg's avatar
wfg committed
    /**
     * @brief Open or Append to an output file
     * @param groupName should match an existing group from XML file or created through CreateGroup
     * @param fileName associated file or stream
wfg's avatar
wfg committed
     * @param accessMode "w": write, "a": append, need more info on this
     */
    void Open( const std::string groupName, const std::string fileName, const std::string accessMode = "w" );
wfg's avatar
wfg committed
    /**
     * Submits a data element values for writing and associates it with the given variableName
     * @param groupName name of group that owns the variable
wfg's avatar
wfg committed
     * @param variableName name of existing scalar or vector variable in the XML file or created with CreateVariable
     * @param values pointer to the variable values passed from the user application, use dynamic_cast to check that pointer is of the same value type
     */
    void Write( const std::string groupName, const std::string variableName, const void* values );
wfg's avatar
wfg committed
    /**
     * Close a particular group, group will be out of scope and destroyed
     * @param groupName group to be closed
     */
    void Close( const std::string groupName );

    /**
     * @brief Dumps groups information to a file stream or standard output.
     * Note that either the user closes this fileStream or it's closed at the end.
     * @param logStream either std::cout standard output, or a std::ofstream file
     */
    void MonitorGroups( std::ostream& logStream ) const;
    std::string m_XMLConfigFile; ///< XML File to be read containing configuration information
wfg's avatar
wfg committed
    std::string m_HostLanguage = "C++"; ///< Supported languages: C, C++, Fortran, Python, etc.
    bool m_DebugMode = false; ///< if true will do more checks, exceptions, warnings, expect slower code
     * @brief List of groups defined from either ADIOS XML configuration file or the CreateGroup function.
     *     Key: std::string unique group name
     *     Value: SGroup struct in SGroup.h
    std::map< std::string, CGroup > m_Groups;
    std::map< std::string, std::unique_ptr<CTransform> > m_Transforms;

    /**
     * @brief Maximum buffer size in ADIOS write() operation. From buffer max - size - MB in XML file
     * Note, that if there are two ADIOS outputs going on at the same time,
     * ADIOS will allocate two separate buffers each with the specified maximum limit.
wfg's avatar
wfg committed
     * Default = 0 means there is no limit
wfg's avatar
wfg committed
    unsigned int MaxBufferSizeInMB = 0;
     * Checks for group existence in m_Groups, if failed throws std::invalid_argument exception
     * @param groupName to be checked
     * @param hint adds information to thrown exception
    void CheckGroup( const std::string groupName, const std::string hint );