1 /* 2 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana 3 * University Research and Technology 4 * Corporation. All rights reserved. 5 * Copyright (c) 2004-2009 The University of Tennessee and The University 6 * of Tennessee Research Foundation. All rights 7 * reserved. 8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 9 * University of Stuttgart. All rights reserved. 10 * Copyright (c) 2004-2005 The Regents of the University of California. 11 * All rights reserved. 12 * Copyright (c) 2015 Research Organization for Information Science 13 * and Technology (RIST). All rights reserved. 14 * Copyright (c) 2015 Intel, Inc. All rights reserved 15 * Copyright (c) 2018 Cisco Systems, Inc. All rights reserved 16 * $COPYRIGHT$ 17 * 18 * Additional copyrights may follow 19 * 20 * $HEADER$ 21 */ 22 #include "ompi_config.h" 23 #include <stdio.h> 24 25 #include "ompi/mpi/c/bindings.h" 26 #include "ompi/runtime/params.h" 27 #include "ompi/communicator/communicator.h" 28 #include "ompi/errhandler/errhandler.h" 29 30 #if OMPI_BUILD_MPI_PROFILING 31 #if OPAL_HAVE_WEAK_SYMBOLS 32 #pragma weak MPI_Get_version = PMPI_Get_version 33 #endif 34 #define MPI_Get_version PMPI_Get_version 35 #endif 36 37 static const char FUNC_NAME[] = "MPI_Get_version"; 38 39 40 int MPI_Get_version(int *version, int *subversion) 41 { 42 OPAL_CR_NOOP_PROGRESS(); 43 44 if (MPI_PARAM_CHECK) { 45 /* Per MPI-2:3.1, this function can be invoked before 46 MPI_INIT, so we don't invoke the normal 47 MPI_ERR_INIT_FINALIZE() macro here */ 48 49 if (NULL == version || NULL == subversion) { 50 /* Note that we have to check and see if we have 51 previously called MPI_INIT or not. If so, use the 52 normal OMPI_ERRHANDLER_INVOKE, because the user may 53 have changed the default errhandler on MPI_COMM_WORLD. 54 If we have not invoked MPI_INIT, then just abort 55 (i.e., use a NULL communicator, which will end up at the 56 default errhandler, which is abort). */ 57 58 int32_t state = ompi_mpi_state; 59 if (state >= OMPI_MPI_STATE_INIT_COMPLETED && 60 state < OMPI_MPI_STATE_FINALIZE_PAST_COMM_SELF_DESTRUCT) { 61 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG, 62 FUNC_NAME); 63 } else { 64 /* We have no MPI object here so call ompi_errhandle_invoke 65 * directly */ 66 return ompi_errhandler_invoke(NULL, NULL, -1, 67 ompi_errcode_get_mpi_code(MPI_ERR_ARG), 68 FUNC_NAME); 69 } 70 } 71 } 72 73 /* According to the MPI-2 specification */ 74 75 *version = MPI_VERSION; 76 *subversion = MPI_SUBVERSION; 77 78 return MPI_SUCCESS; 79 }