File: python_transition_from_high.rst

package info (click to toggle)
adios2 2.11.0%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 39,984 kB
  • sloc: ansic: 250,306; cpp: 189,875; yacc: 18,929; f90: 15,117; python: 8,047; perl: 7,126; sh: 3,049; lisp: 1,106; xml: 1,011; lex: 948; makefile: 598
file content (41 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (4)
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
36
37
38
39
40
41
**********************************
Transition from old API to new API
**********************************

A python script using the high-level API of 2.9 and earlier needs to be modified to work with 2.10 and later.

- adios2.open() is replaced with adios2.Stream(), and does not have 4th and 5th optional arguments for external xml and IO name.
- the ``for in file`` is replaced with ``for _ in file.steps()`` but it works for both writing (by specifying the number of output steps) and reading (for the number of available steps in a stream/file).

.. code-block:: python

    # OLD API
    import adios2

    # NEW API
    from adios2 import Adios, Stream

    # NEW API: this still works
    import adios2


    # OLD API
    fr = adios2.open(args.instream, "r", mpi.comm_app,"adios2.xml", "SimulationOutput")

    # NEW API
    adios = Adios("adios2.xml", mpi.comm_app)
    io = adios.declare_io("SimulationOutput")
    fr = Stream(io, args.instream, "r", mpi.comm_app)


    # OLD API
    for fr_step in fr:
        fr_step....

    # NEW API 1
    for _ in fr.steps():
        fr....

    # NEW API 2
    for fr_step in fr.steps():
        fr_step....