*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * 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.
* 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 "config.h"
#include <math.h>
#include <string.h>
#endif
#include "gromacs/commandline/pargs.h"
-#include "sysstuff.h"
-#include "typedefs.h"
-#include "smalloc.h"
-#include "macros.h"
-#include "vec.h"
-#include "pbc.h"
-#include "gromacs/fileio/futil.h"
-#include "index.h"
#include "gromacs/fileio/confio.h"
-#include "gromacs/fileio/trnio.h"
-#include "mshift.h"
-#include "xvgr.h"
-#include "do_fit.h"
-#include "rmpbc.h"
-#include "txtdump.h"
#include "gromacs/fileio/matio.h"
-#include "eigio.h"
-#include "physics.h"
-#include "gmx_ana.h"
-#include "string2.h"
+#include "gromacs/fileio/trnio.h"
#include "gromacs/fileio/trxio.h"
-
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/gmxana/eigio.h"
+#include "gromacs/gmxana/gmx_ana.h"
+#include "gromacs/legacyheaders/macros.h"
+#include "gromacs/legacyheaders/txtdump.h"
+#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/linearalgebra/eigensolver.h"
+#include "gromacs/math/do_fit.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/rmpbc.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/utility/smalloc.h"
int gmx_covar(int argc, char *argv[])
{
{ "-pbc", FALSE, etBOOL, {&bPBC},
"Apply corrections for periodic boundary conditions" }
};
- FILE *out;
+ FILE *out = NULL; /* initialization makes all compilers happy */
t_trxstatus *status;
t_trxstatus *trjout;
t_topology top;
};
#define NFILE asize(fnm)
- if (!parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_TIME_UNIT | PCA_BE_NICE,
+ if (!parse_common_args(&argc, argv, PCA_CAN_TIME | PCA_TIME_UNIT,
NFILE, fnm, asize(pa), pa, asize(desc), desc, 0, NULL, &oenv))
{
return 0;
if (asciifile)
{
- out = ffopen(asciifile, "w");
+ out = gmx_ffopen(asciifile, "w");
for (j = 0; j < ndim; j++)
{
for (i = 0; i < ndim; i += 3)
mat[ndim*j+i], mat[ndim*j+i+1], mat[ndim*j+i+2]);
}
}
- ffclose(out);
+ gmx_ffclose(out);
}
if (xpmfile)
rlo.r = 0; rlo.g = 0; rlo.b = 1;
rmi.r = 1; rmi.g = 1; rmi.b = 1;
rhi.r = 1; rhi.g = 0; rhi.b = 0;
- out = ffopen(xpmfile, "w");
+ out = gmx_ffopen(xpmfile, "w");
nlevels = 80;
write_xpm3(out, 0, "Covariance", bM ? "u nm^2" : "nm^2",
"dim", "dim", ndim, ndim, axis, axis,
mat2, min, 0.0, max, rlo, rmi, rhi, &nlevels);
- ffclose(out);
+ gmx_ffclose(out);
sfree(axis);
sfree(mat2);
}
rlo.r = 0; rlo.g = 0; rlo.b = 1;
rmi.r = 1; rmi.g = 1; rmi.b = 1;
rhi.r = 1; rhi.g = 0; rhi.b = 0;
- out = ffopen(xpmafile, "w");
+ out = gmx_ffopen(xpmafile, "w");
nlevels = 80;
write_xpm3(out, 0, "Covariance", bM ? "u nm^2" : "nm^2",
"atom", "atom", ndim/DIM, ndim/DIM, axis, axis,
mat2, min, 0.0, max, rlo, rmi, rhi, &nlevels);
- ffclose(out);
+ gmx_ffclose(out);
sfree(axis);
for (i = 0; i < ndim/DIM; i++)
{
fprintf(stderr, "\nWARNING: eigenvalue sum deviates from the trace of the covariance matrix\n");
}
- fprintf(stderr, "\nWriting eigenvalues to %s\n", eigvalfile);
-
- sprintf(str, "(%snm\\S2\\N)", bM ? "u " : "");
- out = xvgropen(eigvalfile,
- "Eigenvalues of the covariance matrix",
- "Eigenvector index", str, oenv);
- for (i = 0; (i < ndim); i++)
- {
- fprintf (out, "%10d %g\n", (int)i+1, eigenvalues[ndim-1-i]);
- }
- ffclose(out);
-
+ /* Set 'end', the maximum eigenvector and -value index used for output */
if (end == -1)
{
if (nframes-1 < ndim)
{
end = nframes-1;
+ fprintf(out, "WARNING: there are fewer frames in your trajectory than there are\n");
+ fprintf(out, "degrees of freedom in your system. Only generating the first\n");
+ fprintf(out, "%d out of %d eigenvectors and eigenvalues.\n", end, (int)ndim);
}
else
{
end = ndim;
}
}
+
+ fprintf(stderr, "\nWriting eigenvalues to %s\n", eigvalfile);
+
+ sprintf(str, "(%snm\\S2\\N)", bM ? "u " : "");
+ out = xvgropen(eigvalfile,
+ "Eigenvalues of the covariance matrix",
+ "Eigenvector index", str, oenv);
+ for (i = 0; (i < end); i++)
+ {
+ fprintf (out, "%10d %g\n", (int)i+1, eigenvalues[ndim-1-i]);
+ }
+ gmx_ffclose(out);
+
if (bFit)
{
/* misuse lambda: 0/1 mass weighted analysis no/yes */
write_eigenvectors(eigvecfile, natoms, mat, TRUE, 1, end,
WriteXref, x, bDiffMass1, xproj, bM, eigenvalues);
- out = ffopen(logfile, "w");
+ out = gmx_ffopen(logfile, "w");
time(&now);
gmx_ctime_r(&now, timebuf, STRLEN);
fprintf(out, "Trace of the covariance matrix after diagonalizing: %g\n\n",
sum);
- fprintf(out, "Wrote %d eigenvalues to %s\n", (int)ndim, eigvalfile);
+ fprintf(out, "Wrote %d eigenvalues to %s\n", (int)end, eigvalfile);
if (WriteXref == eWXR_YES)
{
fprintf(out, "Wrote reference structure to %s\n", eigvecfile);
fprintf(out, "Wrote average structure to %s and %s\n", averfile, eigvecfile);
fprintf(out, "Wrote eigenvectors %d to %d to %s\n", 1, end, eigvecfile);
- ffclose(out);
+ gmx_ffclose(out);
fprintf(stderr, "Wrote the log to %s\n", logfile);