diff --git a/src/version.c b/src/version.c index e49d0cda901e145132615296a37a8054fe0b3ccc..f441cd0a9cbd49301753151382efb3e2643a55db 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 d29ab6d43784c0f64b37a9c0d1a99781c82770bd..3f105751ce5441ca6bce129bcca368a899c90496 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 */