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