Commit 70e54994 authored by Podhorszki, Norbert's avatar Podhorszki, Norbert
Browse files

Merge branch 'py_hdf5' into fix_hdf5

parents fb730f0b 7a330620
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ namespace core
Stream::Stream(const std::string &name, const Mode mode, MPI_Comm comm,
               const std::string engineType, const std::string hostLanguage)
: m_Name(name), m_ADIOS(std::make_shared<ADIOS>(comm, DebugON, hostLanguage)),
  m_IO(&m_ADIOS->DeclareIO(name)), m_Mode(mode)
  m_IO(&m_ADIOS->DeclareIO(name)), m_Mode(mode), m_EngineType(engineType)
{
    if (mode == adios2::Mode::Read)
    {
@@ -105,10 +105,12 @@ void Stream::CheckOpen()
{
    if (m_Engine == nullptr)
    {
        m_IO->SetEngine(m_EngineType);
        m_Engine = &m_IO->Open(m_Name, m_Mode);
        if (m_Mode == adios2::Mode::Write)
        {
            m_Engine->BeginStep();
            m_StepStatus = true;
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -108,9 +108,14 @@ private:
    /** mode to open engine at first read/write */
    Mode m_Mode;

    /** Sets engine type to be opened at first read/write */
    std::string m_EngineType = "BPFile";

    /** internal flag to check if getstep was called */
    bool m_FirstStep = true;

    bool m_StepStatus = false;

    template <class T>
    std::vector<T> GetCommon(Variable<T> &variable);

+6 −1
Original line number Diff line number Diff line
@@ -44,13 +44,18 @@ void Stream::Write(const std::string &name, const T *data, const Dims &shape,
    }

    CheckOpen();
    if (!m_StepStatus)
    {
        m_Engine->BeginStep();
        m_StepStatus = true;
    }

    m_Engine->Put(*variable, data, adios2::Mode::Sync);

    if (endStep)
    {
        m_Engine->EndStep();
        m_Engine->BeginStep();
        m_StepStatus = false;
    }
}

+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ if(ADIOS2_HAVE_MPI)
    				SCRIPT TestBPWriteReadTypes.py)
    python_add_test(NAME PythonBPWriteReadHighLevelAPI ${test_parameters} 
    				SCRIPT TestBPWriteTypesHighLevelAPI.py)
    python_add_test(NAME PythonBPWriteReadHighLevelAPI_HDF5 ${test_parameters} 
    				SCRIPT TestBPWriteTypesHighLevelAPI_HDF5.py)
    python_add_test(NAME PythonBPReadMultisteps ${test_parameters} 
    				SCRIPT TestBPReadMultisteps.py)
endif()
+33 −27
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#      Author: William F Godoy godoywf@ornl.gov


import sys
from adios2NPTypes import SmallTestData
from mpi4py import MPI
import numpy as np
@@ -30,7 +31,11 @@ count = [nx]
# Writer
with adios2.open("types_np.bp", "w", comm) as fw:

    if(rank == 0):
    for i in range(0, 5):
        
        data.update(rank, i, size)
        
        if(rank == 0 and i == 0):
            fw.write("tag", "Testing ADIOS2 high-level API")
            fw.write("gvarI8", np.array(data.I8[0]))
            fw.write("gvarI16", np.array(data.I16[0]))
@@ -43,11 +48,8 @@ with adios2.open("types_np.bp", "w", comm) as fw:
            fw.write("gvarR32", np.array(data.R32[0]))
            fw.write("gvarR64", np.array(data.R64[0]))

    for i in range(0, 5):

        print("i: " + str(i))
        print("Write Step: " + str(i) + " rank: " + str(rank))
        fw.write("steps", "Step:" + str(i))

        fw.write("varI8", data.I8, shape, start, count)
        fw.write("varI16", data.I16, shape, start, count)
        fw.write("varI32", data.I32, shape, start, count)
@@ -59,13 +61,20 @@ with adios2.open("types_np.bp", "w", comm) as fw:
        fw.write("varR32", data.R32, shape, start, count)
        fw.write("varR64", data.R64, shape, start, count, endl=True)
        
comm.Barrier()
sys.stdout.flush()

# Reader
data = SmallTestData()

with adios2.open("types_np.bp", "r", comm) as fr:
    
    for fr_step in fr:

        step = fr_step.currentstep()
        print("Step: " + str(step))
        data.update(rank, step, size)
        
        print("Reader Step: " + str(step))

        step_vars = fr_step.availablevariables()

@@ -101,24 +110,21 @@ with adios2.open("types_np.bp", "r", comm) as fr:
            if(inI32[0] != data.I32[0]):
                raise ValueError('gvarI32 read failed')

            if(inU16[0] != data.U16[0]):
                raise ValueError('gvarU16 read failed')

            if(inI64[0] != data.I64[0]):
                raise ValueError('gvarI64 read failed')

            if(inU64[0] != data.U64[0]):
                raise ValueError('gvarU64 read failed')

            if(inI8[0] != data.I8[0]):
                raise ValueError('gvarI8 read failed')

            if(inU8[0] != data.U8[0]):
                raise ValueError('gvarU8 read failed')
            
            if(inU16[0] != data.U16[0]):
                raise ValueError('gvarU16 read failed')

            if(inU32[0] != data.U32[0]):
                raise ValueError('gvarU32 read failed')
            
            if(inU64[0] != data.U64[0]):
                raise ValueError('gvarU64 read failed')

            if(inR32[0] != data.R32[0]):
                raise ValueError('gvarR32 read failed')

Loading