Cleaned up memory usage in gmx traj and trjconv
[gromacs.git] / src / gromacs / fileio / confio.h
blobbe8b299669a883d24c248c01f9bf0791eab27b63
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014,2015,2016,2017, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
37 #ifndef GMX_FILEIO_CONFIO_H
38 #define GMX_FILEIO_CONFIO_H
40 #include "gromacs/math/vectypes.h"
41 #include "gromacs/utility/basedefinitions.h"
43 /* For reading coordinate files it is assumed that enough memory
44 * has been allocated beforehand.
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
50 struct gmx_mtop_t;
51 struct t_atoms;
52 struct t_topology;
54 void write_sto_conf_indexed(const char *outfile, const char *title,
55 const t_atoms *atoms,
56 const rvec x[], const rvec *v, int ePBC, const matrix box,
57 int nindex, int index[]);
58 /* like write_sto_conf, but indexed */
60 void write_sto_conf(const char *outfile, const char *title,
61 const t_atoms *atoms,
62 const rvec x[], const rvec *v, int ePBC, const matrix box);
63 /* write atoms, x, v (if .gro and not NULL) and box (if not NULL)
64 * to an STO (.gro or .pdb) file */
66 void write_sto_conf_mtop(const char *outfile, const char *title,
67 struct gmx_mtop_t *mtop,
68 const rvec x[], const rvec *v, int ePBC, const matrix box);
69 /* As write_sto_conf, but uses a gmx_mtop_t struct */
71 /*! \brief Read a configuration and, when available, a topology from a tpr or structure file.
73 * When reading from a tpr file, the complete topology is returned in \p mtop.
74 * When reading from a structure file, only the atoms struct in \p mtop contains data.
76 * \param[in] infile Input file name
77 * \param[out] haveTopology true when a topology was read and stored in mtop
78 * \param[out] mtop The topology, either complete or only atom data
79 * \param[out] ePBC Enum reporting the type of PBC
80 * \param[in,out] x Coordinates will be stored when *x!=NULL
81 * \param[in,out] v Velocities will be stored when *v!=NULL
82 * \param[out] box Box dimensions
84 void readConfAndTopology(const char *infile,
85 bool *haveTopology, gmx_mtop_t *mtop,
86 int *ePBC,
87 rvec **x, rvec **v, matrix box);
89 /*! \brief Read a configuration and, when available, a topology from a tpr or structure file.
91 * Deprecated, superseded by readConfAndTopology().
92 * When \p requireMasses = TRUE, this routine must return a topology with
93 * mass data. Masses are either read from a tpr input file, or otherwise
94 * looked up from the mass database, and when such lookup fails a fatal error
95 * results.
96 * When \p requireMasses = FALSE, masses will still be read from tpr input and
97 * their presence is signaled with the \p haveMass flag in t_atoms of \p top.
99 * \param[in] infile Input file name
100 * \param[out] top The topology, either complete or only atom data. Caller is responsible for calling done_top().
101 * \param[out] ePBC Enum reporting the type of PBC
102 * \param[in,out] x Coordinates will be stored when *x!=NULL
103 * \param[in,out] v Velocities will be stored when *v!=NULL
104 * \param[out] box Box dimensions
105 * \param[in] requireMasses Require masses to be present, either from tpr or from the mass database
106 * \returns if a topology is available
108 gmx_bool read_tps_conf(const char *infile, struct t_topology *top,
109 int *ePBC, rvec **x, rvec **v, matrix box,
110 gmx_bool requireMasses);
112 #ifdef __cplusplus
114 #endif
116 #endif