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:
890 bytes
|
Line | |
---|
1 | #!/usr/bin/env python3 |
---|
2 | |
---|
3 | import pyoasis |
---|
4 | from pyoasis import OASIS |
---|
5 | import numpy |
---|
6 | from mpi4py import MPI |
---|
7 | |
---|
8 | comm = MPI.COMM_WORLD |
---|
9 | |
---|
10 | component_name = "receiver" |
---|
11 | |
---|
12 | comp = pyoasis.Component(component_name, True, comm) |
---|
13 | print(comp) |
---|
14 | |
---|
15 | comm_rank = comp.localcomm.rank |
---|
16 | comm_size = comp.localcomm.size |
---|
17 | |
---|
18 | n_points = 16 |
---|
19 | extent = int(n_points/comm_size) |
---|
20 | offset = comm_rank*extent |
---|
21 | |
---|
22 | offsets = [offset] |
---|
23 | extents = [extent] |
---|
24 | |
---|
25 | partition = pyoasis.OrangePartition(offsets, extents) |
---|
26 | print(partition) |
---|
27 | |
---|
28 | variable = pyoasis.Var("FRECVATM", partition, OASIS.IN) |
---|
29 | print(variable) |
---|
30 | |
---|
31 | comp.enddef() |
---|
32 | |
---|
33 | date = int(0) |
---|
34 | field = pyoasis.asarray(numpy.zeros(extent)) |
---|
35 | |
---|
36 | variable.get(date, field) |
---|
37 | |
---|
38 | expected_field = pyoasis.asarray(numpy.zeros(extent)) |
---|
39 | for i in range(extent): |
---|
40 | expected_field[i] = offset + i |
---|
41 | |
---|
42 | epsilon = 1e-8 |
---|
43 | error = numpy.abs(field-expected_field).sum() |
---|
44 | if error < epsilon: |
---|
45 | print("Data received successfully") |
---|
46 | |
---|
47 | del comp |
---|
Note: See
TracBrowser
for help on using the repository browser.