int MPI_Comm_free(MPI_Comm *comm)
{
MPI_Barrier(*comm);
mark communicator with handle *comm for deallocation;
*comm = MPI_COMM_NULL;
return(MPI_SUCCESS);
}
MPI_Comm_free merely marks a communicator for deallocation and does not necessarily immediately deallocate it. When the communicator is actually deallocated it's context ID is freed. Implementations may keep track of the context IDs which are in use and lower IMPI_max_cid appropriately when freeing a context ID.