Move types/block.h to topology/
authorTeemu Murtola <teemu.murtola@gmail.com>
Fri, 23 May 2014 04:07:48 +0000 (07:07 +0300)
committerRoland Schulz <roland@rschulz.eu>
Sat, 24 May 2014 15:38:30 +0000 (17:38 +0200)
- Move t_block and t_blocka definitions to topology/.
- Move functions that operate only on these types from typedefs.[hc] to
  the same place.
- Include the new block.h from all source files that reference the
  functions.
- Clean up a few headers that were including types/block.h directly.
  Most other code still depends on getting the type definitions
  indirectly through typedefs.h, but that can be fixed during subsequent
  changes.

Change-Id: I458e9cdc00a8d81665630f8123589b64d123790a

22 files changed:
src/gromacs/fileio/tpxio.c
src/gromacs/gmxana/gmx_make_ndx.c
src/gromacs/gmxlib/index.c
src/gromacs/gmxlib/mtop_util.c
src/gromacs/gmxlib/typedefs.c
src/gromacs/gmxpreprocess/addconf.c
src/gromacs/gmxpreprocess/hizzie.c
src/gromacs/gmxpreprocess/pdb2gmx.c
src/gromacs/gmxpreprocess/readir.c
src/gromacs/gmxpreprocess/topio.c
src/gromacs/gmxpreprocess/toputil.c
src/gromacs/legacyheaders/index.h
src/gromacs/legacyheaders/typedefs.h
src/gromacs/legacyheaders/types/topology.h
src/gromacs/mdlib/clincs.c
src/gromacs/mdlib/constr.c
src/gromacs/selection/indexutil.cpp
src/gromacs/selection/tests/indexutil.cpp
src/gromacs/tools/check.c
src/gromacs/topology/CMakeLists.txt
src/gromacs/topology/block.cpp [new file with mode: 0644]
src/gromacs/topology/block.h [moved from src/gromacs/legacyheaders/types/block.h with 64% similarity]

index fe8e1abd5186a9bca55454c3932dddcf243360a1..90c07f0cfbde0c69e94277536469507ddb18b284 100644 (file)
@@ -56,6 +56,7 @@
 #include "mtop_util.h"
 
 #include "gromacs/math/vec.h"
+#include "gromacs/topology/block.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/fatalerror.h"
index ea91754d5177e429210f3ecdd31c6e2639aea14c..9e3d47739dc2b70e797d30b75f12450aff937ec1 100644 (file)
 
 #include "gromacs/utility/futil.h"
 #include "macros.h"
-#include "gromacs/utility/cstringutil.h"
-#include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/confio.h"
 #include "typedefs.h"
 #include "index.h"
-#include "gromacs/utility/smalloc.h"
 #include "gromacs/math/vec.h"
 #include "index.h"
 
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/topology/block.h"
+#include "gromacs/utility/cstringutil.h"
 #include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 #define MAXNAMES 30
 #define NAME_LEN 30
index 5557c157f52c7b2b1c1b9c19f96edd049d6ee937..27ec5550039a4d1c0d2a89b782a71bfbb33af969 100644 (file)
@@ -89,16 +89,6 @@ static gmx_bool gmx_ask_yesno(gmx_bool bASK)
     }
 }
 
-t_blocka *new_blocka(void)
-{
-    t_blocka *block;
-
-    snew(block, 1);
-    snew(block->index, 1);
-
-    return block;
-}
-
 void write_index(const char *outf, t_blocka *b, char **gnames, gmx_bool bDuplicate, int natoms)
 {
     FILE *out;
index 6da61759d0db8d6502b0d48e8984b126f5548cd8..04daeb5d19ef34233dc403584bab323f7496de86 100644 (file)
@@ -44,6 +44,7 @@
 #include "mtop_util.h"
 #include "topsort.h"
 
+#include "gromacs/topology/block.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
index ca9c44e7d2c3b0bb39adb9692deb93b946c31d53..3cad484e357361c318b4461860fe82a0164def4d 100644 (file)
@@ -49,6 +49,7 @@
 #include "gromacs/math/vec.h"
 #include "gromacs/pbcutil/pbc.h"
 #include "gromacs/random/random.h"
+#include "gromacs/topology/block.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/smalloc.h"
 
@@ -106,29 +107,6 @@ char *gmx_step_str(gmx_int64_t i, char *buf)
     return buf;
 }
 
-void init_block(t_block *block)
-{
-    int i;
-
-    block->nr           = 0;
-    block->nalloc_index = 1;
-    snew(block->index, block->nalloc_index);
-    block->index[0]     = 0;
-}
-
-void init_blocka(t_blocka *block)
-{
-    int i;
-
-    block->nr           = 0;
-    block->nra          = 0;
-    block->nalloc_index = 1;
-    snew(block->index, block->nalloc_index);
-    block->index[0]     = 0;
-    block->nalloc_a     = 0;
-    block->a            = NULL;
-}
-
 void init_atom(t_atoms *at)
 {
     int i;
@@ -203,91 +181,6 @@ void init_inputrec(t_inputrec *ir)
     snew(ir->simtempvals, 1);
 }
 
-void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup)
-{
-    int i;
-
-    if (bOneIndexGroup)
-    {
-        grp->nalloc_index = 2;
-        snew(grp->index, grp->nalloc_index);
-        grp->index[0] = 0;
-        grp->index[1] = natom;
-        grp->nr       = 1;
-    }
-    else
-    {
-        grp->nalloc_index = natom+1;
-        snew(grp->index, grp->nalloc_index);
-        snew(grp->index, natom+1);
-        for (i = 0; (i <= natom); i++)
-        {
-            grp->index[i] = i;
-        }
-        grp->nr = natom;
-    }
-}
-
-void stupid_fill_blocka(t_blocka *grp, int natom)
-{
-    int i;
-
-    grp->nalloc_a = natom;
-    snew(grp->a, grp->nalloc_a);
-    for (i = 0; (i < natom); i++)
-    {
-        grp->a[i] = i;
-    }
-    grp->nra = natom;
-
-    grp->nalloc_index = natom + 1;
-    snew(grp->index, grp->nalloc_index);
-    for (i = 0; (i <= natom); i++)
-    {
-        grp->index[i] = i;
-    }
-    grp->nr = natom;
-}
-
-void copy_blocka(const t_blocka *src, t_blocka *dest)
-{
-    int i;
-
-    dest->nr           = src->nr;
-    dest->nalloc_index = dest->nr + 1;
-    snew(dest->index, dest->nalloc_index);
-    for (i = 0; i < dest->nr+1; i++)
-    {
-        dest->index[i] = src->index[i];
-    }
-    dest->nra      = src->nra;
-    dest->nalloc_a = dest->nra + 1;
-    snew(dest->a, dest->nalloc_a);
-    for (i = 0; i < dest->nra+1; i++)
-    {
-        dest->a[i] = src->a[i];
-    }
-}
-
-void done_block(t_block *block)
-{
-    block->nr    = 0;
-    sfree(block->index);
-    block->nalloc_index = 0;
-}
-
-void done_blocka(t_blocka *block)
-{
-    block->nr    = 0;
-    block->nra   = 0;
-    sfree(block->index);
-    sfree(block->a);
-    block->index        = NULL;
-    block->a            = NULL;
-    block->nalloc_index = 0;
-    block->nalloc_a     = 0;
-}
-
 void done_atom (t_atoms *at)
 {
     at->nr       = 0;
index bbd3f4f6b1152f846eb44dcaba3a00f0ed75752c..cc0bf57893280fb33b50ca465e7c3728b8f05eda 100644 (file)
@@ -56,6 +56,7 @@
 #include "chargegroup.h"
 
 #include "gromacs/pbcutil/pbc.h"
+#include "gromacs/topology/block.h"
 #include "gromacs/utility/smalloc.h"
 
 static real box_margin;
index f623c842a8ad444a15fb0d6ccca6989ebc4b6a02..bf0d79965a19eb3c92f10c9debb86e842dc8ec93 100644 (file)
@@ -43,7 +43,6 @@
 #include <string.h>
 #include "typedefs.h"
 #include "gromacs/fileio/pdbio.h"
-#include "gromacs/utility/smalloc.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/math/units.h"
 #include "toputil.h"
@@ -51,7 +50,9 @@
 #include "gromacs/utility/cstringutil.h"
 #include "macros.h"
 
+#include "gromacs/topology/block.h"
 #include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
 
 static int in_strings(char *key, int nstr, const char **str)
 {
index c43237a0a44f7f2470d09652464a9feaa8cec008..4dd0bf28947ca807120237f3eb1c7287a5120cfc 100644 (file)
@@ -69,6 +69,7 @@
 
 #include "gromacs/commandline/pargs.h"
 #include "gromacs/fileio/strdb.h"
+#include "gromacs/topology/block.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/smalloc.h"
 #include "gromacs/utility/fatalerror.h"
index d11369f80089f11b7240e4acfbc667f8a9ee720f..87f57a27a60f7f78d0b7fcc12759aa0ef040b794 100644 (file)
@@ -61,6 +61,7 @@
 #include "inputrec.h"
 #include "calc_verletbuf.h"
 
+#include "gromacs/topology/block.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
index 65556a1a08cd70ee398f9ea9b530c52f724614b6..8ac7e65690e8c27a222c3afb9bb5f7d2b0e4a5fb 100644 (file)
@@ -58,6 +58,7 @@
 #include "macros.h"
 #include "names.h"
 #include "gromacs/utility/cstringutil.h"
+#include "gromacs/topology/block.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/fatalerror.h"
 #include "warninp.h"
index 5a8f9a2eaaac4ae15e362158c11770c18b2167fd..dced43b6835c03ba9e86eb50ef10a4f9c3e2087a 100644 (file)
@@ -46,6 +46,7 @@
 #include "toputil.h"
 #include "gpp_atomtype.h"
 
+#include "gromacs/topology/block.h"
 #include "gromacs/topology/symtab.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
index 8d449f1840abe38340de3ffb705b7a0fe0a3a838..731ffc7794ec17c670a7d9d7b88d68f095a76738 100644 (file)
 #include <stdio.h>
 
 #include "types/atoms.h"
-#include "types/block.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+struct t_blocka;
+
 void check_index(char *gname, int n, atom_id index[],
                  char *traj, int natoms);
 /* Checks if any index is smaller than zero or larger than natoms,
@@ -54,7 +55,7 @@ void check_index(char *gname, int n, atom_id index[],
  * and traj (if traj=NULL, "the trajectory" is used).
  */
 
-t_blocka *init_index(const char *gfile, char ***grpname);
+struct t_blocka *init_index(const char *gfile, char ***grpname);
 /* Lower level routine than the next */
 
 void rd_index(const char *statfile, int ngrps, int isize[],
@@ -86,10 +87,10 @@ void get_index(t_atoms *atoms, const char *fnm, int ngrps,
  */
 
 typedef struct {
-    int        maxframe;
-    char     **grpname;
-    t_blocka  *clust;
-    atom_id   *inv_clust;
+    int               maxframe;
+    char            **grpname;
+    struct t_blocka  *clust;
+    atom_id          *inv_clust;
 } t_cluster_ndx;
 
 t_cluster_ndx *cluster_index(FILE *fplog, const char *ndx);
@@ -142,16 +143,13 @@ gmx_residuetype_get_name(gmx_residuetype_t rt, int index);
 
 
 
-t_blocka *new_blocka(void);
-/* allocate new block */
-
-void write_index(const char *outf, t_blocka *b, char **gnames, gmx_bool bDuplicate, int natoms);
+void write_index(const char *outf, struct t_blocka *b, char **gnames, gmx_bool bDuplicate, int natoms);
 /* Writes index blocks to outf (writes an indexfile) */
 
-void add_grp(t_blocka *b, char ***gnames, int nra, atom_id a[], const char *name);
+void add_grp(struct t_blocka *b, char ***gnames, int nra, atom_id a[], const char *name);
 /* Ads group a with name name to block b and namelist gnames */
 
-void analyse(t_atoms *atoms, t_blocka *gb, char ***gn,
+void analyse(t_atoms *atoms, struct t_blocka *gb, char ***gn,
              gmx_bool bASK, gmx_bool bVerb);
 /* Makes index groups gb with names gn for atoms in atoms.
  * bASK=FALSE gives default groups.
index 58d6c68463f1ef582909b19f349a687be82d7dd9..b7566f13b2e7f39634adb8b22316c4f291fcf060 100644 (file)
@@ -46,7 +46,6 @@
 
 #include "types/simple.h"
 #include "types/enums.h"
-#include "types/block.h"
 #include "types/idef.h"
 #include "types/atoms.h"
 #include "../fileio/trx.h"
@@ -122,8 +121,6 @@ char *gmx_step_str(gmx_int64_t i, char *buf);
 /* Functions to initiate and delete structures *
  * These functions are defined in gmxlib/typedefs.c
  */
-void init_block(t_block *block);
-void init_blocka(t_blocka *block);
 void init_atom (t_atoms *at);
 void init_mtop(gmx_mtop_t *mtop);
 void init_top(t_topology *top);
@@ -136,11 +133,6 @@ t_state *serial_init_local_state(t_state *state_global);
 void init_df_history(df_history_t *dfhist, int nlambda);
 void done_df_history(df_history_t *dfhist);
 void copy_df_history(df_history_t * df_dest, df_history_t *df_source);
-
-void copy_blocka(const t_blocka *src, t_blocka *dest);
-
-void done_block(t_block *block);
-void done_blocka(t_blocka *block);
 void done_atom (t_atoms *at);
 void done_moltype(gmx_moltype_t *molt);
 void done_molblock(gmx_molblock_t *molb);
@@ -155,19 +147,6 @@ void set_box_rel(t_inputrec *ir, t_state *state);
 void preserve_box_shape(t_inputrec *ir, matrix box_rel, matrix b);
 /* Preserve the box shape, b can be box or boxv */
 
-void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup);
-/* Fill a block structure with numbers identical to the index
- * (0, 1, 2, .. natom-1)
- * If bOneIndexGroup, then all atoms are  lumped in one index group,
- * otherwise there is one atom per index entry
- */
-
-void stupid_fill_blocka(t_blocka *grp, int natom);
-/* Fill a block structure with numbers identical to the index
- * (0, 1, 2, .. natom-1)
- * There is one atom per index entry
- */
-
 void init_t_atoms(t_atoms *atoms, int natoms, gmx_bool bPdbinfo);
 /* allocate memory for the arrays, set nr to natoms and nres to 0
  * set pdbinfo to NULL or allocate memory for it */
index 95fb9b275a114d862b15d7de4fe558d0714cee3e..861ca360e292aa686d4ca77f26ffc3b9df8102c5 100644 (file)
@@ -39,8 +39,8 @@
 
 #include "atoms.h"
 #include "idef.h"
-#include "block.h"
 #include "simple.h"
+#include "../../topology/block.h"
 #include "../../topology/symtab.h"
 
 #ifdef __cplusplus
index d1af4022249cf6d8598dec5454d74812dd2aafd5..92b684cc2bd998895cfc70d37cd1efcd9ff94ccf 100644 (file)
@@ -55,6 +55,7 @@
 #include "gmx_omp_nthreads.h"
 
 #include "gromacs/fileio/gmxfio.h"
+#include "gromacs/topology/block.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/gmxomp.h"
 #include "gromacs/utility/smalloc.h"
index e30c143420274aa20376134867ddeaa52450fbf0..e52a5b28e6c4a86b563bbc479df2f46dfb30d941 100644 (file)
@@ -62,6 +62,7 @@
 #include "gromacs/pulling/pull.h"
 
 #include "gromacs/pbcutil/pbc.h"
+#include "gromacs/topology/block.h"
 #include "gromacs/utility/fatalerror.h"
 
 typedef struct gmx_constr {
index 061c08bc246122752b0688308144082709998b35..3874cc8a5cd2761f573c27d1d8399006bcd51fe2 100644 (file)
@@ -48,8 +48,8 @@
 #include <vector>
 
 #include "gromacs/legacyheaders/index.h"
-#include "gromacs/legacyheaders/typedefs.h"
 
+#include "gromacs/topology/block.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/smalloc.h"
 
index 8dd46bfcbf782571fff69ac929fa557be3f428a5..e1c4edec0a82227516050571e0c9594c5ecbaf47 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 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.
@@ -44,9 +44,8 @@
  */
 #include <gtest/gtest.h>
 
-#include "gromacs/legacyheaders/typedefs.h"
-
 #include "gromacs/selection/indexutil.h"
+#include "gromacs/topology/block.h"
 
 #include "testutils/refdata.h"
 
index 17e461d352309243c9e4e604a4cef0153a78d942..59f5ff21e9d4f47d62ca654f42ed0dfc89738e45 100644 (file)
@@ -62,6 +62,7 @@
 #include "gromacs/fileio/enxio.h"
 #include "gromacs/fileio/tpxio.h"
 #include "gromacs/fileio/trxio.h"
+#include "gromacs/topology/block.h"
 
 #include "compare.h"
 
index fc15abe96d41c352b27110f1487eac2eb2c5bb0e..fb7f0496ba4cc595047cb9167597cf1befc81599 100644 (file)
@@ -36,6 +36,7 @@ file(GLOB TOPOLOGY_SOURCES *.cpp *.c)
 set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${TOPOLOGY_SOURCES} PARENT_SCOPE)
 
 set(TOPOLOGY_PUBLIC_HEADERS
+    block.h
     symtab.h)
 
 gmx_install_headers(topology ${TOPOLOGY_PUBLIC_HEADERS})
diff --git a/src/gromacs/topology/block.cpp b/src/gromacs/topology/block.cpp
new file mode 100644 (file)
index 0000000..2785465
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,2014, 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.
+ */
+#include "gromacs/topology/block.h"
+
+#include "gromacs/utility/smalloc.h"
+
+void init_block(t_block *block)
+{
+    block->nr           = 0;
+    block->nalloc_index = 1;
+    snew(block->index, block->nalloc_index);
+    block->index[0]     = 0;
+}
+
+void init_blocka(t_blocka *block)
+{
+    block->nr           = 0;
+    block->nra          = 0;
+    block->nalloc_index = 1;
+    snew(block->index, block->nalloc_index);
+    block->index[0]     = 0;
+    block->nalloc_a     = 0;
+    block->a            = NULL;
+}
+
+t_blocka *new_blocka(void)
+{
+    t_blocka *block;
+
+    snew(block, 1);
+    snew(block->index, 1);
+
+    return block;
+}
+
+void done_block(t_block *block)
+{
+    block->nr    = 0;
+    sfree(block->index);
+    block->nalloc_index = 0;
+}
+
+void done_blocka(t_blocka *block)
+{
+    block->nr    = 0;
+    block->nra   = 0;
+    sfree(block->index);
+    sfree(block->a);
+    block->index        = NULL;
+    block->a            = NULL;
+    block->nalloc_index = 0;
+    block->nalloc_a     = 0;
+}
+
+void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup)
+{
+    if (bOneIndexGroup)
+    {
+        grp->nalloc_index = 2;
+        snew(grp->index, grp->nalloc_index);
+        grp->index[0] = 0;
+        grp->index[1] = natom;
+        grp->nr       = 1;
+    }
+    else
+    {
+        grp->nalloc_index = natom+1;
+        snew(grp->index, grp->nalloc_index);
+        snew(grp->index, natom+1);
+        for (int i = 0; i <= natom; ++i)
+        {
+            grp->index[i] = i;
+        }
+        grp->nr = natom;
+    }
+}
+
+void stupid_fill_blocka(t_blocka *grp, int natom)
+{
+    grp->nalloc_a = natom;
+    snew(grp->a, grp->nalloc_a);
+    for (int i = 0; i < natom; ++i)
+    {
+        grp->a[i] = i;
+    }
+    grp->nra = natom;
+
+    grp->nalloc_index = natom + 1;
+    snew(grp->index, grp->nalloc_index);
+    for (int i = 0; i <= natom; ++i)
+    {
+        grp->index[i] = i;
+    }
+    grp->nr = natom;
+}
+
+void copy_blocka(const t_blocka *src, t_blocka *dest)
+{
+    dest->nr           = src->nr;
+    dest->nalloc_index = dest->nr + 1;
+    snew(dest->index, dest->nalloc_index);
+    for (int i = 0; i < dest->nr+1; ++i)
+    {
+        dest->index[i] = src->index[i];
+    }
+    dest->nra      = src->nra;
+    dest->nalloc_a = dest->nra + 1;
+    snew(dest->a, dest->nalloc_a);
+    for (int i = 0; i < dest->nra+1; ++i)
+    {
+        dest->a[i] = src->a[i];
+    }
+}
similarity index 64%
rename from src/gromacs/legacyheaders/types/block.h
rename to src/gromacs/topology/block.h
index 0a753e2d84ac0572bc92dad27603238e6cca1213..599a4bd901157e2f5825c914a3ce274219c7f539 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014, 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.
  * To help us fund GROMACS development, we humbly ask that you cite
  * the research papers on the package. Check out http://www.gromacs.org.
  */
-#ifndef _block_h
-#define _block_h
+#ifndef GMX_TOPOLOGY_BLOCK_H
+#define GMX_TOPOLOGY_BLOCK_H
 
-
-#include "idef.h"
+#include "../legacyheaders/types/simple.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -52,26 +51,50 @@ extern "C" {
 
    This makes the mapping from atoms to molecules O(Nmolecules) instead
    of O(Natoms) in size.  */
-typedef struct {
-    int      nr;           /* The number of blocks                     */
+typedef struct t_block
+{
+    int      nr;           /* The number of blocks          */
     atom_id *index;        /* Array of indices (dim: nr+1)  */
-    int      nalloc_index; /* The allocation size for index        */
+    int      nalloc_index; /* The allocation size for index */
 } t_block;
 
-typedef struct {
-    int      nr;    /* The number of blocks                    */
-    atom_id *index; /* Array of indices in a (dim: nr+1)       */
-    int      nra;   /* The number of atoms          */
+typedef struct t_blocka
+{
+    int      nr;    /* The number of blocks              */
+    atom_id *index; /* Array of indices in a (dim: nr+1) */
+    int      nra;   /* The number of atoms               */
     atom_id *a;     /* Array of atom numbers in each group  */
-    /* (dim: nra)                              */
-    /* Block i (0<=i<nr) runs from             */
+    /* (dim: nra)                           */
+    /* Block i (0<=i<nr) runs from          */
     /* index[i] to index[i+1]-1. There will */
-    /* allways be an extra entry in index      */
-    /* to terminate the table          */
+    /* allways be an extra entry in index   */
+    /* to terminate the table               */
     int nalloc_index;           /* The allocation size for index        */
     int nalloc_a;               /* The allocation size for a            */
 } t_blocka;
 
+void init_block(t_block *block);
+void init_blocka(t_blocka *block);
+t_blocka *new_blocka(void);
+/* allocate new block */
+
+void done_block(t_block *block);
+void done_blocka(t_blocka *block);
+
+void copy_blocka(const t_blocka *src, t_blocka *dest);
+
+void stupid_fill_block(t_block *grp, int natom, gmx_bool bOneIndexGroup);
+/* Fill a block structure with numbers identical to the index
+ * (0, 1, 2, .. natom-1)
+ * If bOneIndexGroup, then all atoms are  lumped in one index group,
+ * otherwise there is one atom per index entry
+ */
+
+void stupid_fill_blocka(t_blocka *grp, int natom);
+/* Fill a block structure with numbers identical to the index
+ * (0, 1, 2, .. natom-1)
+ * There is one atom per index entry
+ */
 
 #ifdef __cplusplus
 }