1# 2# Distributed under the OSI-approved Apache License, Version 2.0. See 3# accompanying file Copyright.txt for details. 4# 5# helloDataManReader.py 6# 7# Created on: Sept 5, 2019 8# Author: Jason Wang <wangr1@ornl.gov> 9# 10 11from mpi4py import MPI 12import numpy as np 13import adios2 14 15comm = MPI.COMM_WORLD 16rank = comm.Get_rank() 17size = comm.Get_size() 18 19adios = adios2.ADIOS(comm) 20dataManIO = adios.DeclareIO("whatever") 21dataManIO.SetEngine("DataMan") 22dataManIO.SetParameters({"IPAddress": "127.0.0.1", 23 "Port": "12306", 24 "Timeout": "5"}) 25 26dataManReader = dataManIO.Open('HelloDataMan', adios2.Mode.Read, comm) 27 28while True: 29 stepStatus = dataManReader.BeginStep() 30 if stepStatus == adios2.StepStatus.OK: 31 var = dataManIO.InquireVariable("FloatArray") 32 shape = var.Shape() 33 floatArray = np.zeros(np.prod(shape), dtype=np.float32) 34 dataManReader.Get(var, floatArray, adios2.Mode.Sync) 35 currentStep = dataManReader.CurrentStep() 36 dataManReader.EndStep() 37 print("Step", currentStep, floatArray) 38 elif stepStatus == adios2.StepStatus.EndOfStream: 39 print("End of stream") 40 break 41 42dataManReader.Close() 43