Break dependency of fileio on tools
authorMark Abraham <mark.j.abraham@gmail.com>
Tue, 21 Jan 2014 09:52:04 +0000 (10:52 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Thu, 23 Jan 2014 05:07:49 +0000 (06:07 +0100)
The issue fixed in Change-Id: I674d41d contributed to the creation of
poor dependencies while trying to avoid yet other dependencies. This
solution relaxes all the constraints, and fixes the mdrun-only build.

Change-Id: I372d5e390469e99ba2d2a4fb70caf2e9a1c404eb

src/gromacs/fileio/tngio_for_tools.cpp
src/gromacs/fileio/tngio_for_tools.h
src/gromacs/tools/dump.c
src/gromacs/tools/dump.h

index 66d24121fabb8ee91e5fa599ed1a24eb2b82e119..9784f890dc51eb490beb8d86e9dc26c197be573d 100644 (file)
@@ -38,8 +38,6 @@
 #include <config.h>
 #endif
 
-#include <vector>
-
 #include "tngio.h"
 #include "trx.h"
 
@@ -52,7 +50,6 @@
 #include "gromacs/legacyheaders/smalloc.h"
 #include "gromacs/legacyheaders/physics.h"
 #include "gromacs/legacyheaders/gmx_fatal.h"
-#include "gromacs/tools/dump.h"
 
 void gmx_prepare_tng_writing(const char              *filename,
                              char                     mode,
@@ -862,62 +859,3 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(tng_trajectory_t     input,
     return FALSE;
 #endif
 }
-
-void list_tng_for_gmx_dump(const char *fn)
-{
-#ifdef GMX_USE_TNG
-    tng_trajectory_t     tng;
-    gmx_int64_t          nframe = 0;
-    gmx_int64_t          i, *block_ids = NULL, step, ndatablocks;
-    gmx_bool             bOK;
-
-    gmx_tng_open(fn, 'r', &tng);
-    gmx_print_tng_molecule_system(tng, stdout);
-
-    bOK    = gmx_get_tng_data_block_types_of_next_frame(tng, -1,
-                                                        0,
-                                                        NULL,
-                                                        &step, &ndatablocks,
-                                                        &block_ids);
-    do
-    {
-        for (i = 0; i < ndatablocks; i++)
-        {
-            double               frame_time;
-            real                 prec, *values = NULL;
-            gmx_int64_t          n_values_per_frame, n_atoms;
-            char                 block_name[STRLEN];
-
-            gmx_get_tng_data_next_frame_of_block_type(tng, block_ids[i], &values,
-                                                      &step, &frame_time,
-                                                      &n_values_per_frame, &n_atoms,
-                                                      &prec,
-                                                      block_name, STRLEN, &bOK);
-            if (!bOK)
-            {
-                /* Can't write any output because we don't know what
-                   arrays are valid. */
-                fprintf(stderr, "\nWARNING: Incomplete frame at time %g, will not write output\n", frame_time);
-                list_tng_inner(fn, (0 == i), values, step, frame_time,
-                               n_values_per_frame, n_atoms, prec, nframe, block_name);
-            }
-        }
-        nframe++;
-    }
-    while (gmx_get_tng_data_block_types_of_next_frame(tng, step,
-                                                      0,
-                                                      NULL,
-                                                      &step,
-                                                      &ndatablocks,
-                                                      &block_ids));
-
-    if (block_ids)
-    {
-        sfree(block_ids);
-    }
-
-    gmx_tng_close(&tng);
-#else
-    GMX_UNUSED_VALUE(fn);
-#endif
-}
index 6dd9a04e59dc8401552c86a9828c7d793af48ed7..d27680d84d75d48c3ad14630bd43cf352efaad42 100644 (file)
@@ -109,9 +109,6 @@ gmx_bool gmx_get_tng_data_next_frame_of_block_type(tng_trajectory_t     input,
                                                    int                  maxLen,
                                                    gmx_bool            *bOK);
 
-/*! \brief Implements TNG file reading for gmxdump. */
-void list_tng_for_gmx_dump(const char *fn);
-
 #ifdef __cplusplus
 }
 #endif
index 06212fed7f1e62867b53e8d58d7432761e193132..17aee79cf01f72c0ae2bf5a96c7629186c5c0409 100644 (file)
@@ -60,6 +60,7 @@
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trnio.h"
 #include "gromacs/fileio/futil.h"
+#include "gromacs/fileio/tngio.h"
 #include "gromacs/fileio/tngio_for_tools.h"
 
 #ifdef HAVE_UNISTD_H
@@ -316,8 +317,8 @@ void list_xtc(const char *fn)
     close_xtc(xd);
 }
 
-/* Callback used by list_tng_for_gmx_dump. */
-void list_tng_inner(const char *fn,
+/*! \brief Callback used by list_tng_for_gmx_dump. */
+static void list_tng_inner(const char *fn,
                     gmx_bool bFirstFrame,
                     real *values,
                     gmx_int64_t step, 
@@ -348,6 +349,63 @@ void list_tng_inner(const char *fn,
     pr_reals_of_dim(stdout, indent, block_name, values, n_atoms, n_values_per_frame);
 }
 
+static void list_tng(const char gmx_unused *fn)
+{
+#ifdef GMX_USE_TNG
+    tng_trajectory_t     tng;
+    gmx_int64_t          nframe = 0;
+    gmx_int64_t          i, *block_ids = NULL, step, ndatablocks;
+    gmx_bool             bOK;
+
+    gmx_tng_open(fn, 'r', &tng);
+    gmx_print_tng_molecule_system(tng, stdout);
+
+    bOK    = gmx_get_tng_data_block_types_of_next_frame(tng, -1,
+                                                        0,
+                                                        NULL,
+                                                        &step, &ndatablocks,
+                                                        &block_ids);
+    do
+    {
+        for (i = 0; i < ndatablocks; i++)
+        {
+            double               frame_time;
+            real                 prec, *values = NULL;
+            gmx_int64_t          n_values_per_frame, n_atoms;
+            char                 block_name[STRLEN];
+
+            gmx_get_tng_data_next_frame_of_block_type(tng, block_ids[i], &values,
+                                                      &step, &frame_time,
+                                                      &n_values_per_frame, &n_atoms,
+                                                      &prec,
+                                                      block_name, STRLEN, &bOK);
+            if (!bOK)
+            {
+                /* Can't write any output because we don't know what
+                   arrays are valid. */
+                fprintf(stderr, "\nWARNING: Incomplete frame at time %g, will not write output\n", frame_time);
+                list_tng_inner(fn, (0 == i), values, step, frame_time,
+                               n_values_per_frame, n_atoms, prec, nframe, block_name);
+            }
+        }
+        nframe++;
+    }
+    while (gmx_get_tng_data_block_types_of_next_frame(tng, step,
+                                                      0,
+                                                      NULL,
+                                                      &step,
+                                                      &ndatablocks,
+                                                      &block_ids));
+
+    if (block_ids)
+    {
+        sfree(block_ids);
+    }
+
+    gmx_tng_close(&tng);
+#endif
+}
+
 void list_trx(const char *fn)
 {
     int ftp;
@@ -363,7 +421,7 @@ void list_trx(const char *fn)
     }
     else if (ftp == efTNG)
     {
-        list_tng_for_gmx_dump(fn);
+        list_tng(fn);
     }
     else
     {
index 9476e4e57b22606f4054b55929a3171d827a0bee..08b7b77b73b2a67263c0bd6a720991d8433f7a6e 100644 (file)
@@ -51,21 +51,6 @@ extern "C" {
  */
 int gmx_dump(int argc, char *argv[]);
 
-/*! \brief Callback used by list_tng_for_gmx_dump.
- *
- * This keeps TNG-related stuff in a TNG-related file, and
- * dumping-related stuff in the dumping file. */
-void list_tng_inner(const char *fn,
-                    gmx_bool bFirstFrame,
-                    real *values,
-                    gmx_int64_t step, 
-                    double frame_time,
-                    gmx_int64_t n_values_per_frame,
-                    gmx_int64_t n_atoms,
-                    real prec,
-                    gmx_int64_t nframe,
-                    char *block_name);
-
 #ifdef __cplusplus
 }
 #endif