[5725] | 1 | #!/usr/bin/env python3 |
---|
| 2 | |
---|
| 3 | import pyoasis |
---|
| 4 | from pyoasis import OASIS |
---|
| 5 | import numpy as np |
---|
| 6 | |
---|
| 7 | comp = pyoasis.Component("receiver_two") |
---|
| 8 | print(comp) |
---|
| 9 | |
---|
| 10 | n_points = 1 |
---|
| 11 | partition = pyoasis.SerialPartition(n_points) |
---|
| 12 | |
---|
| 13 | var_1 = pyoasis.Var("FRECVICE_1", partition, OASIS.IN) |
---|
| 14 | print("Recv_two ", var_1) |
---|
| 15 | |
---|
| 16 | var_2 = pyoasis.Var("FRECVICE_2", partition, OASIS.IN) |
---|
| 17 | print("Recv_two ", var_2) |
---|
| 18 | |
---|
| 19 | comp.enddef() |
---|
| 20 | |
---|
| 21 | inter_two = comp.get_intercomm("sender-serial") |
---|
| 22 | print("Recv_two inter_two: rank = {} of {}".format(inter_two.rank, |
---|
| 23 | inter_two.size)) |
---|
| 24 | |
---|
| 25 | field = pyoasis.asarray(np.zeros(n_points, dtype=np.float64)) |
---|
| 26 | |
---|
| 27 | print("Recv_two: coupling frequencies for {} = ".format(var_1.name), |
---|
| 28 | var_1.cpl_freqs) |
---|
| 29 | print("Recv_two: coupling frequencies for {} = ".format(var_2.name), |
---|
| 30 | var_2.cpl_freqs) |
---|
| 31 | |
---|
| 32 | for 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 | |
---|
| 49 | del comp |
---|