diff --git a/docs/man-openmpi/man3/MPI_Comm_get_name.3.rst b/docs/man-openmpi/man3/MPI_Comm_get_name.3.rst index 6b3cd0cec8a..9e9336fa9eb 100644 --- a/docs/man-openmpi/man3/MPI_Comm_get_name.3.rst +++ b/docs/man-openmpi/man3/MPI_Comm_get_name.3.rst @@ -37,7 +37,8 @@ occurs, :ref:`MPI_Comm_get_name` will return an empty string (all spaces in Fortran, "" in C). The three predefined communicators will have predefined names associated with them. Thus, the names of MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT will have the default -of MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT. The fact that the +of MPI_COMM_WORLD, MPI_COMM_SELF, and MPI_COMM_PARENT (if not MPI_COMM_NULL). +Passing MPI_COMM_NULL as ``comm`` will return the string MPI_COMM_NULL. The fact that the system may have chosen to give a default name to a communicator does not prevent the user from setting a name on the same communicator; doing this removes the old name and assigns the new one. diff --git a/ompi/mpi/c/comm_get_name.c.in b/ompi/mpi/c/comm_get_name.c.in index f0714830f27..a33e4989bf3 100644 --- a/ompi/mpi/c/comm_get_name.c.in +++ b/ompi/mpi/c/comm_get_name.c.in @@ -14,6 +14,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2024 Triad National Security, LLC. All rights * reserved. + * Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserverd. * $COPYRIGHT$ * * Additional copyrights may follow @@ -44,7 +45,9 @@ PROTOTYPE ERROR_CLASS comm_get_name(COMM comm, STRING_OUT name, INT_OUT length) if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if ( ompi_comm_invalid ( comm ) ) + /* Note that MPI 4.1. explicitely allows to invoke comm_get_name + on MPI_COMM_NULL */ + if (ompi_comm_invalid(comm) && MPI_COMM_NULL != comm) return OMPI_ERRHANDLER_INVOKE ( MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME);