Clean up copyrite.*.
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 31 May 2013 10:42:20 +0000 (13:42 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 24 Jun 2013 13:53:23 +0000 (15:53 +0200)
- Make a few functions static, since they are not used outside the file.
- Move pr_difftime() to nrnb.c and make it static there, since that is
  the only place where it was used.
- Move the logic of producing the FFT library identification from
  copyrite.c to fft_*.c, where it naturally belongs.
- master always has a C++ compiler, so remove the unnecessary
  conditional.
- Clean up the include statements in copyrite.c.

Change-Id: I9a72c014f1d0583adacc657414bc8a758d450b21

src/gromacs/fft/fft.h
src/gromacs/fft/fft_fftpack.c
src/gromacs/fft/fft_fftw3.cpp
src/gromacs/fft/fft_mkl.c
src/gromacs/gmxlib/copyrite.c
src/gromacs/gmxlib/nrnb.c
src/gromacs/legacyheaders/copyrite.h

index bfe41efee1dd5d9670f974ebe95929ee60964fcb..32be1dd048459db744adc3d07766d7bbab1e59d3 100644 (file)
@@ -394,10 +394,15 @@ gmx_fft_transpose_2d   (t_complex *       in_data,
 /*! \brief Cleanup global data of FFT
  *
  *  Any plans are invalid after this function. Should be called
- *  after all plans have been destroyed.s
- * */
+ *  after all plans have been destroyed.
+ */
 void gmx_fft_cleanup();
 
+/*! \brief Return string describing the underlying FFT implementation.
+ *
+ * Used to print out information about the used FFT library where needed.
+ */
+const char *gmx_fft_get_version_info();
 
 #ifdef __cplusplus
 }
index b572dd9d7321a560ac2f0257398bf74de19fe742..5350877e4d426e7dd143474f3d30a80b2abb8e04 100644 (file)
@@ -476,3 +476,8 @@ gmx_fft_destroy(gmx_fft_t      fft)
 void gmx_fft_cleanup()
 {
 }
+
+const char *gmx_fft_get_version_info()
+{
+    return "fftpack (built-in)";
+}
index 461cd19d810788fe49f80efb8519f858f4d39764..5b518f61385ab4dc454ad0e42b272db9435c6c25 100644 (file)
@@ -567,3 +567,12 @@ void gmx_fft_cleanup()
 {
     FFTWPREFIX(cleanup)();
 }
+
+const char *gmx_fft_get_version_info()
+{
+#ifdef GMX_NATIVE_WINDOWS
+    return "fftw3";
+#else
+    return FFTWPREFIX(version);
+#endif
+}
index a0a6b0a789f6870c596de1348cb92aed0dd46659..1ee0c0afa1c1d5ef7f918ae1ffc0f5d8d3cba300 100644 (file)
@@ -618,3 +618,8 @@ void gmx_fft_cleanup()
 {
     mkl_free_buffers();
 }
+
+const char *gmx_fft_get_version_info()
+{
+    return "Intel MKL";
+}
index 14529515449ece8ad0f5a5f8debcea46296d3f53..7c64b5cdc9b91c9fd8ac85f7540250dda69d87e3 100644 (file)
  * And Hey:
  * GROningen Mixture of Alchemy and Childrens' Stories
  */
+#include "copyrite.h"
+
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
 #endif
 
-#ifdef GMX_THREAD_MPI
-#include <thread_mpi.h>
-#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
 
 #ifdef HAVE_LIBMKL
 #include <mkl.h>
 #endif
-#ifdef GMX_FFT_FFTW3
-#include <fftw3.h>
-#endif
 
 /* This file is completely threadsafe - keep it that way! */
 
-#include <string.h>
-#include <ctype.h>
-#include "sysstuff.h"
-#include "smalloc.h"
-#include "string2.h"
-#include "macros.h"
-#include <time.h>
-#include "random.h"
-#include "statutil.h"
-#include "copyrite.h"
-#include "strdb.h"
-#include "futil.h"
-#include "vec.h"
-#include "buildinfo.h"
-#include "gmx_cpuid.h"
+#include "gromacs/legacyheaders/futil.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/random.h"
+#include "gromacs/legacyheaders/smalloc.h"
+#include "gromacs/legacyheaders/statutil.h"
+#include "gromacs/legacyheaders/strdb.h"
+#include "gromacs/legacyheaders/string2.h"
+#include "gromacs/legacyheaders/vec.h"
 
-static void pr_two(FILE *out, int c, int i)
-{
-    if (i < 10)
-    {
-        fprintf(out, "%c0%1d", c, i);
-    }
-    else
-    {
-        fprintf(out, "%c%2d", c, i);
-    }
-}
-
-void pr_difftime(FILE *out, double dt)
-{
-    int        ndays, nhours, nmins, nsecs;
-    gmx_bool   bPrint, bPrinted;
-
-    ndays    = dt/(24*3600);
-    dt       = dt-24*3600*ndays;
-    nhours   = dt/3600;
-    dt       = dt-3600*nhours;
-    nmins    = dt/60;
-    dt       = dt-nmins*60;
-    nsecs    = dt;
-    bPrint   = (ndays > 0);
-    bPrinted = bPrint;
-    if (bPrint)
-    {
-        fprintf(out, "%d", ndays);
-    }
-    bPrint = bPrint || (nhours > 0);
-    if (bPrint)
-    {
-        if (bPrinted)
-        {
-            pr_two(out, 'd', nhours);
-        }
-        else
-        {
-            fprintf(out, "%d", nhours);
-        }
-    }
-    bPrinted = bPrinted || bPrint;
-    bPrint   = bPrint || (nmins > 0);
-    if (bPrint)
-    {
-        if (bPrinted)
-        {
-            pr_two(out, 'h', nmins);
-        }
-        else
-        {
-            fprintf(out, "%d", nmins);
-        }
-    }
-    bPrinted = bPrinted || bPrint;
-    if (bPrinted)
-    {
-        pr_two(out, ':', nsecs);
-    }
-    else
-    {
-        fprintf(out, "%ds", nsecs);
-    }
-    fprintf(out, "\n");
-}
+#include "gromacs/fft/fft.h"
 
+#include "buildinfo.h"
 
-gmx_bool be_cool(void)
+static gmx_bool be_cool(void)
 {
     /* Yes, it is bad to check the environment variable every call,
      * but we dont call this routine often, and it avoids using
@@ -147,7 +76,7 @@ gmx_bool be_cool(void)
 #endif
 }
 
-void space(FILE *out, int n)
+static void space(FILE *out, int n)
 {
     fprintf(out, "%*s", n, "");
 }
@@ -489,7 +418,7 @@ void please_cite(FILE *fp, const char *key)
           "A. Bondi",
           "van der Waals Volumes and Radii",
           "J. Phys. Chem.",
-          68, 1964,"441-451" },
+          68, 1964, "441-451" },
         { "Eisenhaber95",
           "Frank Eisenhaber and Philip Lijnzaad and Patrick Argos and Chris Sander and Michael Scharf",
           "The Double Cube Lattice Method: Efficient Approaches to Numerical Integration of Surface Area and Volume and to Dot Surface Contouring of Molecular Assemblies",
@@ -734,21 +663,7 @@ void gmx_print_version_info(FILE *fp)
     fprintf(fp, "invsqrt routine:    %s\n", gmx_stringify(gmx_invsqrt(x)));
     fprintf(fp, "CPU acceleration:   %s\n", GMX_CPU_ACCELERATION_STRING);
 
-    /* TODO: Would be nicer to wrap this in a gmx_fft_version() call, but
-     * since that is currently in mdlib, can wait for master. */
-#ifdef GMX_FFT_FFTPACK
-    fprintf(fp, "FFT library:        fftpack (built-in)\n");
-#elif defined(GMX_FFT_FFTW3) && defined(GMX_NATIVE_WINDOWS)
-    fprintf(fp, "FFT library:        %s\n", "fftw3");
-#elif defined(GMX_FFT_FFTW3) && defined(GMX_DOUBLE)
-    fprintf(fp, "FFT library:        %s\n", fftw_version);
-#elif defined(GMX_FFT_FFTW3)
-    fprintf(fp, "FFT library:        %s\n", fftwf_version);
-#elif defined(GMX_FFT_MKL)
-    fprintf(fp, "FFT library:        MKL\n");
-#else
-    fprintf(fp, "FFT library:        unknown\n");
-#endif
+    fprintf(fp, "FFT library:        %s\n", gmx_fft_get_version_info());
 #ifdef GMX_LARGEFILES
     fprintf(fp, "Large file support: enabled\n");
 #else
@@ -773,11 +688,8 @@ void gmx_print_version_info(FILE *fp)
     fprintf(fp, "Build CPU features: %s\n", BUILD_CPU_FEATURES);
     fprintf(fp, "C compiler:         %s\n", BUILD_C_COMPILER);
     fprintf(fp, "C compiler flags:   %s\n", BUILD_CFLAGS);
-    if (BUILD_CXX_COMPILER[0] != '\0')
-    {
-        fprintf(fp, "C++ compiler:       %s\n", BUILD_CXX_COMPILER);
-        fprintf(fp, "C++ compiler flags: %s\n", BUILD_CXXFLAGS);
-    }
+    fprintf(fp, "C++ compiler:       %s\n", BUILD_CXX_COMPILER);
+    fprintf(fp, "C++ compiler flags: %s\n", BUILD_CXXFLAGS);
 #ifdef HAVE_LIBMKL
     /* MKL might be used for LAPACK/BLAS even if FFTs use FFTW, so keep it separate */
     fprintf(fp, "Linked with Intel MKL version %d.%d.%d.\n",
index 3a402136edc83b7e0731cd54a666d023d1a1cea5..16b1e9f894c737f92f34a07884a34ad282015af6 100644 (file)
 #include "nrnb.h"
 #include "main.h"
 #include "smalloc.h"
-#include "copyrite.h"
-
-
-
-
 
 typedef struct {
     const char *name;
@@ -189,6 +184,72 @@ static const t_nrnb_data nbdata[eNRNB] = {
     { "Mixed Generalized Born stuff",   10 }
 };
 
+static void pr_two(FILE *out, int c, int i)
+{
+    if (i < 10)
+    {
+        fprintf(out, "%c0%1d", c, i);
+    }
+    else
+    {
+        fprintf(out, "%c%2d", c, i);
+    }
+}
+
+static void pr_difftime(FILE *out, double dt)
+{
+    int        ndays, nhours, nmins, nsecs;
+    gmx_bool   bPrint, bPrinted;
+
+    ndays    = dt/(24*3600);
+    dt       = dt-24*3600*ndays;
+    nhours   = dt/3600;
+    dt       = dt-3600*nhours;
+    nmins    = dt/60;
+    dt       = dt-nmins*60;
+    nsecs    = dt;
+    bPrint   = (ndays > 0);
+    bPrinted = bPrint;
+    if (bPrint)
+    {
+        fprintf(out, "%d", ndays);
+    }
+    bPrint = bPrint || (nhours > 0);
+    if (bPrint)
+    {
+        if (bPrinted)
+        {
+            pr_two(out, 'd', nhours);
+        }
+        else
+        {
+            fprintf(out, "%d", nhours);
+        }
+    }
+    bPrinted = bPrinted || bPrint;
+    bPrint   = bPrint || (nmins > 0);
+    if (bPrint)
+    {
+        if (bPrinted)
+        {
+            pr_two(out, 'h', nmins);
+        }
+        else
+        {
+            fprintf(out, "%d", nmins);
+        }
+    }
+    bPrinted = bPrinted || bPrint;
+    if (bPrinted)
+    {
+        pr_two(out, ':', nsecs);
+    }
+    else
+    {
+        fprintf(out, "%ds", nsecs);
+    }
+    fprintf(out, "\n");
+}
 
 void init_nrnb(t_nrnb *nrnb)
 {
index 914d20c9f2bdf339a3b5777024ae612610f83a98..6389adec74d448a5d639e2bf1c6d7cb48c1f3e9c 100644 (file)
  * And Hey:
  * Gromacs Runs On Most of All Computer Systems
  */
-
 #ifndef _copyrite_h
 #define _copyrite_h
 
-
 #include <stdio.h>
-#include "types/simple.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -50,9 +47,6 @@ const char *GromacsVersion(void);
 void
 gmx_print_version_info(FILE *fp);
 
-void
-pr_difftime(FILE *out, double dt);
-
 void
 CopyRight(FILE *out, const char *szProgram);
 
@@ -71,18 +65,9 @@ bromacs(char *retstring, int retsize);
 void
 cool_quote(char *retstring, int retsize, int *cqnum);
 
-gmx_bool
-be_cool(void);
-/* Return TRUE when the user is COOL, FALSE otherwise */
-
 void
 thanx(FILE *fp);
 
-enum {
-    eCITEGMX, eCITEBATH, eCITESHAKE, eCITESETTLE, eCITESOR,
-    eCITEDISRE, eCITERF, eCITELINCS, eCITENR
-};
-
 void
 please_cite(FILE *fp, const char *key);
 /* Print a message asking to cite something... */