Last change
on this file since 5725 was
5725,
checked in by aclsce, 3 years ago
|
Added new oasis3-MCT version to be used to handle ensembles simulations with XIOS.
|
File size:
1.0 KB
|
Rev | Line | |
---|
[5725] | 1 | #!/usr/bin/env python3 |
---|
| 2 | |
---|
| 3 | import pyoasis |
---|
| 4 | from pyoasis import OASIS |
---|
| 5 | import numpy |
---|
| 6 | |
---|
| 7 | from mpi4py import MPI |
---|
| 8 | |
---|
| 9 | comm = MPI.COMM_WORLD |
---|
| 10 | |
---|
| 11 | component_name = "sender-orange" |
---|
| 12 | |
---|
| 13 | comp = pyoasis.Component(component_name, True, comm) |
---|
| 14 | |
---|
| 15 | local_comm_rank = comp.localcomm.rank |
---|
| 16 | local_comm_size = comp.localcomm.size |
---|
| 17 | |
---|
| 18 | coupled = True |
---|
| 19 | if local_comm_size > 3: |
---|
| 20 | if local_comm_rank >= local_comm_size - 2: |
---|
| 21 | coupled = False |
---|
| 22 | |
---|
| 23 | print(comp, flush=True) |
---|
| 24 | |
---|
| 25 | comp.create_couplcomm(coupled) |
---|
| 26 | |
---|
| 27 | if coupled: |
---|
| 28 | comm_rank = comp.couplcomm.rank |
---|
| 29 | comm_size = comp.couplcomm.size |
---|
| 30 | |
---|
| 31 | n_points = 16 |
---|
| 32 | extent = int(n_points / comm_size) |
---|
| 33 | offset = comm_rank * extent |
---|
| 34 | |
---|
| 35 | offsets = [offset] |
---|
| 36 | extents = [extent] |
---|
| 37 | |
---|
| 38 | partition = pyoasis.OrangePartition(offsets, extents) |
---|
| 39 | print(partition, flush=True) |
---|
| 40 | |
---|
| 41 | variable = pyoasis.Var("FSENDOCN", partition, OASIS.OUT) |
---|
| 42 | print(variable, flush=True) |
---|
| 43 | |
---|
| 44 | comp.enddef() |
---|
| 45 | |
---|
| 46 | if coupled: |
---|
| 47 | date = int(0) |
---|
| 48 | |
---|
| 49 | field = pyoasis.asarray(numpy.zeros(extent)) |
---|
| 50 | for i in range(extent): |
---|
| 51 | field[i] = offset + i |
---|
| 52 | |
---|
| 53 | variable.put(date, field) |
---|
| 54 | |
---|
| 55 | del comp |
---|
Note: See
TracBrowser
for help on using the repository browser.