source: CPL/oasis3-mct/branches/OASIS3-MCT_5.0_branch/pyoasis/examples/2-apple/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: 716 bytes
Line 
1#!/usr/bin/env python3
2
3import numpy
4import pyoasis
5from pyoasis import OASIS
6from mpi4py import MPI
7
8component_name = "receiver"
9
10commworld = MPI.COMM_WORLD.Split(1)
11comp = pyoasis.Component(component_name, communicator = commworld)
12print(comp)
13
14n_points = 1600
15
16partition = pyoasis.SerialPartition(n_points)
17print(partition)
18
19variable = pyoasis.Var("FRECVATM", partition, OASIS.IN)
20print(variable)
21
22comp.enddef()
23
24date = int(0)
25field = pyoasis.asarray(numpy.zeros(n_points))
26
27variable.get(date, field)
28
29expected_field = pyoasis.asarray(numpy.arange(n_points, dtype=numpy.float64))
30epsilon = 1e-8
31error = numpy.abs(field - expected_field).sum()
32if error < epsilon:
33    print("Data received successfully")
34
35del comp
Note: See TracBrowser for help on using the repository browser.