File: dataManReader.py

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 (35 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download | duplicates (3)
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
#
# Distributed under the OSI-approved Apache License, Version 2.0.  See
# accompanying file Copyright.txt for details.
#
# dataManReader.py
#
#  Created on: Sept 5, 2019
#      Author: Jason Wang <wangr1@ornl.gov>
#

from mpi4py import MPI
import numpy as np
from adios2 import Adios, Stream
from adios2.bindings import StepStatus

comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()

adios = Adios(comm)
io = adios.declare_io("whatever")
io.set_engine("DataMan")
io.set_parameters({"IPAddress": "127.0.0.1", "Port": "12306", "Timeout": "5"})

with Stream(io, "HelloDataMan", "r") as stream:
    for _ in stream.steps():
        stepStatus = stream.step_status()
        print(f"Step status = {stepStatus}")
        var = io.inquire_variable("FloatArray")
        shape = var.shape()
        floatArray = stream.read(var)
        currentStep = stream.current_step()
        loopStep = stream.loop_index()
        print("Loop index =", loopStep, "stream step =", currentStep, "data =")
        print(floatArray)