Avoid using global variables in programs
authorRoland Schulz <roland.schulz@intel.com>
Fri, 12 Jan 2018 08:46:35 +0000 (00:46 -0800)
committerRoland Schulz <roland.schulz@intel.com>
Fri, 10 Aug 2018 21:12:32 +0000 (14:12 -0700)
Using global variables defined in libgromacs and
used from outside causes issues if only lazy
binding is available.

Change-Id: Id1e960d7c638476d3f7ace339a327040f516f6fc

src/gromacs/gmxpreprocess/insert-molecules.cpp
src/gromacs/gmxpreprocess/insert-molecules.h
src/gromacs/mdlib/membed.cpp
src/gromacs/mdrun/runner.cpp
src/programs/legacymodules.cpp

index dba2916cc8efa72d9d903805236f50a21f5acf86..1b7d10ee0d7ce9aa9e0af0eee1e0eea7fe0e2108 100644 (file)
@@ -595,9 +595,20 @@ int InsertMolecules::run()
 
 }   // namespace
 
-const char InsertMoleculesInfo::name[]             = "insert-molecules";
-const char InsertMoleculesInfo::shortDescription[] =
-    "Insert molecules into existing vacancies";
+
+const char* InsertMoleculesInfo::name()
+{
+    static const char* name = "insert-molecules";
+    return name;
+}
+
+const char* InsertMoleculesInfo::shortDescription()
+{
+    static const char* shortDescription =
+        "Insert molecules into existing vacancies";
+    return shortDescription;
+}
+
 ICommandLineOptionsModulePointer InsertMoleculesInfo::create()
 {
     return ICommandLineOptionsModulePointer(new InsertMolecules());
index 818526f9ec91a27c741d444fa2e7fbc1ecb27ac9..8392f92277a8665d73bb137f94d086985693cefe 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2018, 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.
@@ -43,8 +43,8 @@ namespace gmx
 class InsertMoleculesInfo
 {
     public:
-        static const char name[];
-        static const char shortDescription[];
+        static const char* name();
+        static const char* shortDescription();
         static ICommandLineOptionsModulePointer create();
 };
 
index 19edefaedd2a18727432288a74802170e95d34a1..11aeffa7127e22946c2bd6bdbcfb1c744e76f59b 100644 (file)
@@ -233,6 +233,10 @@ static void get_input(const char *membed_input, real *xy_fac, real *xy_max, real
     *low_up_rm        = get_eint(&inp, "ndiff", 0, wi);
     *maxwarn          = get_eint(&inp, "maxwarn", 0, wi);
     *pieces           = get_eint(&inp, "pieces", 1, wi);
+    const char *yesno_names[BOOL_NR+1] =
+    {
+        "no", "yes", nullptr
+    };
     *bALLOW_ASYMMETRY = get_eeenum(&inp, "asymmetry", yesno_names, wi);
 
     check_warning_error(wi, FARGS);
index c9d634f591c1e91aab6031a3da72fd1d6bf10ecb..0c0797239c936287b100576b72982a3782adcb46 100644 (file)
@@ -837,8 +837,7 @@ int Mdrunner::mdrunner()
         if (inputrec->ePBC == epbcSCREW)
         {
             gmx_fatal(FARGS,
-                      "pbc=%s is only implemented with domain decomposition",
-                      epbc_names[inputrec->ePBC]);
+                      "pbc=screw is only implemented with domain decomposition");
         }
     }
 
index 6da0d77694c1a9aa4471e3e279e07bfde0df2208..7dea2832cee5fd81fc11819ccd649fd72cee6579 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016,2017,2018, 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.
@@ -187,8 +187,8 @@ void registerLegacyModules(gmx::CommandLineModuleManager *manager)
                          "Perform a simulation, do a normal mode analysis or an energy minimization");
 
     gmx::ICommandLineOptionsModule::registerModuleFactory(
-            manager, gmx::InsertMoleculesInfo::name,
-            gmx::InsertMoleculesInfo::shortDescription,
+            manager, gmx::InsertMoleculesInfo::name(),
+            gmx::InsertMoleculesInfo::shortDescription(),
             &gmx::InsertMoleculesInfo::create);
 
     // Modules from gmx_ana.h.