* 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"
/* This file is completely threadsafe - keep it that way! */
-#include <ctype.h>
-#include "sysstuff.h"
-#include "smalloc.h"
-#include "string2.h"
-#include "gmx_fatal.h"
-#include "macros.h"
-#include "names.h"
-#include "symtab.h"
-#include "futil.h"
+#include <stdlib.h>
+#include <string.h>
+
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/names.h"
+#include "gromacs/utility/futil.h"
#include "filenm.h"
#include "gmxfio.h"
#include "tpxio.h"
-#include "txtdump.h"
+#include "gromacs/legacyheaders/txtdump.h"
#include "confio.h"
-#include "atomprop.h"
-#include "copyrite.h"
-#include "vec.h"
-#include "mtop_util.h"
+#include "gromacs/legacyheaders/copyrite.h"
+
+#include "gromacs/math/vec.h"
+#include "gromacs/topology/atomprop.h"
+#include "gromacs/topology/block.h"
+#include "gromacs/topology/mtop_util.h"
+#include "gromacs/topology/symtab.h"
+#include "gromacs/topology/topology.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
#define TPX_TAG_RELEASE "release"
* below that does the right thing according to the value of
* file_version. */
enum tpxv {
- tpxv_ComputationalElectrophysiology = 96, /**< support for ion/water position swaps (computational electrophysiology) */
- tpxv_Use64BitRandomSeed /**< change ld_seed from int to gmx_int64_t */
+ tpxv_ComputationalElectrophysiology = 96, /**< support for ion/water position swaps (computational electrophysiology) */
+ tpxv_Use64BitRandomSeed, /**< change ld_seed from int to gmx_int64_t */
+ tpxv_RestrictedBendingAndCombinedAngleTorsionPotentials, /**< potentials for supporting coarse-grained force fields */
+ tpxv_InteractiveMolecularDynamics, /**< interactive molecular dynamics (IMD) */
+ tpxv_RemoveObsoleteParameters1 /**< remove optimize_fft, dihre_fc, nstcheckpoint */
};
/*! \brief Version number of the file format written to run input
*
* When developing a feature branch that needs to change the run input
* file format, change tpx_tag instead. */
-static const int tpx_version = tpxv_Use64BitRandomSeed;
+static const int tpx_version = tpxv_RemoveObsoleteParameters1;
/* This number should only be increased when you edit the TOPOLOGY section
* It first appeared in tpx version 26, when I also moved the inputrecord
* to the end of the tpx file, so we can just skip it if we only
* want the topology.
+ *
+ * In particular, it must be increased when adding new elements to
+ * ftupd, so that old code can read new .tpr files.
*/
-static const int tpx_generation = 25;
+static const int tpx_generation = 26;
/* This number should be the most recent backwards incompatible version
* I.e., if this number is 9, we cannot read tpx version 9 with this code.
{ 43, F_TABBONDS },
{ 43, F_TABBONDSNC },
{ 70, F_RESTRBONDS },
+ { tpxv_RestrictedBendingAndCombinedAngleTorsionPotentials, F_RESTRANGLES },
{ 76, F_LINEAR_ANGLES },
{ 30, F_CROSS_BOND_BONDS },
{ 30, F_CROSS_BOND_ANGLES },
{ 30, F_UREY_BRADLEY },
{ 34, F_QUARTIC_ANGLES },
{ 43, F_TABANGLES },
+ { tpxv_RestrictedBendingAndCombinedAngleTorsionPotentials, F_RESTRDIHS },
+ { tpxv_RestrictedBendingAndCombinedAngleTorsionPotentials, F_CBTDIHS },
{ 26, F_FOURDIHS },
{ 26, F_PIDIHS },
{ 43, F_TABDIHS },
}
}
+static void do_imd(t_fileio *fio, t_IMD *imd, gmx_bool bRead)
+{
+ gmx_fio_do_int(fio, imd->nat);
+ if (bRead)
+ {
+ snew(imd->ind, imd->nat);
+ }
+ gmx_fio_ndo_int(fio, imd->ind, imd->nat);
+}
+
static void do_fepvals(t_fileio *fio, t_lambda *fepvals, gmx_bool bRead, int file_version)
{
/* i is defined in the ndo_double macro; use g to iterate. */
}
if (file_version >= 79)
{
- gmx_fio_do_int(fio, fepvals->bPrintEnergy);
+ gmx_fio_do_int(fio, fepvals->edHdLPrintEnergy);
}
else
{
- fepvals->bPrintEnergy = FALSE;
+ fepvals->edHdLPrintEnergy = edHdLPrintEnergyNO;
}
/* handle lambda_neighbors */
int i, j, k, *tmp, idum = 0;
real rdum, bd_temp;
rvec vdum;
- gmx_bool bSimAnn;
+ gmx_bool bSimAnn, bdum = 0;
real zerotemptime, finish_t, init_temp, finish_temp;
if (file_version != tpx_version)
gmx_fio_do_int(fio, idum);
ir->nsteps = idum;
}
+
if (file_version > 25)
{
if (file_version >= 62)
}
gmx_fio_do_int(fio, ir->ns_type);
gmx_fio_do_int(fio, ir->nstlist);
- gmx_fio_do_int(fio, ir->ndelta);
+ gmx_fio_do_int(fio, idum); /* used to be ndelta; not used anymore */
if (file_version < 41)
{
gmx_fio_do_int(fio, idum);
}
ir->nstcomm = abs(ir->nstcomm);
- if (file_version > 25)
- {
- gmx_fio_do_int(fio, ir->nstcheckpoint);
- }
- else
+ /* ignore nstcheckpoint */
+ if (file_version > 25 && file_version < tpxv_RemoveObsoleteParameters1)
{
- ir->nstcheckpoint = 0;
+ gmx_fio_do_int(fio, idum);
}
gmx_fio_do_int(fio, ir->nstcgsteep);
gmx_fio_do_real(fio, ir->epsilon_surface);
}
- gmx_fio_do_gmx_bool(fio, ir->bOptFFT);
+ /* ignore bOptFFT */
+ if (file_version < tpxv_RemoveObsoleteParameters1)
+ {
+ gmx_fio_do_gmx_bool(fio, bdum);
+ }
if (file_version >= 93)
{
ir->orires_tau = 0;
ir->nstorireout = 0;
}
+
+ /* ignore dihre_fc */
if (file_version >= 26 && file_version < 79)
{
- gmx_fio_do_real(fio, ir->dihre_fc);
+ gmx_fio_do_real(fio, rdum);
if (file_version < 56)
{
gmx_fio_do_real(fio, rdum);
gmx_fio_do_int(fio, idum);
}
}
- else
- {
- ir->dihre_fc = 0;
- }
gmx_fio_do_real(fio, ir->em_stepsize);
gmx_fio_do_real(fio, ir->em_tol);
ir->bRot = FALSE;
}
+ /* Interactive molecular dynamics */
+ if (file_version >= tpxv_InteractiveMolecularDynamics)
+ {
+ gmx_fio_do_int(fio, ir->bIMD);
+ if (TRUE == ir->bIMD)
+ {
+ if (bRead)
+ {
+ snew(ir->imd, 1);
+ }
+ do_imd(fio, ir->imd, bRead);
+ }
+ }
+ else
+ {
+ /* We don't support IMD sessions for old .tpr files */
+ ir->bIMD = FALSE;
+ }
+
/* grpopts stuff */
gmx_fio_do_int(fio, ir->opts.ngtc);
if (file_version >= 69)
iparams->pdihs.cpB = iparams->pdihs.cpA;
}
break;
+ case F_RESTRANGLES:
+ gmx_fio_do_real(fio, iparams->harmonic.rA);
+ gmx_fio_do_real(fio, iparams->harmonic.krA);
+ break;
case F_LINEAR_ANGLES:
gmx_fio_do_real(fio, iparams->linangle.klinA);
gmx_fio_do_real(fio, iparams->linangle.aA);
gmx_fio_do_real(fio, iparams->fene.bm);
gmx_fio_do_real(fio, iparams->fene.kb);
break;
+
case F_RESTRBONDS:
gmx_fio_do_real(fio, iparams->restraint.lowA);
gmx_fio_do_real(fio, iparams->restraint.up1A);
gmx_fio_do_int(fio, iparams->pdihs.mult);
}
break;
+ case F_RESTRDIHS:
+ gmx_fio_do_real(fio, iparams->pdihs.phiA);
+ gmx_fio_do_real(fio, iparams->pdihs.cpA);
+ break;
case F_DISRES:
gmx_fio_do_int(fio, iparams->disres.label);
gmx_fio_do_int(fio, iparams->disres.type);
gmx_fio_do_real(fio, iparams->fbposres.r);
gmx_fio_do_real(fio, iparams->fbposres.k);
break;
+ case F_CBTDIHS:
+ gmx_fio_ndo_real(fio, iparams->cbtdihs.cbtcA, NR_CBTDIHS);
+ break;
case F_RBDIHS:
gmx_fio_ndo_real(fio, iparams->rbdihs.rbcA, NR_RBDIHS);
if (file_version >= 25)
gmx_fio_ndo_int(fio, block->a, block->nra);
}
+/* This is a primitive routine to make it possible to translate atomic numbers
+ * to element names when reading TPR files, without making the Gromacs library
+ * directory a dependency on mdrun (which is the case if we need elements.dat).
+ */
+static const char *
+atomicnumber_to_element(int atomicnumber)
+{
+ const char * p;
+
+ /* This does not have to be complete, so we only include elements likely
+ * to occur in PDB files.
+ */
+ switch (atomicnumber)
+ {
+ case 1: p = "H"; break;
+ case 5: p = "B"; break;
+ case 6: p = "C"; break;
+ case 7: p = "N"; break;
+ case 8: p = "O"; break;
+ case 9: p = "F"; break;
+ case 11: p = "Na"; break;
+ case 12: p = "Mg"; break;
+ case 15: p = "P"; break;
+ case 16: p = "S"; break;
+ case 17: p = "Cl"; break;
+ case 18: p = "Ar"; break;
+ case 19: p = "K"; break;
+ case 20: p = "Ca"; break;
+ case 25: p = "Mn"; break;
+ case 26: p = "Fe"; break;
+ case 28: p = "Ni"; break;
+ case 29: p = "Cu"; break;
+ case 30: p = "Zn"; break;
+ case 35: p = "Br"; break;
+ case 47: p = "Ag"; break;
+ default: p = ""; break;
+ }
+ return p;
+}
+
+
static void do_atom(t_fileio *fio, t_atom *atom, int ngrp, gmx_bool bRead,
int file_version, gmx_groups_t *groups, int atnr)
{
- int i, myngrp;
+ int i, myngrp;
+ char * p_elem;
gmx_fio_do_real(fio, atom->m);
gmx_fio_do_real(fio, atom->q);
if (file_version >= 52)
{
gmx_fio_do_int(fio, atom->atomnumber);
+ if (bRead)
+ {
+ /* Set element string from atomic number if present.
+ * This routine returns an empty string if the name is not found.
+ */
+ strncpy(atom->elem, atomicnumber_to_element(atom->atomnumber), 4);
+ /* avoid warnings about potentially unterminated string */
+ atom->elem[3] = '\0';
+ }
}
else if (bRead)
{
for (i = 0; (i < nr); i++)
{
gmx_fio_do_string(fio, buf);
- symbuf->buf[i] = strdup(buf);
+ symbuf->buf[i] = gmx_strdup(buf);
}
}
else
static void do_mtop(t_fileio *fio, gmx_mtop_t *mtop, gmx_bool bRead,
int file_version)
{
- int mt, mb, i;
- t_blocka dumb;
+ int mt, mb, i;
+ t_blocka dumb;
if (bRead)
{