from mpi4py import MPI import numpy as np comm = MPI.COMM_WORLD rank = comm.Get_rank() if rank == 0: data = np.arange(10, dtype=int) print(f'data to be broadcasted: {data}') else: data = np.empty(10, dtype=int) comm.Bcast(data, root=0) # check all got the data: print(f'rank {rank} got {data}')