1 | #!/usr/bin/env python3 |
---|
2 | |
---|
3 | import pyoasis |
---|
4 | from pyoasis import OASIS |
---|
5 | from mpi4py import MPI |
---|
6 | |
---|
7 | component_name = "sender-box" |
---|
8 | |
---|
9 | comp = pyoasis.Component(component_name) |
---|
10 | print(comp) |
---|
11 | |
---|
12 | rank = comp.localcomm.rank |
---|
13 | |
---|
14 | global_offsets = [0, 2, 8, 10] |
---|
15 | partition = pyoasis.BoxPartition(global_offsets[rank], 2, 2, 4) |
---|
16 | print(partition) |
---|
17 | |
---|
18 | variable = pyoasis.Var("FSENDOCN", partition, OASIS.OUT) |
---|
19 | print(variable) |
---|
20 | |
---|
21 | variable2 = pyoasis.Var("NOTANAME", partition, OASIS.OUT) |
---|
22 | if variable2.is_active: |
---|
23 | print("{} is active".format(variable2)) |
---|
24 | else: |
---|
25 | print("{} is not active".format(variable2)) |
---|
26 | |
---|
27 | comp.enddef() |
---|
28 | |
---|
29 | intracomm = comp.get_intracomm("receiver") |
---|
30 | intercomm = comp.get_intercomm("receiver") |
---|
31 | |
---|
32 | print("Sender intra_comm: rank = {} of {}".format(intracomm.rank, |
---|
33 | intracomm.size)) |
---|
34 | print("Sender inter_comm: rank = {} of {} Remote size = {}".format(intercomm.rank, |
---|
35 | intercomm.size, |
---|
36 | intercomm.remote_size)) |
---|
37 | |
---|
38 | date = int(0) |
---|
39 | data = [[0, 1, 4, 5], [2, 3, 6, 7], |
---|
40 | [8, 9, 12, 13], [10, 11, 14, 15]] |
---|
41 | field = pyoasis.asarray(data[rank]) |
---|
42 | |
---|
43 | print(variable.put(date, field)) |
---|
44 | |
---|
45 | if rank % 2 == 0: |
---|
46 | del comp |
---|