This function implements the all-reduce operation using MPI. The general syntax for its use is
x = mpiallreduce(y,operation,comm)