From 07f818beadf96b4341f9eaff2c5f3d3efc89532a Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Thu, 7 Jan 2016 12:02:12 +0000 Subject: [PATCH] Added MPI version string to the greeting message. --- src/version.c | 29 ++++++++++++++++++++++++++++- src/version.h.in | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/version.c b/src/version.c index e49d0cda90..f441cd0a9c 100644 --- a/src/version.c +++ b/src/version.c @@ -18,6 +18,14 @@ * ******************************************************************************/ +/* Config parameters. */ +#include "../config.h" + +/* MPI headers. */ +#ifdef WITH_MPI +#include <mpi.h> +#endif + /* Some standard headers. */ #include <stdio.h> #include <string.h> @@ -122,6 +130,21 @@ const char *compiler_version(void) { return version; } + +const char *mpi_version(void) { + static char version[256] = {0}; +#ifdef WITH_MPI + static char lib_version[MPI_MAX_LIBRARY_VERSION_STRING] = {0}; + int len, std_version, std_subversion; + MPI_Get_library_lib_version(version, &len); + MPI_Get_version(&std_version, &std_subversion); + sprintf("%s (standard v %i.%i)", lib_version, std_version, std_subversion); +#else + sprintf(version, "Code was not compiled with MPI support"); +#endif + return version; +} + /** * @brief Prints a greeting message to the standard output containing code * version and revision number @@ -139,5 +162,9 @@ void greetings(void) { printf(" Version : %s\n", package_version()); printf(" Revision: %s, Branch: %s\n", git_revision(), git_branch()); printf(" Webpage : www.swiftsim.com\n"); - printf(" Compiler: %s, Version: %s\n\n", compiler_name(), compiler_version()); + printf(" Compiler: %s, Version: %s\n", compiler_name(), compiler_version()); +#ifdef WITH_MPI + printf(" MPI library: %s\n", mpi_version()); +#endif + printf("\n"); } diff --git a/src/version.h.in b/src/version.h.in index d29ab6d437..3f105751ce 100644 --- a/src/version.h.in +++ b/src/version.h.in @@ -35,6 +35,7 @@ const char* git_revision(void); const char* git_branch(void); const char* compiler_name(void); const char* compiler_version(void); +const char* mpi_version(void); void greetings(void); #endif /* SWIFT_VERSION_H */ -- GitLab