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:
1.2 KB
|
Rev | Line | |
---|
[6328] | 1 | #!/usr/bin/env python3 |
---|
| 2 | |
---|
| 3 | import pyoasis |
---|
| 4 | from pyoasis import OASIS |
---|
| 5 | from mpi4py import MPI |
---|
| 6 | import numpy as np |
---|
| 7 | |
---|
| 8 | comm = MPI.COMM_WORLD |
---|
| 9 | |
---|
| 10 | component_name = "sender-box" |
---|
| 11 | |
---|
| 12 | comp = pyoasis.Component(component_name) |
---|
| 13 | comm_rank = comp.localcomm.rank |
---|
| 14 | |
---|
| 15 | print(comp) |
---|
| 16 | print("Sender: rank = {} of {}".format(comm_rank, |
---|
| 17 | comp.localcomm.size)) |
---|
| 18 | |
---|
| 19 | comp.enddef() |
---|
| 20 | |
---|
| 21 | comp_list = ['receiver', component_name, 'xios'] |
---|
| 22 | intra_comm, root_ranks = comp.get_multi_intracomm(comp_list) |
---|
| 23 | |
---|
| 24 | print("Sender: rank({}) intra_comm: rank = {} of {}".format(comm_rank, |
---|
| 25 | intra_comm.rank, |
---|
| 26 | intra_comm.size)) |
---|
| 27 | |
---|
| 28 | if comm_rank == 0: |
---|
| 29 | for comp in root_ranks: |
---|
| 30 | print("Sender: component {} starts at {}".format(comp, root_ranks[comp])) |
---|
| 31 | |
---|
| 32 | il_x = 111 |
---|
| 33 | intra_comm.Send([np.array([il_x],dtype=np.int32), MPI.INT], dest=root_ranks['xios'], tag=0) |
---|
| 34 | print("Sender rank({}) sent il_x = {}".format(comm_rank,il_x)) |
---|
| 35 | |
---|
| 36 | il_x = np.empty(1, dtype=np.int32) |
---|
| 37 | intra_comm.Bcast(il_x, root=root_ranks['xios']) |
---|
| 38 | il_x = il_x[0] |
---|
| 39 | print("Sender rank({}) got broadcasted il_x = {}".format(comm_rank,il_x)) |
---|
Note: See
TracBrowser
for help on using the repository browser.