Some module dependency cleanup.
authorTeemu Murtola <teemu.murtola@gmail.com>
Tue, 29 Oct 2013 20:25:10 +0000 (22:25 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sat, 16 Nov 2013 22:07:11 +0000 (23:07 +0100)
Move wman.* from onlinehelp/ to commandline/, since they depend on stuff
from commandline, and are not used by anything else than statutil.cpp
for command-line stuff.  Also, don't let exceptions from write_man()
propagate into C code potentially calling parse_common_args().

Move some additional file I/O stuff into trxio.c from statutil.cpp,
removing otherwise unnecessary dependencies to fileio.

Change-Id: I43ededf3c729239cd0e6bd8ddaf97386747c4363

src/gromacs/commandline/wman.cpp [moved from src/gromacs/onlinehelp/wman.cpp with 99% similarity]
src/gromacs/commandline/wman.h [moved from src/gromacs/onlinehelp/wman.h with 94% similarity]
src/gromacs/fileio/trxio.c
src/gromacs/gmxlib/statutil.cpp
src/gromacs/onlinehelp/helpwritercontext.cpp

similarity index 99%
rename from src/gromacs/onlinehelp/wman.cpp
rename to src/gromacs/commandline/wman.cpp
index e9632d9ecb80ac1c0e681ceaab08c37309246b07..f7b763ddd70d40358731ea6ecb3254e4fb98762a 100644 (file)
@@ -32,6 +32,8 @@
  * And Hey:
  * GROningen Mixture of Alchemy and Childrens' Stories
  */
+#include "gromacs/commandline/wman.h"
+
 #include <cstdio>
 #include <cstring>
 
@@ -40,7 +42,6 @@
 #include "gromacs/commandline/cmdlinehelpcontext.h"
 #include "gromacs/fileio/filenm.h"
 #include "gromacs/fileio/gmxfio.h"
-#include "gromacs/onlinehelp/wman.h"
 #include "gromacs/utility/file.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/stringutil.h"
similarity index 94%
rename from src/gromacs/onlinehelp/wman.h
rename to src/gromacs/commandline/wman.h
index 06e9f7fc31427eed0f4f8b1ef8245265cc46d804..72208aefb203cc6fee1ee9ba62842e76d51bc6f7 100644 (file)
  * And Hey:
  * Gromacs Runs On Most of All Computer Systems
  */
-#ifndef GMX_ONLINEHELP_WMAN_H
-#define GMX_ONLINEHELP_WMAN_H
+#ifndef GMX_COMMANDLINE_WMAN_H
+#define GMX_COMMANDLINE_WMAN_H
+
+#include "gromacs/legacyheaders/readinp.h"
 
-#include "readinp.h"
 #include "gromacs/fileio/filenm.h"
 
 void write_man(const char *mantp, const char *program,
index 17baacab638fe25fddc44acdab964e2b89e91e16..2ee0ef5313af72f794ae6ff8e0d4e92d0165cca2 100644 (file)
@@ -52,6 +52,7 @@
 #include "gmxfio.h"
 #include "trxio.h"
 #include "gromacs/legacyheaders/statutil.h"
+#include "tpxio.h"
 #include "trnio.h"
 #include "names.h"
 #include "vec.h"
@@ -88,6 +89,27 @@ struct t_trxstatus
 
 /* utility functions */
 
+gmx_bool bRmod_fd(double a, double b, double c, gmx_bool bDouble)
+{
+    int    iq;
+    double tol;
+
+    tol = 2*(bDouble ? GMX_DOUBLE_EPS : GMX_FLOAT_EPS);
+
+    iq = (int)((a - b + tol*a)/c);
+
+    if (fabs(a - b - c*iq) <= tol*fabs(a))
+    {
+        return TRUE;
+    }
+    else
+    {
+        return FALSE;
+    }
+}
+
+
+
 int check_times2(real t, real t0, gmx_bool bDouble)
 {
     int  r;
@@ -1158,3 +1180,20 @@ void rewind_trj(t_trxstatus *status)
 
     gmx_fio_rewind(status->fio);
 }
+
+/***** T O P O L O G Y   S T U F F ******/
+
+t_topology *read_top(const char *fn, int *ePBC)
+{
+    int         epbc, natoms;
+    t_topology *top;
+
+    snew(top, 1);
+    epbc = read_tpx_top(fn, NULL, NULL, &natoms, NULL, NULL, NULL, top);
+    if (ePBC)
+    {
+        *ePBC = epbc;
+    }
+
+    return top;
+}
index 1755369e9dc5a550dfc6e855431c3e9695f58aad..429c36857ff11a6c41439fcb7928ff0dbd2a33af 100644 (file)
 #include "string2.h"
 #include "smalloc.h"
 #include "statutil.h"
-#include "gromacs/fileio/tpxio.h"
 #include "gmx_fatal.h"
 #include "network.h"
-#include "gromacs/fileio/gmxfio.h"
-#include "gromacs/fileio/trxio.h"
 
-#include "gromacs/onlinehelp/wman.h"
+#include "gromacs/commandline/wman.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/programinfo.h"
@@ -108,27 +105,6 @@ const char *Program(void)
 
 /* utility functions */
 
-gmx_bool bRmod_fd(double a, double b, double c, gmx_bool bDouble)
-{
-    int    iq;
-    double tol;
-
-    tol = 2*(bDouble ? GMX_DOUBLE_EPS : GMX_FLOAT_EPS);
-
-    iq = static_cast<int>((a - b + tol*a)/c);
-
-    if (std::fabs(a - b - c*iq) <= tol*std::fabs(a))
-    {
-        return TRUE;
-    }
-    else
-    {
-        return FALSE;
-    }
-}
-
-
-
 static void set_default_time_unit(const char *time_list[], gmx_bool bCanTime)
 {
     int         i      = 0;
@@ -190,24 +166,6 @@ static void set_default_xvg_format(const char *xvg_list[])
     }
 }
 
-
-/***** T O P O L O G Y   S T U F F ******/
-
-t_topology *read_top(const char *fn, int *ePBC)
-{
-    int         epbc, natoms;
-    t_topology *top;
-
-    snew(top, 1);
-    epbc = read_tpx_top(fn, NULL, NULL, &natoms, NULL, NULL, NULL, top);
-    if (ePBC)
-    {
-        *ePBC = epbc;
-    }
-
-    return top;
-}
-
 /*************************************************************
  *
  *           P A R S I N G   S T U F F
@@ -697,21 +655,25 @@ gmx_bool parse_common_args(int *argc, char *argv[], unsigned long Flags,
 
     if (strcmp(manstr[0], "no") != 0 && !(FF(PCA_QUIET)))
     {
-        if (!strcmp(manstr[0], "completion"))
+        try
         {
-            /* one file each for csh, bash and zsh if we do completions */
-            write_man("completion-zsh", output_env_get_short_program_name(*oenv),
-                      ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
-            write_man("completion-bash", output_env_get_short_program_name(*oenv),
-                      ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
-            write_man("completion-csh", output_env_get_short_program_name(*oenv),
-                      ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
-        }
-        else
-        {
-            write_man(manstr[0], output_env_get_short_program_name(*oenv),
-                      ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
+            if (!strcmp(manstr[0], "completion"))
+            {
+                /* one file each for csh, bash and zsh if we do completions */
+                write_man("completion-zsh", output_env_get_short_program_name(*oenv),
+                          ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
+                write_man("completion-bash", output_env_get_short_program_name(*oenv),
+                          ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
+                write_man("completion-csh", output_env_get_short_program_name(*oenv),
+                          ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
+            }
+            else
+            {
+                write_man(manstr[0], output_env_get_short_program_name(*oenv),
+                          ndesc, desc, nfile, fnm, npall, all_pa, nbugs, bugs);
+            }
         }
+        GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
     }
 
     /* convert time options, must be done after printing! */
index 609013bb3d26a572e704e73c8ce11534bf81a157..df1f4126806382cfab44c40ce7f7545c24ee3d63 100644 (file)
@@ -48,7 +48,6 @@
 #include <vector>
 
 #include "gromacs/onlinehelp/helpformat.h"
-#include "gromacs/onlinehelp/wman.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/file.h"
 #include "gromacs/utility/gmxassert.h"