Merge branch release-2016
authorMark Abraham <mark.j.abraham@gmail.com>
Sun, 9 Oct 2016 21:46:47 +0000 (23:46 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Sun, 9 Oct 2016 21:52:57 +0000 (23:52 +0200)
Resolutions straightforward apart from the question about the
correctness of the gmx_wham fix in release-2016 branch.

Change-Id: I908a9a6d8f5767da49c3f00495beeec2a4f95ca7

14 files changed:
admin/builds/regressiontests-update.py [new file with mode: 0644]
scripts/xplor2gmx.pl
share/top/oplsaa.ff/aminoacids.rtp
src/gromacs/commandline/cmdlinemodulemanager.cpp
src/gromacs/commandline/cmdlinemodulemanager.h
src/gromacs/domdec/domdec.cpp
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/math/tests/functions.cpp
src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda.cu
src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh
src/gromacs/utility/directoryenumerator.cpp
src/gromacs/utility/directoryenumerator.h
src/programs/legacymodules.cpp
src/programs/mdrun_main.cpp

diff --git a/admin/builds/regressiontests-update.py b/admin/builds/regressiontests-update.py
new file mode 100644 (file)
index 0000000..2ee6d95
--- /dev/null
@@ -0,0 +1,64 @@
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2016, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+import os.path
+
+# TODO when merging this to master, update gcc to 4.8
+build_options = ['gcc-4.7', 'cmake-3.4.3']
+extra_projects = [Project.REGRESSIONTESTS]
+
+def run_build(context, cmake_opts):
+    context.chdir(context.workspace.build_dir)
+    context.run_cmake(cmake_opts)
+    context.build_target(target=None)
+
+    context.chdir(context.workspace.get_project_dir(Project.REGRESSIONTESTS))
+    cmd = ['perl', 'gmxtest.pl', 'all']
+    if cmake_opts['GMX_DOUBLE'] == 'ON':
+        cmd += ['-double']
+    context.run_cmd(cmd, failure_message='Regression tests failed to execute')
+
+def do_build(context):
+    cmake_opts=dict()
+    cmake_opts['CMAKE_BUILD_TYPE'] = 'Reference'
+    context.env.set_env_var('GMX_NO_TERM', '1')
+    context.env.prepend_path_env(os.path.join(context.workspace.build_dir, 'bin'))
+
+    cmake_opts['GMX_DOUBLE'] = 'ON'
+    run_build(context, cmake_opts)
+
+    cmake_opts['GMX_DOUBLE'] = 'OFF'
+    run_build(context, cmake_opts)
+
+    context.workspace.upload_revision(project=Project.REGRESSIONTESTS, file_glob='*reference*')
index 7422551d40f9de34a1f6c07e1b9b58ef83e1d2df..b0e28a04b1a9cb936dd1bc74a58e1e11bc327326 100755 (executable)
@@ -21,7 +21,7 @@ $trans = 1;
 #$res0  = shift;# || die "I need the residue offset\n";
 $pdb   = shift || die "I need the name of the pdb file with correct atom numbers\n";
 $core  = shift || "core.ndx";
-$tbl   = "$ENV{GMXDATA}/gromacs/top/atom_nom.tbl";
+$tbl   = "$ENV{GMXDATA}/top/atom_nom.tbl";
 
 printf "[ distance_restraints ]\n";
 printf "; Read an xplor distance restraint file, and output GROMACS distance restraints.\n";
index 65c01723e901b89767589a794a9671ee3cc3f50b..36bcf15933eba4ae6ae60c6cfd22f706a30d94f1 100644 (file)
@@ -34,7 +34,7 @@
 ;                bond as an improper dihedral
 ;            0 = do not generate such
 ; bonds  angles  dihedrals  impropers all_dihedrals nrexcl HH14 RemoveDih
-     1       1          3          1       1         3      1     0
+     1       1          3          1        1         3      1     0
 
 [ ACE ]
  [ atoms ]
      C     O
     -C     N
  [ impropers ]
-    -C    CA     N     H    improper_Z_N_X_Y 
-    CA    +N     C     O    improper_O_C_X_Y 
+    -C    CA     N     H    improper_Z_N_X_Y
+    CA    +N     C     O    improper_O_C_X_Y
 
 
 [ ARG ]
  [ atoms ]
-     N    opls_238   -0.500     1       
+     N    opls_238   -0.500     1
      H    opls_241    0.300     1
-    CA    opls_224B   0.140     1 
-    HA    opls_140    0.060     1 
-    CB    opls_136   -0.120     2 
-   HB1    opls_140    0.060     2 
-   HB2    opls_140    0.060     2 
-    CG    opls_308   -0.050     3 
-   HG1    opls_140    0.060     3 
-   HG2    opls_140    0.060     3 
-    CD    opls_307    0.190     4 
-   HD1    opls_140    0.060     4 
-   HD2    opls_140    0.060     4 
-    NE    opls_303   -0.700     5 
-    HE    opls_304    0.440     5 
-    CZ    opls_302    0.640    
+    CA    opls_224B   0.140     1
+    HA    opls_140    0.060     1
+    CB    opls_136   -0.120     2
+   HB1    opls_140    0.060     2
+   HB2    opls_140    0.060     2
+    CG    opls_308   -0.050     3
+   HG1    opls_140    0.060     3
+   HG2    opls_140    0.060     3
+    CD    opls_307    0.190     4
+   HD1    opls_140    0.060     4
+   HD2    opls_140    0.060     4
+    NE    opls_303   -0.700     5
+    HE    opls_304    0.440     5
+    CZ    opls_302    0.640     5
    NH1    opls_300   -0.800     6
   HH11    opls_301    0.460     6
   HH12    opls_301    0.460     6
    HD2    opls_140    0.060     4
     NE    opls_749   -0.620     5
     HE    opls_304    0.350     5; guessed charge
-    CZ    opls_752    0.550    6
+    CZ    opls_752    0.550     6
    NH1    opls_750   -0.785     6
-   HH1    opls_301    0.340     6; guessed charge  
+   HH1    opls_301    0.340     6; guessed charge
    NH2    opls_751   -0.785     7
-  HH21    opls_301    0.360     7; guessed charge  
+  HH21    opls_301    0.360     7; guessed charge
   HH22    opls_301    0.360     7; guessed charge
      C    opls_235    0.500     8
      O    opls_236   -0.500     8
     CB    CG
     CG   OD1
     CG   OD2
-     C     O   
-    -C     N 
+     C     O
+    -C     N
  [ dihedrals ] ; override some with residue-specific ones
      N    CA    CB    CG    dih_ASP_chi1_N_C_C_C
     CG    CB    CA     C    dih_ASP_chi1_C_C_C_CO
  [ impropers ]
-    -C    CA     N     H    improper_Z_N_X_Y 
-    CA    +N     C     O    improper_O_C_X_Y 
-    CB   OD1    CG   OD2    improper_O_C_X_Y     
+    -C    CA     N     H    improper_Z_N_X_Y
+    CA    +N     C     O    improper_O_C_X_Y
+    CB   OD1    CG   OD2    improper_O_C_X_Y
 
 [ ASPH ]
  [ atoms ]
-     N    opls_238   -0.500     0  
-     H    opls_241    0.300     0  
-    CA    opls_224B   0.140     1  
-    HA    opls_140    0.060     1  
+     N    opls_238   -0.500     0
+     H    opls_241    0.300     0
+    CA    opls_224B   0.140     1
+    HA    opls_140    0.060     1
     CB    opls_136   -0.120     2
    HB1    opls_140    0.060     2
    HB2    opls_140    0.060     2
      N    CA    CB    CG    dih_GLN_chi1_N_C_C_C
     CG    CB    CA     C    dih_GLN_chi1_C_C_C_CO
     CB    CG    CD   NE2    dih_GLN_chi3_C_C_CO_N
-    CG   CD    OE1  HE1    dih_GLN_chi4_C_C_O_H
+    CG    CD    OE1  HE1    dih_GLN_chi4_C_C_O_H
  [ impropers ]
-    -C    CA     N     H    improper_Z_N_X_Y 
-    CA    +N     C     O    improper_O_C_X_Y 
-    CG   NE2    CD   OE1    improper_O_C_X_Y  
-    CD  HE21   NE2  HE22    improper_Z_N_X_Y        
-    HE1  OE1    CD   NE2    improper_O_C_X_Y  
+    -C    CA     N     H    improper_Z_N_X_Y
+    CA    +N     C     O    improper_O_C_X_Y
+    CG   NE2    CD   OE1    improper_O_C_X_Y
+    CD  HE21   NE2  HE22    improper_Z_N_X_Y
+    HE1  OE1    CD   NE2    improper_O_C_X_Y
 
 
 [ GLU ]
     CG    CB    CA     C    dih_HIS_chi1_C_C_C_CO
     CA    CB    CG   ND1    dih_HIS_chi2_C_C_C_N
  [ impropers ]
-    -C    CA     N     H    improper_Z_N_X_Y  
-    CA    +N     C     O    improper_O_C_X_Y  
-   ND1   CD2    CG    CB    improper_Z_CA_X_Y 
-    CG   CE1   ND1   HD1    improper_Z_N_X_Y  
-    CG   NE2   CD2   HD2    improper_Z_CA_X_Y 
-   ND1   NE2   CE1   HE1    improper_Z_CA_X_Y 
+    -C    CA     N     H    improper_Z_N_X_Y
+    CA    +N     C     O    improper_O_C_X_Y
+   ND1   CD2    CG    CB    improper_Z_CA_X_Y
+    CG   CE1   ND1   HD1    improper_Z_N_X_Y
+    CG   NE2   CD2   HD2    improper_Z_CA_X_Y
+   ND1   NE2   CE1   HE1    improper_Z_CA_X_Y
 
 
-[ HISE ] 
+[ HISE ]
  [ atoms ]
      N    opls_238   -0.500     1
      H    opls_241    0.300     1
     CA    opls_224B   0.140     1
     HA    opls_140    0.060     1
     CB    opls_505   -0.005     2
-   HB1    opls_140    0.060    2
-   HB2    opls_140    0.060    2
+   HB1    opls_140    0.060     2
+   HB2    opls_140    0.060     2
     CG    opls_507   -0.015     3
    ND1    opls_511   -0.490     3
    CD2    opls_508    0.015     4
-   HD2    opls_146    0.115     4 
-   CE1    opls_506    0.182     5
+   HD2    opls_146    0.115     4
+   CE1    opls_506    0.295     5
    HE1    opls_146    0.115     5
    NE2    opls_503   -0.570     6
    HE2    opls_504    0.420     6
    CH3  HH33
     -C     N
  [ impropers ]
-    -C    CH3     N    H      improper_Z_N_X_Y   
+    -C    CH3     N    H      improper_Z_N_X_Y
+
 
 [ NH2 ]
  [ atoms ]
-     N     opls_237  -0.760    1
+     N     opls_237  -0.760     1
     H1     opls_240   0.380     1
     H2     opls_240   0.380     1
  [ bonds ]
     -C     N
-     N    H1
+     N     H1
      N     H2
  [ impropers ]
-    -C     H1    N      H2       improper_Z_N_X_Y 
+    -C     H1    N      H2       improper_Z_N_X_Y
 
-[ NHE ] 
+[ NHE ]
 ; same as NH2
  [ atoms ]
-     N     opls_237  -0.760    1
+     N     opls_237  -0.760     1
     H1     opls_240   0.380     1
     H2     opls_240   0.380     1
  [ bonds ]
     -C     N
-     N    H1
+     N     H1
      N     H2
  [ impropers ]
-    -C     H1     N     H2       improper_Z_N_X_Y 
+    -C     H1     N     H2       improper_Z_N_X_Y
+
 [ PHE ]
  [ atoms ]
      N    opls_238   -0.500     1
      C     O
     -C     N
  [ impropers ]
-    -C    CA     N     H    improper_Z_N_X_Y  
-    CA    +N     C     O    improper_O_C_X_Y  
-    CG   CE2   CD2   HD2    improper_Z_CA_X_Y 
-   CD2    CZ   CE2   HE2    improper_Z_CA_X_Y 
-   CD1    CZ   CE1   HE1    improper_Z_CA_X_Y 
-    CG   CE1   CD1   HD1    improper_Z_CA_X_Y 
-   CD1   CD2    CG    CB    improper_Z_CA_X_Y 
-   CE1   CE2    CZ    OH    improper_Z_CA_X_Y 
+    -C    CA     N     H    improper_Z_N_X_Y
+    CA    +N     C     O    improper_O_C_X_Y
+    CG   CE2   CD2   HD2    improper_Z_CA_X_Y
+   CD2    CZ   CE2   HE2    improper_Z_CA_X_Y
+   CD1    CZ   CE1   HE1    improper_Z_CA_X_Y
+    CG   CE1   CD1   HD1    improper_Z_CA_X_Y
+   CD1   CD2    CG    CB    improper_Z_CA_X_Y
+   CE1   CE2    CZ    OH    improper_Z_CA_X_Y
 
 
 [ VAL ]
      H    opls_241    0.300     1
     CA    opls_224B   0.140     1
     HA    opls_140    0.060     1
-    CB    opls_137   -0.060    2
+    CB    opls_137   -0.060     2
     HB    opls_140    0.060     2
    CG1    opls_135   -0.180     3
   HG11    opls_140    0.060     3
 ; Use at your own risk!
 [ DMSO  ]
  [ atoms ]
-OD         opls_125    -0.459      1
-SD         opls_124     0.139      1
-CD1        opls_139    -0.020      1
-HD11       opls_140     0.060      1
-HD12       opls_140     0.060      1
-HD13       opls_140     0.060      1
-CD2        opls_139    -0.020      1
-HD21       opls_140     0.060      1
-HD22       opls_140     0.060      1
-HD23       opls_140     0.060      1
+OD      opls_125    -0.459      1
+SD      opls_124     0.139      1
+CD1     opls_139    -0.020      1
+HD11    opls_140     0.060      1
+HD12    opls_140     0.060      1
+HD13    opls_140     0.060      1
+CD2     opls_139    -0.020      1
+HD21    opls_140     0.060      1
+HD22    opls_140     0.060      1
+HD23    opls_140     0.060      1
 
  [ bonds ]
-    OD     SD  
-    SD     CD1 
-    SD     CD2 
+    OD     SD
+    SD     CD1
+    SD     CD2
     CD1    HD11
-    CD1           HD12
-    CD1           HD13
-    CD2           HD21
-    CD2           HD22
-    CD2           HD23
+    CD1    HD12
+    CD1    HD13
+    CD2    HD21
+    CD2    HD22
+    CD2    HD23
 
index 1eaf5bc99f54ca7d58e61471d9c63a65c4763633..82b14fe19c628b57107877f6f599a7f1b0555d0b 100644 (file)
@@ -90,6 +90,8 @@ class CMainCommandLineModule : public ICommandLineModule
     public:
         //! \copydoc gmx::CommandLineModuleManager::CMainFunction
         typedef CommandLineModuleManager::CMainFunction CMainFunction;
+        //! \copydoc gmx::CommandLineModuleManager::InitSettingsFunction
+        typedef CommandLineModuleManager::InitSettingsFunction InitSettingsFunction;
 
         /*! \brief
          * Creates a wrapper module for the given main function.
@@ -97,14 +99,16 @@ class CMainCommandLineModule : public ICommandLineModule
          * \param[in] name             Name for the module.
          * \param[in] shortDescription One-line description for the module.
          * \param[in] mainFunction     Main function to wrap.
+         * \param[in] settingsFunction Initializer for settings (can be null).
          *
          * Does not throw.  This is essential for correct implementation of
          * CommandLineModuleManager::runAsMainCMain().
          */
         CMainCommandLineModule(const char *name, const char *shortDescription,
-                               CMainFunction mainFunction)
+                               CMainFunction mainFunction,
+                               InitSettingsFunction settingsFunction)
             : name_(name), shortDescription_(shortDescription),
-              mainFunction_(mainFunction)
+              mainFunction_(mainFunction), settingsFunction_(settingsFunction)
         {
         }
 
@@ -117,8 +121,12 @@ class CMainCommandLineModule : public ICommandLineModule
             return shortDescription_;
         }
 
-        virtual void init(CommandLineModuleSettings * /*settings*/)
+        virtual void init(CommandLineModuleSettings *settings)
         {
+            if (settingsFunction_ != nullptr)
+            {
+                settingsFunction_(settings);
+            }
         }
         virtual int run(int argc, char *argv[])
         {
@@ -133,6 +141,7 @@ class CMainCommandLineModule : public ICommandLineModule
         const char             *name_;
         const char             *shortDescription_;
         CMainFunction           mainFunction_;
+        InitSettingsFunction    settingsFunction_;
 };
 
 //! \}
@@ -467,7 +476,18 @@ void CommandLineModuleManager::addModuleCMain(
         CMainFunction mainFunction)
 {
     CommandLineModulePointer module(
-            new CMainCommandLineModule(name, shortDescription, mainFunction));
+            new CMainCommandLineModule(name, shortDescription, mainFunction,
+                                       nullptr));
+    addModule(std::move(module));
+}
+
+void CommandLineModuleManager::addModuleCMainWithSettings(
+        const char *name, const char *shortDescription,
+        CMainFunction mainFunction, InitSettingsFunction settingsFunction)
+{
+    CommandLineModulePointer module(
+            new CMainCommandLineModule(name, shortDescription, mainFunction,
+                                       settingsFunction));
     addModule(std::move(module));
 }
 
@@ -593,7 +613,16 @@ int CommandLineModuleManager::runAsMainSingleModule(
 int CommandLineModuleManager::runAsMainCMain(
         int argc, char *argv[], CMainFunction mainFunction)
 {
-    CMainCommandLineModule module(argv[0], NULL, mainFunction);
+    CMainCommandLineModule module(argv[0], nullptr, mainFunction, nullptr);
+    return runAsMainSingleModule(argc, argv, &module);
+}
+
+// static
+int CommandLineModuleManager::runAsMainCMainWithSettings(
+        int argc, char *argv[], CMainFunction mainFunction,
+        InitSettingsFunction settingsFunction)
+{
+    CMainCommandLineModule module(argv[0], nullptr, mainFunction, settingsFunction);
     return runAsMainSingleModule(argc, argv, &module);
 }
 
index 57749b3949a8105c64486fe114c0c9b72a8e9f26..7bdd30bf8eb718f8f6bbd174db0bd16e1f367989 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -53,6 +53,7 @@ namespace gmx
 
 class CommandLineModuleGroup;
 class CommandLineModuleGroupData;
+class CommandLineModuleSettings;
 class CommandLineProgramContext;
 class ICommandLineModule;
 class IFileOutputRedirector;
@@ -96,6 +97,8 @@ class CommandLineModuleManager
     public:
         //! Function pointer type for a C main function.
         typedef int (*CMainFunction)(int argc, char *argv[]);
+        //! Function pointer to a settings provider.
+        typedef void (*InitSettingsFunction)(CommandLineModuleSettings *settings);
 
         /*! \brief
          * Implements a main() method that runs a single module.
@@ -160,6 +163,17 @@ class CommandLineModuleManager
          */
         static int runAsMainCMain(int argc, char *argv[],
                                   CMainFunction mainFunction);
+        /*! \brief
+         * Implements a main() method that runs a given function with custom
+         * settings.
+         *
+         * This method does the same as runAsMainCMain(), but additionally
+         * calls \p settingsFunction to initialize CommandLineModuleSettings.
+         * This allows specifying, e.g., a different default nice level.
+         */
+        static int runAsMainCMainWithSettings(int argc, char *argv[],
+                                              CMainFunction mainFunction,
+                                              InitSettingsFunction settingsFunction);
 
         /*! \brief
          * Initializes a command-line module manager.
@@ -260,6 +274,17 @@ class CommandLineModuleManager
          */
         void addModuleCMain(const char *name, const char *shortDescription,
                             CMainFunction mainFunction);
+        /*! \brief
+         * Adds a module that runs a given main()-like function with custom
+         * settings.
+         *
+         * This method does the same as runAsMainCMain(), but additionally
+         * calls \p settingsFunction to initialize CommandLineModuleSettings.
+         * This allows specifying, e.g., a different default nice level.
+         */
+        void addModuleCMainWithSettings(const char *name, const char *shortDescription,
+                                        CMainFunction mainFunction,
+                                        InitSettingsFunction settingsFunction);
         /*! \brief
          * Registers a module of a certain type to this manager.
          *
index a18620ccfc2805a0079b9ae3a73b058fcd6e3ec6..b612a1ebdf88f462a24c5184172c4f1c558e101b 100644 (file)
@@ -2104,8 +2104,8 @@ static gmx_bool receive_vir_ener(const gmx_domdec_t *dd, const t_commrec *cr)
         gmx_domdec_comm_t *comm = dd->comm;
         if (comm->bCartesianPP_PME)
         {
-            int  pmenode = dd_simnode2pmenode(dd, cr, cr->sim_nodeid);
 #if GMX_MPI
+            int  pmenode = dd_simnode2pmenode(dd, cr, cr->sim_nodeid);
             ivec coords;
             MPI_Cart_coords(cr->mpi_comm_mysim, cr->sim_nodeid, DIM, coords);
             coords[comm->cartpmedim]++;
@@ -2119,6 +2119,8 @@ static gmx_bool receive_vir_ener(const gmx_domdec_t *dd, const t_commrec *cr)
                     bReceive = FALSE;
                 }
             }
+#else
+            GMX_RELEASE_ASSERT(false, "Without MPI we should not have Cartesian PP-PME with #PMEnodes < #DDnodes");
 #endif
         }
         else
@@ -5750,8 +5752,8 @@ static void make_pp_communicator(FILE                 *fplog,
     }
 }
 
-static void receive_ddindex2simnodeid(gmx_domdec_t gmx_unused *dd,
-                                      t_commrec    gmx_unused *cr)
+static void receive_ddindex2simnodeid(gmx_domdec_t         *dd,
+                                      t_commrec            *cr)
 {
 #if GMX_MPI
     gmx_domdec_comm_t *comm = dd->comm;
@@ -5770,6 +5772,9 @@ static void receive_ddindex2simnodeid(gmx_domdec_t gmx_unused *dd,
                       cr->mpi_comm_mysim);
         sfree(buf);
     }
+#else
+    GMX_UNUSED_VALUE(dd);
+    GMX_UNUSED_VALUE(cr);
 #endif
 }
 
index 9c34afabe15b8759b03568549616b0dea2c30155..e6205f23d4977f25c87ab136c8117c5d31382dba 100644 (file)
@@ -124,6 +124,7 @@ typedef struct
 {
     int      pull_type;       //!< such as constraint, umbrella, ...
     int      geometry;        //!< such as distance, direction, cylinder
+    int      ngroup;          //!< the number of pull groups involved
     ivec     dim;             //!< pull dimension with geometry distance
     int      ndim;            //!< nr of pull_dim != 0
     real     k;               //!< force constants in tpr file
@@ -140,9 +141,9 @@ typedef struct
     /*!\{*/
     int          npullcrds;      //!< nr of umbrella pull coordinates for reading
     t_pullcoord *pcrd;           //!< the pull coordinates
+    gmx_bool     bPrintCOM;      //!< COMs of pull groups writtn in pullx.xvg
     gmx_bool     bPrintRefValue; //!< Reference value for the coordinate written in pullx.xvg
     gmx_bool     bPrintComp;     //!< Components of pull distance written to pullx.xvg ?
-    int          nCOMGrpsPullx;  //!< Number of grps of which the COM is listed in pullx.xvg (COM of grp 1 or grp 2 or both)
 
     /*!\}*/
     /*!
@@ -2067,12 +2068,8 @@ void read_tpr_header(const char *fn, t_UmbrellaHeader* header, t_UmbrellaOptions
     }
 
     /* Read overall pull info */
-    header->npullcrds     = ir->pull->ncoord;
-    header->nCOMGrpsPullx = 0;
-    if (ir->pull->bPrintCOM)
-    {
-        header->nCOMGrpsPullx += ir->pull->ngroup;
-    }
+    header->npullcrds      = ir->pull->ncoord;
+    header->bPrintCOM      = ir->pull->bPrintCOM;
     header->bPrintRefValue = ir->pull->bPrintRefValue;
     header->bPrintComp     = ir->pull->bPrintComp;
 
@@ -2082,6 +2079,7 @@ void read_tpr_header(const char *fn, t_UmbrellaHeader* header, t_UmbrellaOptions
     {
         header->pcrd[i].pull_type     = ir->pull->coord[i].eType;
         header->pcrd[i].geometry      = ir->pull->coord[i].eGeom;
+        header->pcrd[i].ngroup        = ir->pull->coord[i].ngroup;
         header->pcrd[i].k             = ir->pull->coord[i].k;
         header->pcrd[i].init_dist     = ir->pull->coord[i].init;
 
@@ -2174,18 +2172,7 @@ void read_tpr_header(const char *fn, t_UmbrellaHeader* header, t_UmbrellaOptions
                    epullg_names[header->pcrd[i].geometry], header->pcrd[i].k, header->pcrd[i].init_dist,
                    int2YN(header->pcrd[i].dim[XX]), int2YN(header->pcrd[i].dim[YY]), int2YN(header->pcrd[i].dim[ZZ]),
                    header->pcrd[i].ndim, use ? "Yes" : "No");
-        }
-        switch (header->nCOMGrpsPullx)
-        {
-            case 0:
-                printf("\tNo pull group coordinates expected in pullx files.\n");
-                break;
-            case 1:
-                printf("\tPull group coordinates of one group expected in pullx files.\n");
-                break;
-            case 2:
-                printf("\tPull group coordinates of two groups expected in pullx files.\n");
-                break;
+            printf("\tPull group coordinates of %d groups expected in pullx files.\n", ir->pull->bPrintCOM ? header->pcrd[i].ngroup : 0);
         }
         printf("\tReference value of the coordinate%s expected in pullx files.\n",
                header->bPrintRefValue ? "" : " not");
@@ -2233,8 +2220,7 @@ void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
      *    No reference columns, one column per pull coordinate
      *
      *  - in position output pullx.xvg:
-     *     * optionally, ndim columns for COM of of grp1 or grp2, depending on on mdp options
-     *       pull-print-com1 & pull-print-com2);
+     *     * optionally, ndim columns for COMs of all groups (depending on on mdp options pull-print-com);
      *     * The displacement, always one column. Note: with pull-print-components = yes, the dx/dy/dz would
      *       be written separately into pullx file, but this is not supported and throws an error below;
      *     * optionally, the position of the reference coordinate (depending on pull-print-ref-value)
@@ -2267,7 +2253,7 @@ void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
         for (g = 0; g < header->npullcrds; g++)
         {
             nColRefCrd[g]   = (header->bPrintRefValue ? 1 : 0);
-            nColCOMCrd[g]   = header->pcrd[g].ndim*header->nCOMGrpsPullx;
+            nColCOMCrd[g]   = (header->bPrintCOM ? header->pcrd[g].ndim*header->pcrd[g].ngroup : 0);
             nColThisCrd[g]  = 1 + nColCOMCrd[g] + nColRefCrd[g];
         }
     }
@@ -2293,10 +2279,10 @@ void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
         for (i = 0; i < header->npullcrds; i++)
         {
             printf("\tColumns for pull coordinate %d\n", i+1);
-            printf("\t\tcenter-of-mass of groups:        %d\n"
-                   "\t\tdisplacement wrt. reference:     %d\n"
+            printf("\t\treaction coordinate:             %d\n"
+                   "\t\tcenter-of-mass of groups:        %d\n"
                    "\t\treference position column:       %s\n",
-                   nColCOMCrd[i], 1, (header->bPrintRefValue ? "Yes" : "No"));
+                   1, nColCOMCrd[i], (header->bPrintRefValue ? "Yes" : "No"));
         }
         printf("\tFound %d times in %s\n", nt, fn);
         bFirst = FALSE;
@@ -2459,7 +2445,6 @@ void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
                     {
                         column += nColThisCrd[j];
                     }
-                    column += nColCOMCrd[g];
                     pos     = y[column][i];
                 }
 
index cbd80479e5a974f1e69eaceb216453f459b2a192..488a9bc80f37d34e50e1297506c3b608970ef161 100644 (file)
@@ -310,7 +310,7 @@ TEST(FunctionTest, ErfInvFloat)
 
     for (int i = 0; i < npoints; i++)
     {
-        float r = -1.0 + 2.0 * (float(i) + 0.5) / npoints;
+        float r = float(2*i - npoints + 1) / npoints;
 
         result.push_back(gmx::erfinv(r));
     }
@@ -326,7 +326,7 @@ TEST(FunctionTest, ErfInvDouble)
 
     for (int i = 0; i < npoints; i++)
     {
-        double r = -1.0 + 2.0 * (double(i) + 0.5) / npoints;
+        double r = double(2*i - npoints + 1) / npoints;
 
         result.push_back(gmx::erfinv(r));
     }
@@ -339,7 +339,7 @@ TEST(FunctionTest, ErfAndErfInvAreInversesFloat)
 
     for (int i = 0; i < npoints; i++)
     {
-        float r = -1.0 + 2.0 * (float(i) + 0.5) / npoints;
+        float r = float(2*i - npoints + 1) / npoints;
         EXPECT_FLOAT_EQ_TOL(r, std::erf(gmx::erfinv(r)), gmx::test::ulpTolerance(10));
     }
 }
@@ -350,7 +350,7 @@ TEST(FunctionTest, ErfAndErfInvAreInversesDouble)
 
     for (int i = 0; i < npoints; i++)
     {
-        double r = -1.0 + 2.0 * (double(i) + 0.5) / npoints;
+        double r = double(2*i - npoints + 1) / npoints;
         EXPECT_DOUBLE_EQ_TOL(r, std::erf(gmx::erfinv(r)), gmx::test::ulpTolerance(10));
     }
 }
index ace59739463cf3fc2642429d7b736058e53d31b7..3f62e86de485c915adab7a05a8c6ce9bfb67ee8c 100644 (file)
@@ -423,8 +423,7 @@ void nbnxn_gpu_launch_kernel(gmx_nbnxn_cuda_t       *nb,
      * - The 1D block-grid contains as many blocks as super-clusters.
      */
     int num_threads_z = 1;
-    if ((nb->dev_info->prop.major == 3 && nb->dev_info->prop.minor == 7) ||
-        (nb->dev_info->prop.major == 6 && nb->dev_info->prop.minor == 0))
+    if (nb->dev_info->prop.major == 3 && nb->dev_info->prop.minor == 7)
     {
         num_threads_z = 2;
     }
index 4d9455cc66e4b56f4a51c5888423af07e97a9a68..192b20d35e766d88798e4ba7c22742492761e2a7 100644 (file)
  * NTHREAD_Z controls the number of j-clusters processed concurrently on NTHREAD_Z
  * warp-pairs per block.
  *
- * - On CC 2.0-3.5, 5.0, and 5.2, NTHREAD_Z == 1, translating to 64 th/block with 16
- * blocks/multiproc, is the fastest even though this setup gives low occupancy.
+ * - On CC 2.0-3.5, and >=5.0 NTHREAD_Z == 1, translating to 64 th/block with 16
+ * blocks/multiproc, is the fastest even though this setup gives low occupancy
+ * (except on 6.0).
  * NTHREAD_Z > 1 results in excessive register spilling unless the minimum blocks
  * per multiprocessor is reduced proportionally to get the original number of max
  * threads in flight (and slightly lower performance).
- * - On CC 3.7 and 6.0 there are enough registers to double the number of threads; using
+ * - On CC 3.7 there are enough registers to double the number of threads; using
  * NTHREADS_Z == 2 is fastest with 16 blocks (TODO: test with RF and other kernels
  * with low-register use).
  *
 /* Kernel launch bounds for different compute capabilities. The value of NTHREAD_Z
  * determines the number of threads per block and it is chosen such that
  * 16 blocks/multiprocessor can be kept in flight.
- * - CC 3.0/3.5/5.x, >=6.1: NTHREAD_Z=1, (64, 16) bounds
- * - CC 3.7, 6.0:           NTHREAD_Z=2, (128, 16) bounds
+ * - CC 3.0,3.5, and >=5.0: NTHREAD_Z=1, (64, 16) bounds
+ * - CC 3.7:                NTHREAD_Z=2, (128, 16) bounds
  *
  * Note: convenience macros, need to be undef-ed at the end of the file.
  */
-#if GMX_PTX_ARCH == 370 || GMX_PTX_ARCH == 600
+#if GMX_PTX_ARCH == 370
     #define NTHREAD_Z           (2)
     #define MIN_BLOCKS_PER_MP   (16)
 #else
     #define NTHREAD_Z           (1)
     #define MIN_BLOCKS_PER_MP   (16)
-#endif /* GMX_PTX_ARCH == 370 || GMX_PTX_ARCH == 600 */
+#endif /* GMX_PTX_ARCH == 370 */
 #define THREADS_PER_BLOCK   (c_clSize*c_clSize*NTHREAD_Z)
 
 #if GMX_PTX_ARCH >= 350
index 6ac192b712d903cfe3c799a3067491686875b04b..8ec23c6d890e0fb50cfa8364ca2f813fed8255a4 100644 (file)
@@ -177,46 +177,37 @@ class DirectoryEnumerator::Impl
             }
             return new Impl(handle);
         }
-        explicit Impl(DIR *handle) : dirent_handle(handle)
-        {
-            // TODO: Use memory allocation that throws, and handle
-            // exception safety (close handle) in such a case.
-            /* On some platforms no space is present for d_name in dirent.
-             * Since d_name is guaranteed to be the last entry, allocating
-             * extra space for dirent will allow more size for d_name.
-             * GMX_MAX_PATH should always be >= the max possible d_name.
-             */
-            smalloc(direntp_large, sizeof(*direntp_large) + GMX_PATH_MAX);
-        }
+        explicit Impl(DIR *handle) : dirent_handle(handle) {}
         ~Impl()
         {
-            sfree(direntp_large);
             closedir(dirent_handle);
         }
 
         bool nextFile(std::string *filename)
         {
             errno = 0;
-            dirent *p;
-            int     rc = readdir_r(dirent_handle, direntp_large, &p);
-            if (p == NULL && rc == 0)
-            {
-                filename->clear();
-                return false;
-            }
-            else if (rc != 0)
+            dirent *p = readdir(dirent_handle);
+            if (p == NULL)
             {
-                GMX_THROW_WITH_ERRNO(
-                        FileIOError("Failed to list files in a directory"),
-                        "readdir_r", errno);
+                if (errno == 0)
+                {
+                    // All the files have been found.
+                    filename->clear();
+                    return false;
+                }
+                else
+                {
+                    GMX_THROW_WITH_ERRNO(
+                            FileIOError("Failed to list files in a directory"),
+                            "readdir", errno);
+                }
             }
-            *filename = direntp_large->d_name;
+            *filename = p->d_name;
             return true;
         }
 
     private:
         DIR    *dirent_handle;
-        dirent *direntp_large;
 };
 #else
 class DirectoryEnumerator::Impl
index 2a3962cd9d59b9ff39081c846333a1c84f6c01b5..bb4a05006f46938ec452e143828241128bdde12d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -54,6 +54,10 @@ namespace gmx
 /*! \libinternal \brief
  * Lists files in a directory.
  *
+ * If multiple threads share the same DirectoryEnumerator, they must
+ * take responsibility for their mutual synchronization, particularly
+ * with regard to calling nextFile().
+ *
  * \inlibraryapi
  * \ingroup module_utility
  */
@@ -108,6 +112,10 @@ class DirectoryEnumerator
          * If `bThrow` passed to the constructor was `false` and the directory
          * was not successfully opened, the first call to this function will
          * return `false`.
+         *
+         * This method is not thread safe when called on the same
+         * object by multiple threads. Such use requires external
+         * synchronization.
          */
         bool nextFile(std::string *filename);
 
index 406e2711dc25098a77e71c0f7e275039ab43ad1d..10a6f64c342d2a66b6357c371aede70f1c737840 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -113,57 +113,11 @@ class ObsoleteToolModule : public gmx::ICommandLineModule
         const char             *name_;
 };
 
-// TODO: Consider removing duplication with CMainCommandLineModule from
-// cmdlinemodulemanager.cpp.
-class NoNiceModule : public gmx::ICommandLineModule
+//! Initializer for a module that defaults to nice level zero.
+void initSettingsNoNice(gmx::CommandLineModuleSettings *settings)
 {
-    public:
-        //! \copydoc gmx::CommandLineModuleManager::CMainFunction
-        typedef gmx::CommandLineModuleManager::CMainFunction CMainFunction;
-
-        /*! \brief
-         * Creates a wrapper module for the given main function.
-         *
-         * \param[in] name             Name for the module.
-         * \param[in] shortDescription One-line description for the module.
-         * \param[in] mainFunction     Main function to wrap.
-         *
-         * Does not throw.
-         */
-        NoNiceModule(const char *name, const char *shortDescription,
-                     CMainFunction mainFunction)
-            : name_(name), shortDescription_(shortDescription),
-              mainFunction_(mainFunction)
-        {
-        }
-
-        virtual const char *name() const
-        {
-            return name_;
-        }
-        virtual const char *shortDescription() const
-        {
-            return shortDescription_;
-        }
-
-        virtual void init(gmx::CommandLineModuleSettings *settings)
-        {
-            settings->setDefaultNiceLevel(0);
-        }
-        virtual int run(int argc, char *argv[])
-        {
-            return mainFunction_(argc, argv);
-        }
-        virtual void writeHelp(const gmx::CommandLineHelpContext &context) const
-        {
-            writeCommandLineHelpCMain(context, name_, mainFunction_);
-        }
-
-    private:
-        const char             *name_;
-        const char             *shortDescription_;
-        CMainFunction           mainFunction_;
-};
+    settings->setDefaultNiceLevel(0);
+}
 
 /*! \brief
  * Convenience function for creating and registering a module.
@@ -193,9 +147,8 @@ void registerModuleNoNice(gmx::CommandLineModuleManager                *manager,
                           gmx::CommandLineModuleManager::CMainFunction  mainFunction,
                           const char *name, const char *shortDescription)
 {
-    gmx::CommandLineModulePointer module(
-            new NoNiceModule(name, shortDescription, mainFunction));
-    manager->addModule(std::move(module));
+    manager->addModuleCMainWithSettings(name, shortDescription, mainFunction,
+                                        &initSettingsNoNice);
 }
 
 /*! \brief
index e6b694d123dd4bd0cffbee8e4c300fb01d77cb81..c2bdb70b3df5fdd4913947893cf056a81e4e5964 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  */
 #include "gmxpre.h"
 
+#include "gromacs/commandline/cmdlinemodule.h"
 #include "gromacs/commandline/cmdlinemodulemanager.h"
 
 #include "mdrun/mdrun_main.h"
 
+namespace
+{
+
+//! Initializer for a module that defaults to nice level zero.
+void initSettingsNoNice(gmx::CommandLineModuleSettings *settings)
+{
+    settings->setDefaultNiceLevel(0);
+}
+
+}
+
 int main(int argc, char *argv[])
 {
-    return gmx::CommandLineModuleManager::runAsMainCMain(argc, argv, &gmx_mdrun);
+    return gmx::CommandLineModuleManager::runAsMainCMainWithSettings(
+            argc, argv, &gmx_mdrun, &initSettingsNoNice);
 }