For convergence testing, compute
diffnorm = 0;
for (i,j)
diffnorm += (xnew[i][j] - x[i][j]) * (xnew[i][j] - x[i][j]);
diffnorm = sqrt(diffnorm);
Use MPI_Allreduce for this. (Why not use MPI_Reduce?) Write out diffnorm and the iteration
count at each iteration. When diffnorm is less than some tolerance, consider the iteration converged.