From 497580441d24db1d21564c52c19da149c9add4f6 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 31 May 2005 16:30:34 +0000 Subject: [PATCH] Per MPI-2:3.1, MPI_GET_VERSION can be called before MPI_INIT, so remove the MPI_ERR_INIT_FINALIZE() macro. Also check to see how we invoke the errhandler if an error occurs (i.e., the action depends on whether we're between MPI_INIT and MPI_FINALIZE or not). This commit was SVN r5891. --- src/mpi/c/get_version.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/mpi/c/get_version.c b/src/mpi/c/get_version.c index d5a8045d33..f9bcbf7483 100644 --- a/src/mpi/c/get_version.c +++ b/src/mpi/c/get_version.c @@ -34,17 +34,36 @@ static const char FUNC_NAME[] = "MPI_Get_version"; int MPI_Get_version(int *version, int *subversion) { - if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (NULL == version || NULL == subversion) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, FUNC_NAME); + MPI_Comm null = NULL; + + if (MPI_PARAM_CHECK) { + /* Per MPI-2:3.1, this function can be invoked before + MPI_INIT, so we don't invoke the normal + MPI_ERR_INIT_FINALIZE() macro here */ + + if (NULL == version || NULL == subversion) { + /* Note that we have to check and see if we have + previously called MPI_INIT or not. If so, use the + normal OMPI_ERRHANDLER_INVOKE, because the user may + have changed the default errhandler on MPI_COMM_WORLD. + If we have not invoked MPI_INIT, then just abort + (i.e., use a NULL communicator, which will end up at the + default errhandler, which is abort). */ + + if (ompi_mpi_initialized && !ompi_mpi_finalized) { + return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, + FUNC_NAME); + } else { + return OMPI_ERRHANDLER_INVOKE(null, MPI_ERR_ARG, + FUNC_NAME); + } + } } - } - /* According to the MPI-2 specification */ + /* According to the MPI-2 specification */ - *version = 2; - *subversion = 0; + *version = 2; + *subversion = 0; - return MPI_SUCCESS; + return MPI_SUCCESS; }