source: CONFIG_DEVT/IPSLCM6.5_work_ENSEMBLES/oasis3-mct/pyoasis/examples/7-multiple-puts/python/receiver_two.py @ 5725

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.5 KB
Line 
1#!/usr/bin/env python3
2
3import pyoasis
4from pyoasis import OASIS
5import numpy as np
6
7comp = pyoasis.Component("receiver_two")
8print(comp)
9
10n_points = 1
11partition = pyoasis.SerialPartition(n_points)
12
13var_1 = pyoasis.Var("FRECVICE_1", partition, OASIS.IN)
14print("Recv_two ", var_1)
15
16var_2 = pyoasis.Var("FRECVICE_2", partition, OASIS.IN)
17print("Recv_two ", var_2)
18
19comp.enddef()
20
21inter_two = comp.get_intercomm("sender-serial")
22print("Recv_two inter_two: rank = {} of {}".format(inter_two.rank,
23      inter_two.size))
24
25field = pyoasis.asarray(np.zeros(n_points, dtype=np.float64))
26
27print("Recv_two: coupling frequencies for {} = ".format(var_1.name),
28      var_1.cpl_freqs)
29print("Recv_two: coupling frequencies for {} = ".format(var_2.name),
30      var_2.cpl_freqs)
31
32for date in range(43200):
33    if any([date % freq == 0 for freq in var_1.cpl_freqs]):
34        var_1.get(date, field)
35        if abs((field - date).sum()) < 1.e-8:
36            print("Recv_two: field 1 received successfully at time {}".format(date))
37        else:
38            print("Warning: Recv_two at time {} got {} instead of {}".format(date,
39                  field[0], date))
40
41    if any([date % freq == 0 for freq in var_2.cpl_freqs]):
42        var_2.get(date, field)
43        if np.abs(field + date).sum() < 1.e-8:
44            print("Recv_two: field 2 received successfully at time {}".format(date))
45        else:
46            print("Warning: Recv_two at time {} got {} instead of {}".format(date,
47                  field[0], date))
48
49del comp
Note: See TracBrowser for help on using the repository browser.