source: CPL/oasis3-mct/branches/OASIS3-MCT_5.0_branch/pyoasis/examples/4-orange/python/receiver.py @ 6331

Last change on this file since 6331 was 6331, checked in by aclsce, 17 months ago

Moved oasis-mct_5.0 in oasis3-mct/branches directory.

File size: 659 bytes
Line 
1#!/usr/bin/env python3
2
3import pyoasis
4from pyoasis import OASIS
5import numpy
6
7from mpi4py import MPI
8
9
10comm = MPI.COMM_WORLD
11
12component_name = "receiver"
13
14comp = pyoasis.Component(component_name, True, comm)
15print(comp)
16
17n_points = 16
18
19partition = pyoasis.SerialPartition(n_points)
20print(partition)
21
22variable = pyoasis.Var("FRECVATM", partition, OASIS.IN)
23print(variable)
24
25comp.enddef()
26
27date = int(0)
28field = pyoasis.asarray(numpy.zeros(n_points))
29
30variable.get(date, field)
31
32expected_field = pyoasis.asarray(range(n_points))
33epsilon = 1e-8
34error = numpy.abs(field-expected_field).sum()
35if error < epsilon:
36    print("Data received successfully")
37
38del comp
Note: See TracBrowser for help on using the repository browser.