*
* 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
+ * Copyright (c) 2013,2014,2015, 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.
{
FILE *in;
char **ptr;
- char buf[256];
+ char buf[STRLEN];
int i, nstr;
in = libopen(db);
snew(ptr, nstr);
for (i = 0; (i < nstr); i++)
{
- if (1 != fscanf(in, "%s", buf))
+ if (NULL == fgets2(buf, STRLEN, in))
{
gmx_fatal(FARGS, "Cannot read string from buffer");
}
int i, nstr;
char *pret;
- pret = fgets(buf, STRLEN-1, in);
+ pret = fgets(buf, STRLEN, in);
if (pret == NULL || sscanf(buf, "%d", &nstr) != 1)
{
gmx_warning("File is empty");
snew(ptr, nstr);
for (i = 0; (i < nstr); i++)
{
- fgets2(buf, STRLEN-1, in);
+ fgets2(buf, STRLEN, in);
ptr[i] = gmx_strdup(buf);
}
)
{
int mdof_flags;
+ rvec *x_for_confout = NULL;
mdof_flags = 0;
if (do_per_step(step, ir->nstxout))
bDoConfOut && MASTER(cr) &&
!bRerunMD)
{
+ if (fr->bMolPBC && state->x == state_global->x)
+ {
+ /* This (single-rank) run needs to allocate a
+ temporary array of size natoms so that any
+ periodicity removal for mdrun -confout does not
+ perturb the update and thus the final .edr
+ output. This makes .cpt restarts look binary
+ identical, and makes .edr restarts binary
+ identical. */
+ snew(x_for_confout, state_global->natoms);
+ copy_rvecn(state_global->x, x_for_confout, 0, state_global->natoms);
+ }
+ else
+ {
+ /* With DD, or no bMolPBC, it doesn't matter if
+ we change state_global->x */
+ x_for_confout = state_global->x;
+ }
+
/* x and v have been collected in mdoutf_write_to_trajectory_files,
* because a checkpoint file will always be written
* at the last step.
if (fr->bMolPBC)
{
/* Make molecules whole only for confout writing */
- do_pbc_mtop(fplog, ir->ePBC, state->box, top_global, state_global->x);
+ do_pbc_mtop(fplog, ir->ePBC, state->box, top_global, x_for_confout);
}
write_sto_conf_mtop(ftp2fn(efSTO, nfile, fnm),
*top_global->name, top_global,
- state_global->x, state_global->v,
+ x_for_confout, state_global->v,
ir->ePBC, state->box);
+ if (fr->bMolPBC && state->x == state_global->x)
+ {
+ sfree(x_for_confout);
+ }
debug_gmx();
}
wallcycle_stop(mdoutf_get_wcycle(outf), ewcTRAJ);
int *steps;
int *points;
enerdat_t *s;
+ gmx_bool bHaveSums;
} enerdata_t;
static double mypow(double x, double y)
{
ed = &edat->s[i];
ed->bExactStat = FALSE;
- if (edat->npoints > 0)
+ if (edat->bHaveSums)
{
/* All energy file sum entries 0 signals no exact sums.
* But if all energy values are 0, we still have exact sums.
esum = calc_sum(nset, edat, nbmin, nbmax);
}
- if (edat->npoints == 0)
+ if (!edat->bHaveSums)
{
nexact = 0;
nnotexact = nset;
}
/* Initiate energies and set them to zero */
- edat.nsteps = 0;
- edat.npoints = 0;
- edat.nframes = 0;
- edat.step = NULL;
- edat.steps = NULL;
- edat.points = NULL;
+ edat.nsteps = 0;
+ edat.npoints = 0;
+ edat.nframes = 0;
+ edat.step = NULL;
+ edat.steps = NULL;
+ edat.points = NULL;
+ edat.bHaveSums = TRUE;
snew(edat.s, nset);
/* Initiate counters */
else
{
edat.steps[nfr] = fr->nsteps;
+
+ if (fr->nsum <= 1)
{
- if (fr->step - start_step + 1 == edat.nsteps + fr->nsteps)
+ /* mdrun only calculated the energy at energy output
+ * steps. We don't need to check step intervals.
+ */
+ edat.points[nfr] = 1;
+ for (i = 0; i < nset; i++)
{
- if (fr->nsum <= 1)
- {
- edat.points[nfr] = 1;
- for (i = 0; i < nset; i++)
- {
- sss = set[i];
- edat.s[i].es[nfr].sum = fr->ener[sss].e;
- edat.s[i].es[nfr].sum2 = 0;
- }
- edat.npoints += 1;
- }
- else
- {
- edat.points[nfr] = fr->nsum;
- for (i = 0; i < nset; i++)
- {
- sss = set[i];
- edat.s[i].es[nfr].sum = fr->ener[sss].esum;
- edat.s[i].es[nfr].sum2 = fr->ener[sss].eav;
- }
- edat.npoints += fr->nsum;
- }
+ sss = set[i];
+ edat.s[i].es[nfr].sum = fr->ener[sss].e;
+ edat.s[i].es[nfr].sum2 = 0;
}
- else
+ edat.npoints += 1;
+ edat.bHaveSums = FALSE;
+ }
+ else if (fr->step - start_step + 1 == edat.nsteps + fr->nsteps)
+ {
+ /* We have statistics to the previous frame */
+ edat.points[nfr] = fr->nsum;
+ for (i = 0; i < nset; i++)
{
- /* The interval does not match fr->nsteps:
- * can not do exact averages.
- */
- edat.npoints = 0;
+ sss = set[i];
+ edat.s[i].es[nfr].sum = fr->ener[sss].esum;
+ edat.s[i].es[nfr].sum2 = fr->ener[sss].eav;
}
- edat.nsteps = fr->step - start_step + 1;
+ edat.npoints += fr->nsum;
}
+ else
+ {
+ /* The interval does not match fr->nsteps:
+ * can not do exact averages.
+ */
+ edat.bHaveSums = FALSE;
+ }
+
+ edat.nsteps = fr->step - start_step + 1;
}
for (i = 0; i < nset; i++)
{
flags_enh = 0;
if (state->enerhist.nsum > 0 || state->enerhist.nsum_sim > 0)
{
- flags_enh |= (1<<eenhENERGY_N);
+ flags_enh |= (1<<eenhENERGY_N) | (1<<eenhENERGY_NSTEPS) | (1<<eenhENERGY_NSTEPS_SIM);
if (state->enerhist.nsum > 0)
{
flags_enh |= ((1<<eenhENERGY_AVER) | (1<<eenhENERGY_SUM) |
- (1<<eenhENERGY_NSTEPS) | (1<<eenhENERGY_NSUM));
+ (1<<eenhENERGY_NSUM));
}
if (state->enerhist.nsum_sim > 0)
{
- flags_enh |= ((1<<eenhENERGY_SUM_SIM) | (1<<eenhENERGY_NSTEPS_SIM) |
- (1<<eenhENERGY_NSUM_SIM));
+ flags_enh |= ((1<<eenhENERGY_SUM_SIM) | (1<<eenhENERGY_NSUM_SIM));
}
if (state->enerhist.dht)
{
&ls, &n_nonlin_vsite, &rlist_1x1);
/* Set the pair-list buffer size in ir */
- verletbuf_get_list_setup(FALSE, &ls);
+ verletbuf_get_list_setup(FALSE, FALSE, &ls);
calc_verlet_buffer_size(mtop, det(box), ir, buffer_temp,
&ls, &n_nonlin_vsite, &ir->rlist);
ls.cluster_size_i, ls.cluster_size_j,
ir->rlist, ir->rlist-max(ir->rvdw, ir->rcoulomb));
+ printf("Note that mdrun will redetermine rlist based on the actual pair-list setup\n");
+
if (sqr(ir->rlistlong) >= max_cutoff2(ir->ePBC, box))
{
gmx_fatal(FARGS, "The pair-list cut-off (%g nm) is longer than half the shortest box vector or longer than the smallest box diagonal element (%g nm). Increase the box size or decrease nstlist or increase verlet-buffer-tolerance.", ir->rlistlong, sqrt(max_cutoff2(ir->ePBC, box)));
#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/nbnxn_consts.h"
+#include "gromacs/mdlib/nbnxn_simd.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
int n; /* #atoms of this type in the system */
} verletbuf_atomtype_t;
-void verletbuf_get_list_setup(gmx_bool bGPU,
+void verletbuf_get_list_setup(gmx_bool gmx_unused bSIMD,
+ gmx_bool bGPU,
verletbuf_list_setup_t *list_setup)
{
- list_setup->cluster_size_i = NBNXN_CPU_CLUSTER_I_SIZE;
-
if (bGPU)
{
- list_setup->cluster_size_j = NBNXN_GPU_CLUSTER_SIZE;
+ list_setup->cluster_size_i = NBNXN_GPU_CLUSTER_SIZE;
+ list_setup->cluster_size_j = NBNXN_GPU_CLUSTER_SIZE;
}
else
{
-#ifndef GMX_NBNXN_SIMD
- list_setup->cluster_size_j = NBNXN_CPU_CLUSTER_I_SIZE;
-#else
- list_setup->cluster_size_j = GMX_SIMD_REAL_WIDTH;
+ list_setup->cluster_size_i = NBNXN_CPU_CLUSTER_I_SIZE;
+ list_setup->cluster_size_j = NBNXN_CPU_CLUSTER_I_SIZE;
+#ifdef GMX_NBNXN_SIMD
+ if (bSIMD)
+ {
+ list_setup->cluster_size_j = GMX_SIMD_REAL_WIDTH;
#ifdef GMX_NBNXN_SIMD_2XNN
- /* We assume the smallest cluster size to be on the safe side */
- list_setup->cluster_size_j /= 2;
+ /* We assume the smallest cluster size to be on the safe side */
+ list_setup->cluster_size_j /= 2;
#endif
+ }
#endif
}
}
/* Sets the pair-list setup assumed for the current Gromacs configuration.
* The setup with smallest cluster sizes is return, such that the Verlet
* buffer size estimated with this setup will be conservative.
+ * bSIMD tells if to take into account SIMD, when supported.
+ * bGPU tells to estimate for GPU kernels (bSIMD is ignored with bGPU=TRUE)
*/
-void verletbuf_get_list_setup(gmx_bool bGPU,
+void verletbuf_get_list_setup(gmx_bool bSIMD,
+ gmx_bool bGPU,
verletbuf_list_setup_t *list_setup);
*
* 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
+ * Copyright (c) 2013,2014,2015, 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.
/*! \brief
* Reads a line from a stream.
*
- * This routine reads a string from stream of max length n
- * and zero terminated, without newlines.
- * \p s should be long enough (>= \p n)
+ * This routine reads a string from stream of max length n, including
+ * \0 and zero terminated, without newlines. \p s should be long
+ * enough (>= \p n)
*/
char *fgets2(char *s, int n, FILE *stream);
nstfep = gmx_greatest_common_divisor(repl_ex_nst, nstfep);
}
- /* I'm assuming we need global communication the first time! MRS */
+ /* Be REALLY careful about what flags you set here. You CANNOT assume
+ * this is the first step, since we might be restarting from a checkpoint,
+ * and in that case we should not do any modifications to the state.
+ */
+ bStopCM = (ir->comm_mode != ecmNO && !ir->bContinuation);
+
cglo_flags = (CGLO_TEMPERATURE | CGLO_GSTAT
- | ((ir->comm_mode != ecmNO) ? CGLO_STOPCM : 0)
+ | (bStopCM ? CGLO_STOPCM : 0)
| (bVV ? CGLO_PRESSURE : 0)
| (bVV ? CGLO_CONSTRAINT : 0)
| (bRerunMD ? CGLO_RERUNMD : 0)
ir->nstlist = nstlist_cmdline;
}
- verletbuf_get_list_setup(bGPU, &ls);
+ verletbuf_get_list_setup(TRUE, bGPU, &ls);
/* Allow rlist to make the list a given factor larger than the list
* would be with the reference value for nstlist (10).
* calc_verlet_buffer_size gives the same results for 4x8 and 4x4
* and 4x2 gives a larger buffer than 4x4, this is ok.
*/
- verletbuf_get_list_setup(bUseGPU, &ls);
+ verletbuf_get_list_setup(TRUE, bUseGPU, &ls);
calc_verlet_buffer_size(mtop, det(box), ir, -1, &ls, NULL, &rlist_new);