From 1c6c0c24ae683f19cc064edf017086bd9a380b9f Mon Sep 17 00:00:00 2001
From: "Peter W. Draper" <p.w.draper@durham.ac.uk>
Date: Mon, 11 Jan 2016 13:22:19 +0000
Subject: [PATCH] Add features to get PLATFORM MPI library name reported

---
 configure.ac  |  5 +++++
 src/version.c | 13 +++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 225796677a..d54d3dc7ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,7 @@ AC_ARG_ENABLE([mpi],
 good_mpi="yes"
 if test "$enable_mpi" = "yes"; then
     AX_MPI([CC="$MPICC" AC_DEFINE(HAVE_MPI, 1, [Define if you have the MPI library.]) ])
+    MPI_LIBRARY="Unknown MPI"
 
     # Various MPI implementations require additional libraries when also using
     # threads. Use mpirun (on PATH) as that seems to be only command with
@@ -83,14 +84,17 @@ if test "$enable_mpi" = "yes"; then
        case "$version" in
          *Intel*MPI*)
             MPI_THREAD_LIBS="-mt_mpi"
+            MPI_LIBRARY="Intel MPI"
             AC_MSG_RESULT([Intel MPI])
          ;;
          *Platform*)
             MPI_THREAD_LIBS="-lmtmpi"
+            MPI_LIBRARY="PLATFORM MPI"
             AC_MSG_RESULT([PLATFORM MPI])
          ;;
          *"Open MPI"*)
             MPI_THREAD_LIBS=""
+            MPI_LIBRARY="Open MPI"
             AC_MSG_RESULT([Open MPI])
             #  OpenMPI should be 1.8.6 or later, if not complain.
             #  Version is last word on first line of -version output.
@@ -109,6 +113,7 @@ if test "$enable_mpi" = "yes"; then
        esac
        AC_SUBST([MPI_THREAD_LIBS])
     fi
+    AC_DEFINE_UNQUOTED([SWIFT_MPI_LIBRARY], ["$MPI_LIBRARY"], [The MPI library name, if known.])
 fi
 AM_CONDITIONAL([HAVEMPI],[test $enable_mpi = "yes"])
 
diff --git a/src/version.c b/src/version.c
index c351b18f06..7c60767e4d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -140,21 +140,26 @@ const char *compiler_version(void) {
 const char *mpi_version(void) {
   static char version[256] = {0};
 #ifdef WITH_MPI
-  int len, std_version, std_subversion;
-/* Check that the library implements the version string routine */
+  int std_version, std_subversion;
+
+  /* Check that the library implements the version string routine */
 #ifdef MPI_MAX_LIBRARY_VERSION_STRING
   static char lib_version[MPI_MAX_LIBRARY_VERSION_STRING] = {0};
+  int len;
   MPI_Get_library_version(lib_version, &len);
 
-  /* Find first \n and truncate string to this length, get many lines from 
+  /* Find first \n and truncate string to this length, can get many lines from
    * some MPIs (MPICH). */
   char *ptr = strchr(lib_version, '\n');
   if (ptr != NULL) *ptr = '\0';
 
 #else
+  /* Use autoconf guessed value. */
   static char lib_version[256] = {0};
-  sprintf(lib_version, "Unknown library");
+  sprintf(lib_version, SWIFT_MPI_LIBRARY);
 #endif
+
+  /* Numeric version. */
   MPI_Get_version(&std_version, &std_subversion);
   snprintf(version, 256, "%s (implementing MPI standard v %i.%i)", lib_version,
            std_version, std_subversion);
-- 
GitLab