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 | |
---|
3 | import numpy |
---|
4 | import pyoasis |
---|
5 | from pyoasis import OASIS |
---|
6 | from mpi4py import MPI |
---|
7 | |
---|
8 | comm = MPI.COMM_WORLD |
---|
9 | |
---|
10 | component_name = "sender-apple" |
---|
11 | |
---|
12 | comp = pyoasis.Component(component_name, True, comm) |
---|
13 | print(comp) |
---|
14 | |
---|
15 | local_comm_rank = comp.localcomm.rank |
---|
16 | local_comm_size = comp.localcomm.size |
---|
17 | |
---|
18 | icpl = 1 |
---|
19 | if local_comm_size > 3: |
---|
20 | if local_comm_rank >= local_comm_size - 2: |
---|
21 | icpl = 0 |
---|
22 | |
---|
23 | couplcomm = comp.localcomm.Split(icpl, local_comm_rank) |
---|
24 | if icpl == 0: |
---|
25 | couplcomm = MPI.COMM_NULL |
---|
26 | |
---|
27 | comp.set_couplcomm(couplcomm) |
---|
28 | |
---|
29 | if icpl == 1: |
---|
30 | |
---|
31 | n_points = 16 |
---|
32 | |
---|
33 | comm_rank = comp.couplcomm.rank |
---|
34 | comm_size = comp.couplcomm.size |
---|
35 | |
---|
36 | local_size = int(n_points/comm_size) |
---|
37 | offset = comm_rank*local_size |
---|
38 | if comm_rank == comm_size - 1: |
---|
39 | local_size = n_points - offset |
---|
40 | |
---|
41 | partition = pyoasis.ApplePartition(offset, local_size) |
---|
42 | print(partition) |
---|
43 | |
---|
44 | variable = pyoasis.Var("FSENDOCN", partition, OASIS.OUT) |
---|
45 | print(variable) |
---|
46 | |
---|
47 | comp.enddef() |
---|
48 | |
---|
49 | if icpl == 1: |
---|
50 | |
---|
51 | date = int(0) |
---|
52 | |
---|
53 | field = pyoasis.asarray(numpy.zeros(local_size)) |
---|
54 | |
---|
55 | for i in range(local_size): |
---|
56 | field[i] = offset + i |
---|
57 | |
---|
58 | print("Sent data: "+str(field)) |
---|
59 | |
---|
60 | variable.put(date, field) |
---|
61 | |
---|
62 | del comp |
---|
Note: See
TracBrowser
for help on using the repository browser.