source: CPL/oasis3-mct_5.0/pyoasis/examples/3-box/python/receiver.py @ 6328

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

First import of oasis3-mct_5.0 (from oasis git server, branch OASIS3-MCT_5.0)

File size: 1.1 KB
Line 
1#!/usr/bin/env python3
2
3import pyoasis
4from pyoasis import OASIS
5import numpy
6from mpi4py import MPI
7
8
9component_name = "receiver"
10
11comp = pyoasis.Component(component_name)
12print(comp)
13
14n_points = 16
15
16partition = pyoasis.SerialPartition(n_points)
17print(partition)
18
19variable = pyoasis.Var("FRECVATM", partition, OASIS.IN)
20print(variable)
21
22comp.enddef()
23
24intracomm = comp.get_intracomm("sender-box")
25intercomm = comp.get_intercomm("sender-box")
26
27print("Receiver intra_comm: rank = {} of {}".format(intracomm.rank,
28                                                    intracomm.size))
29print("Receiver inter_comm: rank = {} of {} Remote size = {}".format(intercomm.rank,
30                                                                     intercomm.size,
31                                                                     intercomm.remote_size))
32
33date = int(0)
34field = pyoasis.asarray(numpy.zeros(n_points))
35
36print(variable.get(date, field))
37
38expected_field = pyoasis.asarray(range(n_points))
39epsilon = 1e-8
40error = numpy.abs(field-expected_field).sum()
41if error < epsilon:
42    print("Data received successfully")
43
44del comp
Note: See TracBrowser for help on using the repository browser.