/*
+ * This file is part of the GROMACS molecular simulation package.
*
- * This source code is part of
- *
- * G R O M A C S
- *
- * GROningen MAchine for Chemical Simulations
- *
- * VERSION 3.2.0
- * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * check out http://www.gromacs.org for more information.
-
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
+ * 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.
*
- * If you want to redistribute modifications, 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 www.gromacs.org.
+ * 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.
*
- * To help us fund GROMACS development, we humbly ask that you cite
- * the papers on the package - you can find them in the top README file.
+ * 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.
*
- * For more info, check our website at http://www.gromacs.org
+ * 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.
*
- * And Hey:
- * GROningen Mixture of Alchemy and Childrens' Stories
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "gmxpre.h"
+
+#include "gromacs/legacyheaders/readinp.h"
#include <stdio.h>
#include <stdlib.h>
-#include "typedefs.h"
-#include "string2.h"
-#include "gromacs/fileio/futil.h"
-#include "smalloc.h"
-#include "readinp.h"
-#include "macros.h"
-#include "statutil.h"
-#include "gromacs/fileio/gmxfio.h"
-#include "names.h"
-#include "warninp.h"
-#include "gmx_fatal.h"
-
-/* find an entry; return index, or -1 if not found */
-static int search_einp(int ninp, const t_inpfile *inp, const char *name);
+#include "gromacs/fileio/gmxfio.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/legacyheaders/warninp.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/smalloc.h"
t_inpfile *read_inpfile(const char *fn, int *ninp,
warninp_t wi)
fprintf(debug, "Reading MDP file %s\n", fn);
}
- in = ffopen(fn, "r");
+ in = gmx_ffopen(fn, "r");
nin = lc = 0;
do
inp[nin-1].count = 0;
inp[nin-1].bObsolete = FALSE;
inp[nin-1].bSet = FALSE;
- inp[nin-1].name = strdup(lbuf);
- inp[nin-1].value = strdup(rbuf);
+ inp[nin-1].name = gmx_strdup(lbuf);
+ inp[nin-1].value = gmx_strdup(rbuf);
}
else
{
{
/* override */
sfree(inp[found_index].value);
- inp[found_index].value = strdup(rbuf);
+ inp[found_index].value = gmx_strdup(rbuf);
sprintf(warn_buf,
"Overriding existing parameter \"%s\" with value \"%s\"\n",
lbuf, rbuf);
}
while (ptr);
- ffclose(in);
+ gmx_ffclose(in);
if (debug)
{
fprintf(stderr, "Replacing old mdp entry '%s' by '%s'\n",
inp[i].name, new_entry);
sfree(inp[i].name);
- inp[i].name = strdup(new_entry);
+ inp[i].name = gmx_strdup(new_entry);
}
else
{
}
}
-static int search_einp(int ninp, const t_inpfile *inp, const char *name)
+int search_einp(int ninp, const t_inpfile *inp, const char *name)
{
int i;
notfound = TRUE;
i = (*ninp)++;
srenew(*inp, (*ninp));
- (*inp)[i].name = strdup(name);
+ (*inp)[i].name = gmx_strdup(name);
(*inp)[i].bSet = TRUE;
}
(*inp)[i].count = (*inp)[0].inp_count++;
if (ii == -1)
{
sprintf(buf, "%d", def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
return def;
}
}
}
-gmx_large_int_t get_egmx_large_int(int *ninp, t_inpfile **inp,
- const char *name, gmx_large_int_t def,
- warninp_t wi)
+gmx_int64_t get_eint64(int *ninp, t_inpfile **inp,
+ const char *name, gmx_int64_t def,
+ warninp_t wi)
{
char buf[32], *ptr, warn_buf[STRLEN];
int ii;
- gmx_large_int_t ret;
+ gmx_int64_t ret;
ii = get_einp(ninp, inp, name);
if (ii == -1)
{
- sprintf(buf, gmx_large_int_pfmt, def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ sprintf(buf, "%"GMX_PRId64, def);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
return def;
}
else
{
- ret = str_to_large_int_t((*inp)[ii].value, &ptr);
+ ret = str_to_int64_t((*inp)[ii].value, &ptr);
if (ptr == (*inp)[ii].value)
{
sprintf(warn_buf, "Right hand side '%s' for parameter '%s' in parameter file is not an integer value\n", (*inp)[ii].value, (*inp)[ii].name);
if (ii == -1)
{
sprintf(buf, "%g", def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
return def;
}
if (def)
{
sprintf(buf, "%s", def);
- (*inp)[(*ninp)-1].value = strdup(buf);
+ (*inp)[(*ninp)-1].value = gmx_strdup(buf);
}
else
{
if (ii == -1)
{
- (*inp)[(*ninp)-1].value = strdup(defs[0]);
+ (*inp)[(*ninp)-1].value = gmx_strdup(defs[0]);
return 0;
}
fprintf(stderr, "%s\n", buf);
}
- (*inp)[ii].value = strdup(defs[0]);
+ (*inp)[ii].value = gmx_strdup(defs[0]);
return 0;
}