Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / gmxlib / copyrite.cpp
index 9ac9e6565c37dcdab623c735ae32360a6004dc53..fe7045a22e5881c53800a34b3656a48024c36cd0 100644 (file)
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-#include "copyrite.h"
+#include "gmxpre.h"
+
+#include "gromacs/legacyheaders/copyrite.h"
 
-#ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef HAVE_LIBMKL
 #include <mkl.h>
 #endif
-
+#ifdef HAVE_EXTRAE
+#include <extrae_user_events.h>
+#endif
 #include <boost/version.hpp>
 
 /* This file is completely threadsafe - keep it that way! */
 
-#include "gromacs/legacyheaders/macros.h"
-#include "gromacs/random/random.h"
-#include "gromacs/legacyheaders/smalloc.h"
-#include "gromacs/legacyheaders/string2.h"
-#include "gromacs/legacyheaders/vec.h"
-
+#include "buildinfo.h"
 #include "gromacs/fft/fft.h"
-#include "gromacs/fileio/futil.h"
 #include "gromacs/fileio/strdb.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/random/random.h"
+#include "gromacs/utility/baseversion.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/futil.h"
 #include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/programinfo.h"
-
-#include "buildinfo.h"
+#include "gromacs/utility/programcontext.h"
+#include "gromacs/utility/smalloc.h"
 
 static gmx_bool be_cool(void)
 {
@@ -94,7 +95,7 @@ static void pukeit(const char *db, const char *defstring, char *retstring,
     {
         nhlp = fget_lines(fp, &help);
         /* for libraries we can use the low-level close routines */
-        ffclose(fp);
+        gmx_ffclose(fp);
         rng    = gmx_rng_init(gmx_rng_make_seed());
         *cqnum = static_cast<int>(nhlp*gmx_rng_uniform_real(rng));
         gmx_rng_destroy(rng);
@@ -556,7 +557,17 @@ void please_cite(FILE *fp, const char *key)
           "C. Kutzner, H. Grubmuller, B. L. de Groot, and U. Zachariae",
           "Computational Electrophysiology: The Molecular Dynamics of Ion Channel Permeation and Selectivity in Atomistic Detail",
           "Biophys. J.",
-          101, 2011, "809-817"}
+          101, 2011, "809-817"},
+        { "Lundborg2014",
+          "M. Lundborg, R. Apostolov, D. Spangberg, A. Gardenas, D. van der Spoel and E. Lindahl",
+          "An efficient and extensible format, library, and API for binary trajectory data from molecular simulations",
+          "J. Comput. Chem.",
+          35, 2014, "260-269"},
+        { "Goga2012",
+          "N. Goga and A. J. Rzepiela and A. H. de Vries and S. J. Marrink and H. J. C. Berendsen",
+          "Efficient Algorithms for Langevin and DPD Dynamics",
+          "J. Chem. Theory Comput.",
+          8, 2012, "3637--3649"}
     };
 #define NSTR (int)asize(citedb)
 
@@ -596,34 +607,30 @@ void please_cite(FILE *fp, const char *key)
     fflush(fp);
 }
 
-#ifdef GMX_GIT_VERSION_INFO
-/* Version information generated at compile time. */
-#include "gromacs/utility/gitversion.h"
-#else
-/* Fall back to statically defined version. */
-static const char _gmx_ver_string[] = "VERSION " VERSION;
-#endif
-
 const char *GromacsVersion()
 {
-    return _gmx_ver_string;
+    return gmx_version();
 }
 
 const char *ShortProgram(void)
 {
+    const char *programName = NULL;
+
     try
     {
         // TODO: Use the display name once it doesn't break anything.
-        return gmx::ProgramInfo::getInstance().programName().c_str();
+        programName = gmx::getProgramContext().programName();
     }
     GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
+
+    return programName;
 }
 
 const char *Program(void)
 {
     try
     {
-        return gmx::ProgramInfo::getInstance().fullBinaryPath().c_str();
+        return gmx::getProgramContext().fullBinaryPath();
     }
     GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
 }
@@ -633,18 +640,17 @@ extern void gmx_print_version_info_gpu(FILE *fp);
 
 static void gmx_print_version_info(FILE *fp)
 {
-    fprintf(fp, "Gromacs version:    %s\n", _gmx_ver_string);
-#ifdef GMX_GIT_VERSION_INFO
-    fprintf(fp, "GIT SHA1 hash:      %s\n", _gmx_full_git_hash);
-    /* Only print out the branch information if present.
-     * The generating script checks whether the branch point actually
-     * coincides with the hash reported above, and produces an empty string
-     * in such cases. */
-    if (_gmx_central_base_hash[0] != 0)
+    fprintf(fp, "Gromacs version:    %s\n", gmx_version());
+    const char *const git_hash = gmx_version_git_full_hash();
+    if (git_hash[0] != '\0')
     {
-        fprintf(fp, "Branched from:      %s\n", _gmx_central_base_hash);
+        fprintf(fp, "GIT SHA1 hash:      %s\n", git_hash);
+    }
+    const char *const base_hash = gmx_version_git_central_base_hash();
+    if (base_hash[0] != '\0')
+    {
+        fprintf(fp, "Branched from:      %s\n", base_hash);
     }
-#endif
 
 #ifdef GMX_DOUBLE
     fprintf(fp, "Precision:          double\n");
@@ -674,7 +680,11 @@ static void gmx_print_version_info(FILE *fp)
 #define gmx_stringify2(x) #x
 #define gmx_stringify(x) gmx_stringify2(x)
     fprintf(fp, "invsqrt routine:    %s\n", gmx_stringify(gmx_invsqrt(x)));
-    fprintf(fp, "CPU acceleration:   %s\n", GMX_CPU_ACCELERATION_STRING);
+#ifndef __MIC__
+    fprintf(fp, "SIMD instructions:  %s\n", GMX_SIMD_STRING);
+#else
+    fprintf(fp, "SIMD instructions:  %s\n", "Intel MIC");
+#endif
 
     fprintf(fp, "FFT library:        %s\n", gmx_fft_get_version_info());
 #ifdef HAVE_RDTSCP
@@ -692,6 +702,14 @@ static void gmx_print_version_info(FILE *fp)
 #else
     fprintf(fp, "TNG support:        disabled\n");
 #endif
+#ifdef HAVE_EXTRAE
+    unsigned major, minor, revision;
+    Extrae_get_version(&major, &minor, &revision);
+    fprintf(fp, "Tracing support:    enabled. Using Extrae-%d.%d.%d\n", major, minor, revision);
+#else
+    fprintf(fp, "Tracing support:    disabled\n");
+#endif
+
 
     fprintf(fp, "Built on:           %s\n", BUILD_TIME);
     fprintf(fp, "Built by:           %s\n", BUILD_USER);
@@ -726,6 +744,18 @@ static void gmx_print_version_info(FILE *fp)
 #endif
 }
 
+#ifdef GMX_DOUBLE
+void gmx_is_double_precision()
+{
+    /* allow precision detection */
+}
+#else
+void gmx_is_single_precision()
+{
+    /* allow precision detection */
+}
+#endif
+
 namespace gmx
 {
 
@@ -735,12 +765,14 @@ BinaryInformationSettings::BinaryInformationSettings()
 {
 }
 
-void printBinaryInformation(FILE *fp, const ProgramInfo &programInfo)
+void printBinaryInformation(FILE                          *fp,
+                            const ProgramContextInterface &programContext)
 {
-    printBinaryInformation(fp, programInfo, BinaryInformationSettings());
+    printBinaryInformation(fp, programContext, BinaryInformationSettings());
 }
 
-void printBinaryInformation(FILE *fp, const ProgramInfo &programInfo,
+void printBinaryInformation(FILE                            *fp,
+                            const ProgramContextInterface   &programContext,
                             const BinaryInformationSettings &settings)
 {
     const char *prefix          = settings.prefix_;
@@ -749,7 +781,7 @@ void printBinaryInformation(FILE *fp, const ProgramInfo &programInfo,
 #ifdef GMX_DOUBLE
     precisionString = " (double precision)";
 #endif
-    const std::string &name = programInfo.displayName();
+    const char *const name = programContext.displayName();
     if (settings.bGeneratedByHeader_)
     {
         fprintf(fp, "%sCreated by:%s\n", prefix, suffix);
@@ -766,18 +798,30 @@ void printBinaryInformation(FILE *fp, const ProgramInfo &programInfo,
         // TODO: It would be nice to know here whether we are really running a
         // Gromacs binary or some other binary that is calling Gromacs; we
         // could then print "%s is part of GROMACS" or some alternative text.
-        fprintf(fp, "%sGROMACS:    %s, %s%s%s\n", prefix, name.c_str(),
-                GromacsVersion(), precisionString, suffix);
+        fprintf(fp, "%sGROMACS:    %s, %s%s%s\n", prefix, name,
+                gmx_version(), precisionString, suffix);
         fprintf(fp, "\n");
         printCopyright(fp);
         fprintf(fp, "\n");
     }
-    fprintf(fp, "%sGROMACS:    %s, %s%s%s\n", prefix, name.c_str(),
-            GromacsVersion(), precisionString, suffix);
-    fprintf(fp, "%sExecutable: %s%s\n", prefix,
-            programInfo.fullBinaryPath().c_str(), suffix);
-    fprintf(fp, "%sCommand line:%s\n%s  %s%s\n",
-            prefix, suffix, prefix, programInfo.commandLine().c_str(), suffix);
+    fprintf(fp, "%sGROMACS:      %s, %s%s%s\n", prefix, name,
+            gmx_version(), precisionString, suffix);
+    const char *const binaryPath = programContext.fullBinaryPath();
+    if (binaryPath != NULL && binaryPath[0] != '\0')
+    {
+        fprintf(fp, "%sExecutable:   %s%s\n", prefix, binaryPath, suffix);
+    }
+    const char *const libraryPath = programContext.defaultLibraryDataPath();
+    if (libraryPath != NULL && libraryPath[0] != '\0')
+    {
+        fprintf(fp, "%sLibrary dir:  %s%s\n", prefix, libraryPath, suffix);
+    }
+    const char *const commandLine = programContext.commandLine();
+    if (commandLine != NULL && commandLine[0] != '\0')
+    {
+        fprintf(fp, "%sCommand line:%s\n%s  %s%s\n",
+                prefix, suffix, prefix, commandLine, suffix);
+    }
     if (settings.bExtendedInfo_)
     {
         GMX_RELEASE_ASSERT(prefix[0] == '\0' && suffix[0] == '\0',