from mpi4py import MPI
import numpy as np
comm = MPI.COMM_WORLD
size = comm.Get_size()
rank = comm.Get_rank()

data =np.array(rank, dtype='int')
gather = np.zeros(4, dtype='int')
comm.Allgather([data,MPI.INT], [gather, MPI.INT])
print(rank, gather)




