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')
if rank is 0:
    gather = np.zeros(4, dtype='int')
    comm.Gather([data,MPI.INT], [gather, MPI.INT], root=0)
    print(rank, gather)
else:
    comm.Gather([data,MPI.INT], None, root=0)


