Skip to content

Commit

Permalink
Merge pull request #3167 from manauref/fixTimeWriterPyExample
Browse files Browse the repository at this point in the history
Fix helloBPTimeWriter Python example.
  • Loading branch information
JasonRuonanWang authored Apr 17, 2022
2 parents 4aa67ed + 857994d commit eee6dff
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/hello/bpTimeWriter/helloBPTimeWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# User data
myArray = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
nx = myArray.size
time = np.array([0.0])

# ADIOS
adios = adios2.ADIOS(comm, adios2.DebugON)
Expand All @@ -27,19 +28,22 @@
bpIO = adios.DeclareIO("BPN2N")

# Variables
bpArray = bpIO.DefineVariable("bpArray", [size * nx], [rank * nx], [nx],
adios2.ConstantDims, myArray)
bpTimeStep = bpIO.DefineVariable("bpTimeStep")
bpArray = bpIO.DefineVariable("bpArray", myArray, [size * nx], [rank * nx],
[nx], adios2.ConstantDims)
bpTimeStep = bpIO.DefineVariable("bpTimeStep", time)

# Engine
bpFileWriter = bpIO.Open("myArray.bp", adios2.OpenModeWrite)
bpFileWriter = bpIO.Open("myArray.bp", adios2.Mode.Write)
# Doesn't work: bpFileWriter = bpIO.Open("myArray.bp", adios2.OpenModeWrite)
# Doesn't work: bpFileWriter = bpIO.Open("myArray.bp", adiosOpenModeWrite,
# MPI.COMM_WORLD)


for t in range(0, 10):
bpFileWriter.BeginStep()
if rank == 0:
bpFileWriter.Put(bpTimeStep, np.array([t]))
time[0] = t
bpFileWriter.Put(bpTimeStep, time)
bpFileWriter.Put(bpArray, myArray)
bpFileWriter.EndStep()

Expand Down

0 comments on commit eee6dff

Please sign in to comment.