#include "gromacs/topology/mtop_util.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
+
/* We use the same defines as in broadcaststructs.cpp here */
#define block_bc(cr, d) gmx_bcast( sizeof(d), &(d), (cr))
#define nblock_bc(cr, nr, d) gmx_bcast((nr)*sizeof((d)[0]), (d), (cr))
#define snew_bc(cr, d, nr) { if (!MASTER(cr)) {snew((d), (nr)); }}
-/* These macros determine the column width in the output file */
-#define EDcol_sfmt "%17s"
-#define EDcol_efmt "%17.5e"
-#define EDcol_ffmt "%17f"
-
/* enum to identify the type of ED: none, normal ED, flooding */
enum {
eEDnone, eEDedsam, eEDflood, eEDnr
static void write_edo_legend(gmx_edsam_t ed, int nED, const output_env_t oenv);
/* End function declarations */
+/* Define formats for the column width in the output file */
+const char EDcol_sfmt[] = "%17s";
+const char EDcol_efmt[] = "%17.5e";
+const char EDcol_ffmt[] = "%17f";
+
+/* Define a formats for reading, otherwise cppcheck complains for scanf without width limits */
+const char max_ev_fmt_d[] = "%7d"; /* Number of eigenvectors. 9,999,999 should be enough */
+const char max_ev_fmt_lf[] = "%12lf";
+const char max_ev_fmt_dlf[] = "%7d%12lf";
+const char max_ev_fmt_dlflflf[] = "%7d%12lf%12lf%12lf";
+const char max_ev_fmt_lelele[] = "%12le%12le%12le";
/* Do we have to perform essential dynamics constraints or possibly only flooding
* for any of the ED groups? */
char line[STRLEN+1];
int idum;
-
fgets2 (line, STRLEN, file);
check(line, label);
fgets2 (line, STRLEN, file);
- sscanf (line, "%d", &idum);
+ sscanf (line, max_ev_fmt_d, &idum);
return idum;
}
*bEOF = TRUE;
return -1;
}
- sscanf (line, "%d", &idum);
+ sscanf (line, max_ev_fmt_d, &idum);
*bEOF = FALSE;
return idum;
}
fgets2 (line, STRLEN, file);
check(line, label);
fgets2 (line, STRLEN, file);
- sscanf (line, "%lf", &rdum);
+ sscanf (line, max_ev_fmt_lf, &rdum);
return (real) rdum; /* always read as double and convert to single */
}
for (i = 0; i < number; i++)
{
fgets2 (line, STRLEN, file);
- sscanf (line, "%d%lf%lf%lf", &anrs[i], &d[0], &d[1], &d[2]);
+ sscanf (line, max_ev_fmt_dlflflf, &anrs[i], &d[0], &d[1], &d[2]);
anrs[i]--; /* we are reading FORTRAN indices */
for (j = 0; j < 3; j++)
{
for (i = 0; (i < nr); i++)
{
fgets2 (line, STRLEN, in);
- sscanf (line, "%le%le%le", &x, &y, &z);
+ sscanf (line, max_ev_fmt_lelele, &x, &y, &z);
vec[i][XX] = x;
vec[i][YY] = y;
vec[i][ZZ] = z;
fgets2 (line, STRLEN, in);
if (bReadRefproj) /* ONLY when using flooding as harmonic restraint */
{
- nscan = sscanf(line, "%d%lf%lf%lf", &idum, &rdum, &refproj_dum, &refprojslope_dum);
+ nscan = sscanf(line, max_ev_fmt_dlflflf, &idum, &rdum, &refproj_dum, &refprojslope_dum);
/* Zero out values which were not scanned */
switch (nscan)
{
}
else /* Normal flooding */
{
- nscan = sscanf(line, "%d%lf", &idum, &rdum);
+ nscan = sscanf(line, max_ev_fmt_dlf, &idum, &rdum);
if (nscan != 2)
{
gmx_fatal(FARGS, "Expected 2 values for flooding vec: <nr> <stpsz>\n");
if (rad < edi->vecs.radacc.radius)
{
ratio = edi->vecs.radacc.radius/rad - 1.0;
- rad = edi->vecs.radacc.radius;
}
else
{
if (edi->buf->do_radcon != NULL)
{
bFirst = FALSE;
- loc = edi->buf->do_radcon;
}
else
{
rvec_inc(xcoll[j], vec_dum);
}
}
+
}
else
{
edi->vecs.radcon.radius = rad;
}
- if (rad != edi->vecs.radcon.radius)
- {
- rad = 0.0;
- for (i = 0; i < edi->vecs.radcon.neig; i++)
- {
- /* calculate the projections, radius */
- loc->proj[i] = projectx(edi, xcoll, edi->vecs.radcon.vec[i]);
- rad += pow(loc->proj[i] - edi->vecs.radcon.refproj[i], 2);
- }
- rad = sqrt(rad);
- }
}
}
-static void nice_legend(const char ***setname, int *nsets, char **LegendStr, char *value, char *unit, char EDgroupchar)
+static void nice_legend(const char ***setname, int *nsets, char **LegendStr, const char *value, const char *unit, char EDgroupchar)
{
char tmp[STRLEN], tmp2[STRLEN];
}
/* Reset pointer to first ED data set which contains the actual ED data */
edi = ed->edpar;
+ GMX_ASSERT(NULL != edi,
+ "The pointer to the essential dynamics parameters is undefined");
+
/* Loop over all ED/flooding data sets (usually only one, though) */
for (nr_edi = 1; nr_edi <= EDstate->nED; nr_edi++)
{