File: python_transition_from_high.rst

package info (click to toggle)
adios2 2.10.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, 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 (41 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (2)
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....