Adjust the save_mat() function for compatibility with MPI.