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:
933 bytes
|
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 | component_name = "sender-apple" |
---|
9 | |
---|
10 | commworld = MPI.COMM_WORLD.Split(1) |
---|
11 | comp = pyoasis.Component(component_name, communicator = commworld) |
---|
12 | print(comp) |
---|
13 | |
---|
14 | comm_rank = comp.localcomm.rank |
---|
15 | comm_size = comp.localcomm.size |
---|
16 | |
---|
17 | n_points = 1600 |
---|
18 | |
---|
19 | local_size = int(n_points / comm_size) |
---|
20 | offset = comm_rank * local_size |
---|
21 | if comm_rank == comm_size - 1: |
---|
22 | local_size = n_points - offset |
---|
23 | |
---|
24 | partition = pyoasis.ApplePartition(offset, local_size) |
---|
25 | print(partition) |
---|
26 | |
---|
27 | variable = pyoasis.Var("FSENDOCN", partition, OASIS.OUT) |
---|
28 | print(variable) |
---|
29 | |
---|
30 | comp.enddef() |
---|
31 | |
---|
32 | date = int(0) |
---|
33 | |
---|
34 | field = pyoasis.asarray(numpy.arange(start=offset, stop=offset + local_size, |
---|
35 | dtype=numpy.float64)) |
---|
36 | |
---|
37 | print("Sent data: from {} to {}".format(int(field[0]), int(field[-1]))) |
---|
38 | |
---|
39 | variable.put(date, field) |
---|
40 | |
---|
41 | print("Terminating component {}".format(comp.name)) |
---|
42 | del comp |
---|
Note: See
TracBrowser
for help on using the repository browser.