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

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

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

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