# NOTE: when releasing the "-dev" suffix needs to be stripped off!
# REGRESSIONTEST_VERSION and REGRESSIONTEST_BRANCH should always be
# defined.
-set(PROJECT_VERSION "5.0-rc1-dev")
+set(PROJECT_VERSION "5.1-dev")
# If this is a released tarball, "-dev" will not be present in
# PROJECT_VERSION, and REGRESSIONTEST_VERSION specifies the version
# number of the regressiontest tarball against which the code tarball
# PROJECT_VERSION, and REGRESSIONTEST_BRANCH specifies the name of the
# gerrit.gromacs.org branch whose HEAD can test this code, *if* this
# code contains all recent fixes from the corresponding code branch.
-set(REGRESSIONTEST_BRANCH "refs/heads/release-5-0")
+set(REGRESSIONTEST_BRANCH "refs/heads/master")
set(CUSTOM_VERSION_STRING ""
CACHE STRING "Custom version string (if empty, use hard-coded default)")
set(LIBRARY_VERSION ${LIBRARY_SOVERSION}.0.0)
# It is a bit irritating, but this has to be set separately for now!
SET(CPACK_PACKAGE_VERSION_MAJOR "5")
-SET(CPACK_PACKAGE_VERSION_MINOR "0")
+SET(CPACK_PACKAGE_VERSION_MINOR "1")
#SET(CPACK_PACKAGE_VERSION_PATCH "0")
# The numerical gromacs version. It is 40600 for 4.6.0.
mark_as_advanced(GMX_INSTALL_PREFIX)
include(gmxBuildTypeReference)
-include(gmxBuildTypeThreadSanitizer)
+include(gmxBuildTypeProfile)
+include(gmxBuildTypeTSAN)
+include(gmxBuildTypeASAN)
include(gmxBuildTypeReleaseWithAssert)
if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Reference RelWithAssert." FORCE)
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel Reference RelWithAssert Profile." FORCE)
# There's no need to offer a user the choice of ThreadSanitizer
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
- "MinSizeRel" "RelWithDebInfo" "Reference" "RelWithAssert")
+ "MinSizeRel" "RelWithDebInfo" "Reference" "RelWithAssert" "Profile")
endif()
if(CMAKE_CONFIGURATION_TYPES)
# Add appropriate GROMACS-specific build types for the Visual
"List of configuration types"
FORCE)
endif()
-set(build_types_with_explicit_flags RELEASE DEBUG RELWITHDEBUGINFO RELWITHASSERT MINSIZEREL)
+set(build_types_with_explicit_flags RELEASE DEBUG RELWITHDEBUGINFO RELWITHASSERT MINSIZEREL PROFILE)
enable_language(C)
enable_language(CXX)
########################################################################
# Specify install locations
########################################################################
- set(GMX_LIB_INSTALL_DIR lib CACHE STRING
- "Library installation directory (default: lib)")
+ # Use GNUInstallDirst to set paths on multiarch systems
+ include(GNUInstallDirs)
+
+ set(GMX_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING
+ "Library installation directory (default: ${CMAKE_INSTALL_LIBDIR})")
set(GMX_DATA_INSTALL_DIR gromacs CACHE STRING
"Data installation directory under share/ (default: gromacs)")
mark_as_advanced(GMX_LIB_INSTALL_DIR GMX_DATA_INSTALL_DIR)
#include <stdlib.h>
#include "errno.h"
-#include "sysstuff.h"
#include "typedefs.h"
#include "gromacs/utility/cstringutil.h"
#include "macros.h"
#include "gromacs/utility/smalloc.h"
-#include "mshift.h"
#include "gromacs/commandline/pargs.h"
#include "copyrite.h"
#include "gromacs/fileio/confio.h"
-#include "gmx_fatal.h"
-#include "xvgr.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/fileio/xvgr.h"
#include "gstat.h"
-#include "index.h"
+#include "gromacs/topology/index.h"
#include "gromacs/fileio/pdbio.h"
void cat(FILE *out,char *fn,real t)
"calling the 'total' program. If you do not have the total program,",
"get it. do_shift assumes that the total executable is in",
"[TT]/home/mdgroup/total/total[tt]. If that is not the case, then you should",
- "set an environment variable [BB]TOTAL[bb] as in: [PAR]",
- "[TT]setenv TOTAL /usr/local/bin/total[tt][PAR]",
+ "set an environment variable [BB]GMX_TOTAL[bb] as in: [PAR]",
+ "[TT]setenv GMX_TOTAL /usr/local/bin/total[tt][PAR]",
"where the right hand side should point to the total executable.[PAR]",
"Output is printed in files [TT]shift.out[tt] where t is the time of the frame.[PAR]",
"The program also needs an input file called [BB]random.dat[bb] which",
gmx_tmpnam(tmpfile);
fprintf(stderr,"pdbfile = %s\ntmpfile = %s\n",pdbfile,tmpfile);
- if ((dptr=getenv("TOTAL")) == NULL)
+ if ((dptr=getenv("GMX_TOTAL")) == NULL)
dptr="/home/mdgroup/total/total";
sprintf(total,"%s > /dev/null",dptr);
fprintf(stderr,"total cmd='%s'\n",total);
#include <algorithm>
#include "macros.h"
-#include "gromacs/commandline/pargs.h"
-#include "sysstuff.h"
-#include "gromacs/utility/smalloc.h"
-#include "vec.h"
-#include "pbc.h"
+#include "gromacs/pbcutil/pbc.h"
#include "bondf.h"
-#include "gromacs/fileio/futil.h"
-#include "xvgr.h"
+#include "gromacs/utility/futil.h"
+#include "viewit.h"
#include "txtdump.h"
#include "gromacs/statistics/statistics.h"
#include "gstat.h"
-#include "index.h"
+#include "gromacs/topology/index.h"
#include "gromacs/random/random.h"
#include "names.h"
-#include "physics.h"
+#include "gromacs/math/units.h"
#include "calcmu.h"
#include "gromacs/fileio/enxio.h"
-#include "gromacs/fileio/matio.h"
#include "gmx_ana.h"
#include "copyrite.h"
#include "gromacs/fileio/trxio.h"
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/fileio/matio.h"
+#include "gromacs/fileio/xvgr.h"
#include "gromacs/linearalgebra/nrjac.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/rmpbc.h"
#include "gromacs/utility/exceptions.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/programcontext.h"
+#include "gromacs/utility/smalloc.h"
#define e2d(x) ENM2DEBYE*(x)
#define EANG2CM E_CHARGE*1.0e-10 /* e Angstrom to Coulomb meter */
snew(gb, 1);
- if ((ptr = getenv("GKRWIDTH")) != NULL)
+ if ((ptr = getenv("GMX_DIPOLE_SPACING")) != NULL)
{
double bw = strtod(ptr, NULL);
gb->spacing = bw;
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <string.h>
+
#include <math.h>
+#include <stdlib.h>
+#include <string.h>
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
#include "disre.h"
#include "names.h"
#include "macros.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/fileio/enxio.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "gmx_ana.h"
#include "gromacs/fileio/trxio.h"
int *set;
gmx_bool bVerbose = TRUE;
- if ((getenv("VERBOSE")) != NULL)
+ if ((getenv("GMX_ENER_VERBOSE")) != NULL)
{
bVerbose = FALSE;
}
nset = 0;
timestep = 0.0;
snew(fnms, argc);
- nfile = 0;
lastfilestep = 0;
laststep = startstep = 0;
#endif
#include <math.h>
+#include <stdlib.h>
#include <string.h>
#include "typedefs.h"
-#include "gmx_fatal.h"
-#include "vec.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/math/vec.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/fileio/enxio.h"
#include "names.h"
#include "copyrite.h"
#include "macros.h"
-#include "xvgr.h"
+#include "gromacs/fileio/xvgr.h"
#include "gstat.h"
-#include "physics.h"
+#include "gromacs/math/units.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
#include "viewit.h"
-#include "mtop_util.h"
+#include "gromacs/topology/mtop_util.h"
#include "gmx_ana.h"
#include "mdebin.h"
int *set;
gmx_bool bVerbose = TRUE;
- if ((getenv("VERBOSE")) != NULL)
+ if ((getenv("GMX_ENER_VERBOSE")) != NULL)
{
bVerbose = FALSE;
}
const char *fm2 = "%3d %-34s";
char **newnm = NULL;
- if ((getenv("VERBOSE")) != NULL)
+ if ((getenv("GMX_ENER_VERBOSE")) != NULL)
{
bVerbose = FALSE;
}
#endif
#include <ctype.h>
+#include <stdlib.h>
#include <string.h>
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
-#include "sysstuff.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/commandline/pargs.h"
-#include "pbc.h"
+#include "gromacs/pbcutil/pbc.h"
#include "force.h"
-#include "gmx_fatal.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/math/utilities.h"
#include "macros.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "gromacs/fileio/tpxio.h"
#include "mdrun.h"
-#include "main.h"
#include "gromacs/random/random.h"
-#include "index.h"
-#include "mtop_util.h"
+#include "gromacs/topology/index.h"
#include "gmx_ana.h"
static void insert_ion(int nsa, int *nwater,
if ((p_num == 0) && (n_num == 0))
{
- fprintf(stderr, "No ions to add.\n");
- exit(0);
+ fprintf(stderr, "No ions to add, will just copy input configuration.\n");
}
else
{
{
gmx_fatal(FARGS, "Not enough solvent for adding ions");
}
- }
- if (opt2bSet("-p", NFILE, fnm))
- {
- update_topol(opt2fn("-p", NFILE, fnm), p_num, n_num, p_name, n_name, grpname);
- }
+ if (opt2bSet("-p", NFILE, fnm))
+ {
+ update_topol(opt2fn("-p", NFILE, fnm), p_num, n_num, p_name, n_name, grpname);
+ }
- snew(bSet, nw);
- snew(repl, nw);
+ snew(bSet, nw);
+ snew(repl, nw);
- snew(v, atoms.nr);
- snew(atoms.pdbinfo, atoms.nr);
+ snew(v, atoms.nr);
+ snew(atoms.pdbinfo, atoms.nr);
- set_pbc(&pbc, ePBC, box);
+ set_pbc(&pbc, ePBC, box);
- if (seed == 0)
- {
- rng = gmx_rng_init(gmx_rng_make_seed());
- }
- else
- {
- rng = gmx_rng_init(seed);
- }
- /* Now loop over the ions that have to be placed */
- while (p_num-- > 0)
- {
- insert_ion(nsa, &nw, bSet, repl, index, x, &pbc,
- 1, p_q, p_name, &atoms, rmin, rng);
- }
- while (n_num-- > 0)
- {
- insert_ion(nsa, &nw, bSet, repl, index, x, &pbc,
- -1, n_q, n_name, &atoms, rmin, rng);
- }
- gmx_rng_destroy(rng);
- fprintf(stderr, "\n");
+ if (seed == 0)
+ {
+ rng = gmx_rng_init(gmx_rng_make_seed());
+ }
+ else
+ {
+ rng = gmx_rng_init(seed);
+ }
+ /* Now loop over the ions that have to be placed */
+ while (p_num-- > 0)
+ {
+ insert_ion(nsa, &nw, bSet, repl, index, x, &pbc,
+ 1, p_q, p_name, &atoms, rmin, rng);
+ }
+ while (n_num-- > 0)
+ {
+ insert_ion(nsa, &nw, bSet, repl, index, x, &pbc,
+ -1, n_q, n_name, &atoms, rmin, rng);
+ }
+ gmx_rng_destroy(rng);
+ fprintf(stderr, "\n");
- if (nw)
- {
- sort_ions(nsa, nw, repl, index, &atoms, x, p_name, n_name);
- }
+ if (nw)
+ {
+ sort_ions(nsa, nw, repl, index, &atoms, x, p_name, n_name);
+ }
- sfree(atoms.pdbinfo);
- atoms.pdbinfo = NULL;
- write_sto_conf(ftp2fn(efSTO, NFILE, fnm), *top.name, &atoms, x, NULL, ePBC,
- box);
+ sfree(atoms.pdbinfo);
+ atoms.pdbinfo = NULL;
+ }
+ write_sto_conf(ftp2fn(efSTO, NFILE, fnm), *top.name, &atoms, x, NULL, ePBC, box);
return 0;
}
#include <ctype.h>
#include <string.h>
-#include "sysstuff.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "macros.h"
-#include "gromacs/utility/cstringutil.h"
-#include "gromacs/commandline/pargs.h"
#include "gromacs/fileio/confio.h"
#include "typedefs.h"
-#include "index.h"
-#include "gromacs/utility/smalloc.h"
-#include "vec.h"
-#include "index.h"
+#include "gromacs/topology/index.h"
+#include "gromacs/math/vec.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
+#include "gromacs/commandline/pargs.h"
+#include "gromacs/topology/block.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
- #define MAXNAMES 30
- #define NAME_LEN 30
+ /* It's not nice to have size limits, but we should not spend more time
+ * on this ancient tool, but instead use the new selection library.
+ */
+ #define MAXNAMES 1024
+ #define NAME_LEN 1024
gmx_bool bCase = FALSE;
{
rvec_sub(x[ca_end], x[i], vec);
}
+ else
+ {
+ break;
+ }
}
- while ((i < natoms) && (norm(vec) < 0.45));
+ while (norm(vec) < 0.45);
end[nchain] = ca_end;
while ((end[nchain]+1 < natoms) &&
#include <string.h>
#include "gromacs/commandline/pargs.h"
-#include "sysstuff.h"
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
#include "macros.h"
-#include "vec.h"
-#include "pbc.h"
-#include "gromacs/fileio/futil.h"
-#include "index.h"
-#include "mshift.h"
-#include "xvgr.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/futil.h"
+#include "gromacs/topology/index.h"
#include "princ.h"
-#include "rmpbc.h"
+#include "gromacs/pbcutil/rmpbc.h"
#include "txtdump.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
{
const char *desc[] = {
"[THISMODULE] calculates the three principal axes of inertia for a group",
- "of atoms.",
+ "of atoms. NOTE: Old versions of Gromacs wrote the output data in a",
+ "strange transposed way. As of Gromacs-5.0, the output file paxis1.dat",
+ "contains the x/y/z components of the first (major) principal axis for",
+ "each frame, and similarly for the middle and minor axes in paxis2.dat",
+ "and paxis3.dat."
};
static gmx_bool foo = FALSE;
{ efTRX, "-f", NULL, ffREAD },
{ efTPS, NULL, NULL, ffREAD },
{ efNDX, NULL, NULL, ffOPTRD },
- { efDAT, "-a1", "axis1", ffWRITE },
- { efDAT, "-a2", "axis2", ffWRITE },
- { efDAT, "-a3", "axis3", ffWRITE },
+ { efDAT, "-a1", "paxis1", ffWRITE },
+ { efDAT, "-a2", "paxis2", ffWRITE },
+ { efDAT, "-a3", "paxis3", ffWRITE },
{ efDAT, "-om", "moi", ffWRITE }
};
#define NFILE asize(fnm)
calc_principal_axes(&top, x, index, gnx, axes, moi);
- fprintf(axis1, "%15.10f %15.10f %15.10f %15.10f\n", t, axes[XX][XX], axes[YY][XX], axes[ZZ][XX]);
- fprintf(axis2, "%15.10f %15.10f %15.10f %15.10f\n", t, axes[XX][YY], axes[YY][YY], axes[ZZ][YY]);
- fprintf(axis3, "%15.10f %15.10f %15.10f %15.10f\n", t, axes[XX][ZZ], axes[YY][ZZ], axes[ZZ][ZZ]);
+ fprintf(axis1, "%15.10f %15.10f %15.10f %15.10f\n", t, axes[XX][XX], axes[XX][YY], axes[XX][ZZ]);
+ fprintf(axis2, "%15.10f %15.10f %15.10f %15.10f\n", t, axes[YY][XX], axes[YY][YY], axes[YY][ZZ]);
+ fprintf(axis3, "%15.10f %15.10f %15.10f %15.10f\n", t, axes[ZZ][XX], axes[ZZ][YY], axes[ZZ][ZZ]);
fprintf(fmoi, "%15.10f %15.10f %15.10f %15.10f\n", t, moi[XX], moi[YY], moi[ZZ]);
}
while (read_next_x(oenv, status, &t, x, box));
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+
#include <math.h>
+#include <stdlib.h>
#include <string.h>
+
#include "gromacs/commandline/pargs.h"
-#include "sysstuff.h"
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
#include "macros.h"
-#include "gmx_fatal.h"
-#include "vec.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/utility/futil.h"
#include "readinp.h"
#include "txtdump.h"
#include "gstat.h"
-#include "xvgr.h"
-#include "physics.h"
+#include "gromacs/fileio/xvgr.h"
+#include "gromacs/math/units.h"
#include "gromacs/fileio/pdbio.h"
#include "gromacs/fileio/matio.h"
#include "gmx_ana.h"
static void do_sham(const char *fn, const char *ndx,
const char *xpmP, const char *xpm, const char *xpm2,
- const char *xpm3, const char *xpm4, const char *pdb,
+ const char *xpm3, const char *pdb,
const char *logf,
int n, int neig, real **eig,
gmx_bool bGE, int nenerT, real **enerT,
- int nmap, real *mapindex, real **map,
real Tref,
real pmax, real gmax,
real *emin, real *emax, int nlevels, real pmin,
- const char *mname, int *idim, int *ibox,
+ int *idim, int *ibox,
gmx_bool bXmin, real *xmin, gmx_bool bXmax, real *xmax)
{
FILE *fp;
real *min_eig, *max_eig;
real *axis_x, *axis_y, *axis_z, *axis = NULL;
double *P;
- real **PP, *W, *E, **WW, **EE, *S, **SS, *M, **MM, *bE;
+ real **PP, *W, *E, **WW, **EE, *S, **SS, *M, *bE;
rvec xxx;
char *buf;
- double *bfac, efac, bref, Pmax, Wmin, Wmax, Winf, Emin, Emax, Einf, Smin, Smax, Sinf, Mmin, Mmax, Minf;
+ double *bfac, efac, bref, Pmax, Wmin, Wmax, Winf, Emin, Emax, Einf, Smin, Smax, Sinf, Mmin, Mmax;
real *delta;
int i, j, k, imin, len, index, d, *nbin, *bindex, bi;
int *nxyz, maxbox;
axis[j] = min_eig[i] + j/bfac[i];
}
}
- if (map)
- {
- snew(M, len);
- snew(MM, maxbox*maxbox);
- for (i = 0; (i < ibox[0]); i++)
- {
- MM[i] = &(M[i*ibox[1]]);
- }
- Mmin = 1e8;
- Mmax = -1e8;
- for (i = 0; (i < nmap); i++)
- {
- Mmin = min(Mmin, map[0][i]);
- Mmax = max(Mmax, map[0][i]);
- }
- Minf = Mmax*1.05;
- for (i = 0; (i < len); i++)
- {
- M[i] = Minf;
- }
- for (i = 0; (i < nmap); i++)
- {
- index = gmx_nint(mapindex[i]);
- if (index >= len)
- {
- gmx_fatal(FARGS, "Number of bins in file from -mdata option does not correspond to current analysis");
- }
- if (P[index] != 0)
- {
- M[index] = map[0][i];
- }
- }
- }
- else
- {
- MM = NULL;
- Minf = NOTSET;
- }
pick_minima(logf, ibox, neig, len, W);
if (gmax <= 0)
{
write_xpm(fp, flags, "Entropy Landscape", "TDS (kJ/mol)", "PC1", "PC2",
ibox[0], ibox[1], axis_x, axis_y, SS, 0, Sinf, rlo, rhi, &nlevels);
gmx_ffclose(fp);
- if (map)
- {
- fp = gmx_ffopen(xpm4, "w");
- write_xpm(fp, flags, "Custom Landscape", mname, "PC1", "PC2",
- ibox[0], ibox[1], axis_x, axis_y, MM, 0, Minf, rlo, rhi, &nlevels);
- gmx_ffclose(fp);
- }
}
else if (neig == 3)
{
}
gmx_ffclose(fp);
write_xplor("out.xplor", W, ibox, min_eig, max_eig);
- if (map)
- {
- write_xplor("user.xplor", M, ibox, min_eig, max_eig);
- }
nxyz[XX] = imin/(ibox[1]*ibox[2]);
nxyz[YY] = (imin-nxyz[XX]*ibox[1]*ibox[2])/ibox[2];
nxyz[ZZ] = imin % ibox[2];
gmx_ffclose(fp);
sfree(buf);
}
- if (map)
- {
- sfree(MM);
- sfree(M);
- }
}
static void ehisto(const char *fh, int n, real **enerT, const output_env_t oenv)
static rvec nrbox = {32, 32, 32};
static rvec xmin = {0, 0, 0}, xmax = {1, 1, 1};
static int nsets_in = 1, nb_min = 4, resol = 10, nlevels = 25;
- static const char *mname = "";
t_pargs pa[] = {
{ "-time", FALSE, etBOOL, {&bHaveT},
"Expect a time in the input" },
"Maximum enthalpy in output, default is calculate" },
{ "-nlevels", FALSE, etINT, {&nlevels},
"Number of levels for energy landscape" },
- { "-mname", FALSE, etSTR, {&mname},
- "Legend label for the custom landscape" },
};
#define NPA asize(pa)
FILE *out;
- int n, e_n, d_n, nlast, s, nset, e_nset, d_nset, i, j = 0, *idim, *ibox;
- real **val, **et_val, **dt_val, *t, *e_t, e_dt, d_dt, *d_t, dt, tot, error;
+ int n, e_n, nlast, s, nset, e_nset, d_nset, i, j = 0, *idim, *ibox;
+ real **val, **et_val, *t, *e_t, e_dt, d_dt, dt, tot, error;
real *rmin, *rmax;
double *av, *sig, cum1, cum2, cum3, cum4, db;
const char *fn_ge, *fn_ene;
{ efXPM, "-ls", "gibbs", ffOPTWR },
{ efXPM, "-lsh", "enthalpy", ffOPTWR },
{ efXPM, "-lss", "entropy", ffOPTWR },
- { efXPM, "-map", "map", ffOPTWR },
{ efPDB, "-ls3", "gibbs3", ffOPTWR },
- { efXVG, "-mdata", "mapdata", ffOPTRD },
{ efLOG, "-g", "shamlog", ffOPTWR }
};
#define NFILE asize(fnm)
et_val = NULL;
}
- if (opt2fn_null("-mdata", NFILE, fnm) != NULL)
- {
- dt_val = read_xvg_time(opt2fn("-mdata", NFILE, fnm), bHaveT,
- FALSE, tb, FALSE, te,
- nsets_in, &d_nset, &d_n, &d_dt, &d_t);
- if (d_nset != 1)
- {
- gmx_fatal(FARGS, "Can only handle one mapping data column in %s",
- opt2fn("-mdata", NFILE, fnm));
- }
- }
- else
- {
- dt_val = NULL;
- }
-
if (fn_ene && et_val)
{
ehisto(opt2fn("-histo", NFILE, fnm), e_n, et_val, oenv);
do_sham(opt2fn("-dist", NFILE, fnm), opt2fn("-bin", NFILE, fnm),
opt2fn("-lp", NFILE, fnm),
opt2fn("-ls", NFILE, fnm), opt2fn("-lsh", NFILE, fnm),
- opt2fn("-lss", NFILE, fnm), opt2fn("-map", NFILE, fnm),
+ opt2fn("-lss", NFILE, fnm),
opt2fn("-ls3", NFILE, fnm), opt2fn("-g", NFILE, fnm),
- n, nset, val, fn_ge != NULL, e_nset, et_val, d_n, d_t, dt_val, Tref,
+ n, nset, val, fn_ge != NULL, e_nset, et_val, Tref,
pmax, gmax,
opt2parg_bSet("-emin", NPA, pa) ? &emin : NULL,
opt2parg_bSet("-emax", NPA, pa) ? &emax : NULL,
nlevels, pmin,
- mname, idim, ibox,
+ idim, ibox,
opt2parg_bSet("-xmin", NPA, pa), rmin,
opt2parg_bSet("-xmax", NPA, pa), rmax);
#include "md_logging.h"
#include "gmx_thread_affinity.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/basenetwork.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxomp.h"
+#include "gromacs/utility/smalloc.h"
static int
get_thread_affinity_layout(FILE *fplog,
*/
MPI_Comm comm_intra;
- MPI_Comm_split(MPI_COMM_WORLD, gmx_hostname_num(), cr->rank_intranode,
+ MPI_Comm_split(MPI_COMM_WORLD,
+ gmx_physicalnode_id_hash(), cr->rank_intranode,
&comm_intra);
MPI_Scan(&nthread_local, &thread0_id_node, 1, MPI_INT, MPI_SUM, comm_intra);
/* MPI_Scan is inclusive, but here we need exclusive */
* Note that this will only work on Linux as we use a GNU feature.
*/
void
-gmx_check_thread_affinity_set(FILE gmx_unused *fplog,
- const t_commrec gmx_unused *cr,
- gmx_hw_opt_t gmx_unused *hw_opt,
- int gmx_unused ncpus,
- gmx_bool gmx_unused bAfterOpenmpInit)
+gmx_check_thread_affinity_set(FILE *fplog,
+ const t_commrec *cr,
+ gmx_hw_opt_t *hw_opt,
+ int gmx_unused ncpus,
+ gmx_bool bAfterOpenmpInit)
{
#ifdef HAVE_SCHED_GETAFFINITY
cpu_set_t mask_current;
int i, ret, cpu_count, cpu_set;
gmx_bool bAllSet;
+#endif
assert(hw_opt);
+ if (!bAfterOpenmpInit)
+ {
+ /* Check for externally set OpenMP affinity and turn off internal
+ * pinning if any is found. We need to do this check early to tell
+ * thread-MPI whether it should do pinning when spawning threads.
+ * TODO: the above no longer holds, we should move these checks later
+ */
+ if (hw_opt->thread_affinity != threadaffOFF)
+ {
+ char *message;
+ if (!gmx_omp_check_thread_affinity(&message))
+ {
+ /* TODO: with -pin auto we should only warn when using all cores */
+ md_print_warn(cr, fplog, "%s", message);
+ sfree(message);
+ hw_opt->thread_affinity = threadaffOFF;
+ }
+ }
+
+ /* With thread-MPI this is needed as pinning might get turned off,
+ * which needs to be known before starting thread-MPI.
+ * With thread-MPI hw_opt is processed here on the master rank
+ * and passed to the other ranks later, so we only do this on master.
+ */
+ if (!SIMMASTER(cr))
+ {
+ return;
+ }
+#ifndef GMX_THREAD_MPI
+ return;
+#endif
+ }
+
+#ifdef HAVE_SCHED_GETAFFINITY
if (hw_opt->thread_affinity == threadaffOFF)
{
/* internal affinity setting is off, don't bother checking process affinity */
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+#include "network.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <ctype.h>
+#include <stdarg.h>
+#include <stdlib.h>
#include <string.h>
-#include "gmx_fatal.h"
-#include "main.h"
-#include "gromacs/utility/smalloc.h"
+
#include "types/commrec.h"
-#include "network.h"
#include "copyrite.h"
-#include <ctype.h>
#include "macros.h"
-#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/basenetwork.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/utility/gmxmpi.h"
-
+#include "gromacs/utility/smalloc.h"
/* The source code in this file should be thread-safe.
Please keep it that way. */
-gmx_bool gmx_mpi_initialized(void)
-{
- int n;
-#ifndef GMX_MPI
- return 0;
-#else
- MPI_Initialized(&n);
-
- return n;
-#endif
-}
-
void gmx_fill_commrec_from_mpi(t_commrec gmx_unused *cr)
{
#ifndef GMX_MPI
#endif
}
-int gmx_node_num(void)
-{
-#ifndef GMX_MPI
- return 1;
-#else
- int i;
- (void) MPI_Comm_size(MPI_COMM_WORLD, &i);
- return i;
-#endif
-}
-
-int gmx_node_rank(void)
-{
-#ifndef GMX_MPI
- return 0;
-#else
- int i;
- (void) MPI_Comm_rank(MPI_COMM_WORLD, &i);
- return i;
-#endif
-}
-
-static int mpi_hostname_hash(void)
-{
- int hash_int;
-
-#ifndef GMX_LIB_MPI
- /* We have a single physical node */
- hash_int = 0;
-#else
- int resultlen;
- char mpi_hostname[MPI_MAX_PROCESSOR_NAME];
-
- /* This procedure can only differentiate nodes with different names.
- * Architectures where different physical nodes have identical names,
- * such as IBM Blue Gene, should use an architecture specific solution.
- */
- MPI_Get_processor_name(mpi_hostname, &resultlen);
-
- /* The string hash function returns an unsigned int. We cast to an int.
- * Negative numbers are converted to positive by setting the sign bit to 0.
- * This makes the hash one bit smaller.
- * A 63-bit hash (with 64-bit int) should be enough for unique node hashes,
- * even on a million node machine. 31 bits might not be enough though!
- */
- hash_int =
- (int)gmx_string_fullhash_func(mpi_hostname, gmx_string_hash_init);
- if (hash_int < 0)
- {
- hash_int -= INT_MIN;
- }
-#endif
-
- return hash_int;
-}
-
-#if defined GMX_LIB_MPI && defined GMX_TARGET_BGQ
-#include <spi/include/kernel/location.h>
-
-static int bgq_nodenum(void)
-{
- int hostnum;
- Personality_t personality;
- Kernel_GetPersonality(&personality, sizeof(personality));
- /* Each MPI rank has a unique coordinate in a 6-dimensional space
- (A,B,C,D,E,T), with dimensions A-E corresponding to different
- physical nodes, and T within each node. Each node has sixteen
- physical cores, each of which can have up to four hardware
- threads, so 0 <= T <= 63 (but the maximum value of T depends on
- the confituration of ranks and OpenMP threads per
- node). However, T is irrelevant for computing a suitable return
- value for gmx_hostname_num().
- */
- hostnum = personality.Network_Config.Acoord;
- hostnum *= personality.Network_Config.Bnodes;
- hostnum += personality.Network_Config.Bcoord;
- hostnum *= personality.Network_Config.Cnodes;
- hostnum += personality.Network_Config.Ccoord;
- hostnum *= personality.Network_Config.Dnodes;
- hostnum += personality.Network_Config.Dcoord;
- hostnum *= personality.Network_Config.Enodes;
- hostnum += personality.Network_Config.Ecoord;
-
- if (debug)
- {
- fprintf(debug,
- "Torus ID A: %d / %d B: %d / %d C: %d / %d D: %d / %d E: %d / %d\nNode ID T: %d / %d core: %d / %d hardware thread: %d / %d\n",
- personality.Network_Config.Acoord,
- personality.Network_Config.Anodes,
- personality.Network_Config.Bcoord,
- personality.Network_Config.Bnodes,
- personality.Network_Config.Ccoord,
- personality.Network_Config.Cnodes,
- personality.Network_Config.Dcoord,
- personality.Network_Config.Dnodes,
- personality.Network_Config.Ecoord,
- personality.Network_Config.Enodes,
- Kernel_ProcessorCoreID(),
- 16,
- Kernel_ProcessorID(),
- 64,
- Kernel_ProcessorThreadID(),
- 4);
- }
- return hostnum;
-}
-#endif
-
-int gmx_physicalnode_id_hash(void)
-{
- int hash;
-
-#ifndef GMX_MPI
- hash = 0;
-#else
-#ifdef GMX_THREAD_MPI
- /* thread-MPI currently puts the thread number in the process name,
- * we might want to change this, as this is inconsistent with what
- * most MPI implementations would do when running on a single node.
- */
- hash = 0;
-#else
-#ifdef GMX_TARGET_BGQ
- hash = bgq_nodenum();
-#else
- hash = mpi_hostname_hash();
-#endif
-#endif
-#endif
-
- if (debug)
- {
- fprintf(debug, "In gmx_physicalnode_id_hash: hash %d\n", hash);
- }
-
- return hash;
-}
-
void gmx_setup_nodecomm(FILE gmx_unused *fplog, t_commrec *cr)
{
gmx_nodecomm_t *nc;
- int n, rank, hostnum, ng, ni;
+ int n, rank, nodehash, ng, ni;
/* Many MPI implementations do not optimize MPI_Allreduce
* (and probably also other global communication calls)
MPI_Comm_size(cr->mpi_comm_mygroup, &n);
MPI_Comm_rank(cr->mpi_comm_mygroup, &rank);
- hostnum = gmx_hostname_num();
+ nodehash = gmx_physicalnode_id_hash();
if (debug)
{
/* The intra-node communicator, split on node number */
- MPI_Comm_split(cr->mpi_comm_mygroup, hostnum, rank, &nc->comm_intra);
+ MPI_Comm_split(cr->mpi_comm_mygroup, nodehash, rank, &nc->comm_intra);
MPI_Comm_rank(nc->comm_intra, &nc->rank_intra);
if (debug)
{
/* thread-MPI is not initialized when not running in parallel */
#if defined GMX_MPI && !defined GMX_THREAD_MPI
int nrank_world, rank_world;
- int i, mynum, *num, *num_s, *num_pp, *num_pp_s;
+ int i, myhash, *hash, *hash_s, *hash_pp, *hash_pp_s;
MPI_Comm_size(MPI_COMM_WORLD, &nrank_world);
MPI_Comm_rank(MPI_COMM_WORLD, &rank_world);
- /* Get the node number from the hostname to identify the nodes */
- mynum = gmx_hostname_num();
+ /* Get a (hopefully unique) hash that identifies our physical node */
+ myhash = gmx_physicalnode_id_hash();
/* We can't rely on MPI_IN_PLACE, so we need send and receive buffers */
- snew(num, nrank_world);
- snew(num_s, nrank_world);
- snew(num_pp, nrank_world);
- snew(num_pp_s, nrank_world);
+ snew(hash, nrank_world);
+ snew(hash_s, nrank_world);
+ snew(hash_pp, nrank_world);
+ snew(hash_pp_s, nrank_world);
- num_s[rank_world] = mynum;
- num_pp_s[rank_world] = (cr->duty & DUTY_PP) ? mynum : -1;
+ hash_s[rank_world] = myhash;
+ hash_pp_s[rank_world] = (cr->duty & DUTY_PP) ? myhash : -1;
- MPI_Allreduce(num_s, num, nrank_world, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
- MPI_Allreduce(num_pp_s, num_pp, nrank_world, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ MPI_Allreduce(hash_s, hash, nrank_world, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
+ MPI_Allreduce(hash_pp_s, hash_pp, nrank_world, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
nrank_intranode = 0;
rank_intranode = 0;
rank_pp_intranode = 0;
for (i = 0; i < nrank_world; i++)
{
- if (num[i] == mynum)
+ if (hash[i] == myhash)
{
nrank_intranode++;
if (i < rank_world)
rank_intranode++;
}
}
- if (num_pp[i] == mynum)
+ if (hash_pp[i] == myhash)
{
nrank_pp_intranode++;
if ((cr->duty & DUTY_PP) && i < rank_world)
}
}
}
- sfree(num);
- sfree(num_s);
- sfree(num_pp);
- sfree(num_pp_s);
+ sfree(hash);
+ sfree(hash_s);
+ sfree(hash_pp);
+ sfree(hash_pp_s);
#else
/* Serial or thread-MPI code: we run within a single physical node */
nrank_intranode = cr->nnodes;
#endif
}
-void gmx_abort(int gmx_unused noderank, int gmx_unused nnodes, int gmx_unused errorno)
-{
-#ifndef GMX_MPI
- gmx_call("gmx_abort");
-#else
-#ifdef GMX_THREAD_MPI
- fprintf(stderr, "Halting program %s\n", ShortProgram());
- gmx_thanx(stderr);
- exit(1);
-#else
- if (nnodes > 1)
- {
- fprintf(stderr, "Halting parallel program %s on CPU %d out of %d\n",
- ShortProgram(), noderank, nnodes);
- }
- else
- {
- fprintf(stderr, "Halting program %s\n", ShortProgram());
- }
-
- gmx_thanx(stderr);
- MPI_Abort(MPI_COMM_WORLD, errorno);
- exit(1);
-#endif
-#endif
-}
-
void gmx_bcast(int gmx_unused nbytes, void gmx_unused *b, const t_commrec gmx_unused *cr)
{
#ifndef GMX_MPI
#endif
#endif
}
+
+gmx_bool gmx_fexist_master(const char *fname, t_commrec *cr)
+{
+ gmx_bool bExist;
+
+ if (SIMMASTER(cr))
+ {
+ bExist = gmx_fexist(fname);
+ }
+ if (PAR(cr))
+ {
+ gmx_bcast(sizeof(bExist), &bExist, cr);
+ }
+ return bExist;
+}
+
+void gmx_fatal_collective(int f_errno, const char *file, int line,
+ const t_commrec *cr, gmx_domdec_t *dd,
+ const char *fmt, ...)
+{
+ va_list ap;
+ gmx_bool bMaster, bFinalize;
+#ifdef GMX_MPI
+ int result;
+ /* Check if we are calling on all processes in MPI_COMM_WORLD */
+ if (cr != NULL)
+ {
+ MPI_Comm_compare(cr->mpi_comm_mysim, MPI_COMM_WORLD, &result);
+ }
+ else
+ {
+ MPI_Comm_compare(dd->mpi_comm_all, MPI_COMM_WORLD, &result);
+ }
+ /* Any result except MPI_UNEQUAL allows us to call MPI_Finalize */
+ bFinalize = (result != MPI_UNEQUAL);
+#else
+ bFinalize = TRUE;
+#endif
+ bMaster = (cr != NULL && MASTER(cr)) || (dd != NULL && DDMASTER(dd));
+
+ va_start(ap, fmt);
+ gmx_fatal_mpi_va(f_errno, file, line, bMaster, bFinalize, fmt, ap);
+ va_end(ap);
+}
#include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
+
#include "types/commrec.h"
-#include "sysstuff.h"
#include "names.h"
#include "macros.h"
#include "nrnb.h"
-#include "main.h"
#include "gromacs/utility/smalloc.h"
typedef struct {
fprintf(out, " %-32s %16s %15.3f %6.1f\n",
"Total", "", *mflop, tfrac);
fprintf(out, "%s\n\n", myline);
+
+ if (nrnb->n[eNR_NBKERNEL_GENERIC] > 0)
+ {
+ fprintf(out,
+ "WARNING: Using the slow generic C kernel. This is fine if you are\n"
+ "comparing different implementations or MD software. Routine\n"
+ "simulations should use a different non-bonded setup for much better\n"
+ "performance.\n\n");
+ }
}
}
/* This file is completely threadsafe - please keep it that way! */
#include <stdio.h>
+#include <stdlib.h>
+
#include "typedefs.h"
#include "types/commrec.h"
#include "names.h"
#include "txtdump.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "macros.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
int pr_indent(FILE *fp, int n)
const char *format;
int i, j;
- if (getenv("LONGFORMAT") != NULL)
+ if (getenv("GMX_PRINT_LONGFORMAT") != NULL)
{
format = flong;
}
const char *format;
int i, j;
- if (getenv("LONGFORMAT") != NULL)
+ if (getenv("GMX_PRINT_LONGFORMAT") != NULL)
{
format = flong;
}
const char *flong = "%15.8e";
const char *format;
- if (getenv("LONGFORMAT") != NULL)
+ if (getenv("GMX_PRINT_LONGFORMAT") != NULL)
{
format = flong;
}
for (i = 0; i <= block->nr; i++)
{
(void) pr_indent(fp, indent+INDENT);
- (void) fprintf(fp, "%s->index[%d]=%u\n",
+ (void) fprintf(fp, "%s->index[%d]=%d\n",
title, bShowNumbers ? i : -1, block->index[i]);
}
for (i = 0; i < block->nra; i++)
{
(void) pr_indent(fp, indent+INDENT);
- (void) fprintf(fp, "%s->a[%d]=%u\n",
+ (void) fprintf(fp, "%s->a[%d]=%d\n",
title, bShowNumbers ? i : -1, block->a[i]);
}
}
(void) fprintf(fp, "\n");
size = pr_indent(fp, indent+INDENT);
}
- size += fprintf(fp, "%u", block->a[j]);
+ size += fprintf(fp, "%d", block->a[j]);
}
(void) fprintf(fp, "}\n");
start = end;
* the research papers on the package. Check out http://www.gromacs.org.
*/
/* This file is completely threadsafe - keep it that way! */
+#include "viewit.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
#include "oenv.h"
-#include "viewit.h"
-#include "gromacs/utility/cstringutil.h"
-#include "gromacs/fileio/filenm.h"
#include "macros.h"
-#include "gmx_fatal.h"
+#include "gromacs/fileio/filenm.h"
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
static const int can_view_ftp[] = {
0,
"ghostview", "display", NULL, "xterm -e rasmol"
};
-int can_view(int ftp)
+static int can_view(int ftp)
{
int i;
case efXVG:
if (!(cmd = getenv(env)) )
{
- if (getenv("XMGR") )
+ if (getenv("GMX_USE_XMGR") )
{
cmd = "xmgr";
}
#endif
#include <ctype.h>
-#include <stdlib.h>
#include <limits.h>
-#include "sysstuff.h"
-#include "gromacs/utility/smalloc.h"
+#include <stdlib.h>
+
#include "typedefs.h"
-#include "physics.h"
+#include "gromacs/math/units.h"
#include "names.h"
-#include "gmx_fatal.h"
#include "macros.h"
-#include "index.h"
-#include "symtab.h"
+#include "gromacs/topology/index.h"
#include "gromacs/utility/cstringutil.h"
#include "readinp.h"
#include "warninp.h"
#include "readir.h"
#include "toputil.h"
-#include "index.h"
#include "network.h"
-#include "vec.h"
-#include "pbc.h"
-#include "mtop_util.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/topology/mtop_util.h"
#include "chargegroup.h"
#include "inputrec.h"
#include "calc_verletbuf.h"
+#include "gromacs/topology/block.h"
+#include "gromacs/topology/symtab.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
+
#define MAXPTR 254
#define NOGID 255
ir->epsilon_r = 1.0;
}
- if (getenv("GALACTIC_DYNAMICS") == NULL)
+ if (getenv("GMX_DO_GALACTIC_DYNAMICS") == NULL)
{
sprintf(err_buf, "epsilon-r must be >= 0 instead of %g\n", ir->epsilon_r);
CHECK(ir->epsilon_r < 0);
void make_IMD_group(t_IMD *IMDgroup, char *IMDgname, t_blocka *grps, char **gnames)
{
- int ig = -1, i;
+ int ig, i;
ig = search_string(IMDgname, grps->nr, gnames);
#include <config.h>
#endif
+#include <assert.h>
#include <math.h>
#include <string.h>
-#include <assert.h>
-#include "sysstuff.h"
+
#include "typedefs.h"
#include "types/commrec.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "gromacs/math/utilities.h"
#include "macros.h"
-#include "gromacs/utility/smalloc.h"
#include "macros.h"
-#include "gmx_fatal.h"
-#include "physics.h"
+#include "gromacs/math/units.h"
#include "force.h"
#include "tables.h"
#include "nonbonded.h"
-#include "invblock.h"
#include "names.h"
#include "network.h"
-#include "pbc.h"
#include "ns.h"
-#include "mshift.h"
#include "txtdump.h"
#include "coulomb.h"
#include "md_support.h"
#include "domdec.h"
#include "qmmm.h"
#include "copyrite.h"
-#include "mtop_util.h"
+#include "gromacs/topology/mtop_util.h"
#include "nbnxn_simd.h"
#include "nbnxn_search.h"
#include "nbnxn_atomdata.h"
#include "gmx_detect_hardware.h"
#include "inputrec.h"
+#include "gromacs/pbcutil/ishift.h"
+#include "gromacs/pbcutil/pbc.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/smalloc.h"
+
#include "types/nbnxn_cuda_types_ext.h"
#include "gpu_utils.h"
#include "nbnxn_cuda_data_mgmt.h"
lookup_nbnxn_kernel_name(*kernel_type),
nbnxn_kernel_pairlist_simple(*kernel_type) ? NBNXN_CPU_CLUSTER_I_SIZE : NBNXN_GPU_CLUSTER_SIZE,
nbnxn_kernel_to_cj_size(*kernel_type));
+
+ if (nbnxnk4x4_PlainC == *kernel_type ||
+ nbnxnk8x8x8_PlainC == *kernel_type)
+ {
+ md_print_warn(cr, fp,
+ "WARNING: Using the slow %s kernels. This should\n"
+ "not happen during routine usage on supported platforms.\n\n",
+ lookup_nbnxn_kernel_name(*kernel_type));
+ }
}
}
#include "typedefs.h"
+ #include "gromacs/mdlib/nbnxn_simd.h"
+
#ifdef {0}
- {1}
- #include "gromacs/simd/macros.h"
- #include "gromacs/simd/vector_operations.h"
+ {1}#include "gromacs/simd/vector_operations.h"
+
{2}
#define GMX_SIMD_J_UNROLL_SIZE {3}
#include "{4}"
#include "../nbnxn_kernel_common.h"
#include "gmx_omp_nthreads.h"
#include "types/force_flags.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
/*! \brief Kinds of electrostatic treatments in SIMD Verlet kernels
*/
#else /* {0} */
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#endif /* {0} */
#ifdef GMX_NBNXN_SIMD_4XN
#include "gromacs/simd/vector_operations.h"
+
#if !(GMX_SIMD_REAL_WIDTH == 2 || GMX_SIMD_REAL_WIDTH == 4 || GMX_SIMD_REAL_WIDTH == 8)
#error "unsupported SIMD width"
#endif
#include "../nbnxn_kernel_common.h"
#include "gmx_omp_nthreads.h"
#include "types/force_flags.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
/*! \brief Kinds of electrostatic treatments in SIMD Verlet kernels
*/
#else /* GMX_NBNXN_SIMD_4XN */
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#endif /* GMX_NBNXN_SIMD_4XN */
#ifdef GMX_QMMM_GAUSSIAN
#include <math.h>
-#include "sysstuff.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "typedefs.h"
#include "macros.h"
#include "gromacs/utility/smalloc.h"
-#include "physics.h"
-#include "macros.h"
-#include "vec.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/vec.h"
#include "force.h"
-#include "invblock.h"
#include "gromacs/fileio/confio.h"
#include "names.h"
#include "network.h"
-#include "pbc.h"
#include "ns.h"
#include "nrnb.h"
#include "bondf.h"
-#include "mshift.h"
#include "txtdump.h"
#include "qmmm.h"
-#include <stdio.h>
-#include <string.h>
-#include "gmx_fatal.h"
-#include "typedefs.h"
-#include <stdlib.h>
+#include "gromacs/utility/fatalerror.h"
/* TODO: this should be made thread-safe */
/* we read the number of cpus and environment from the environment
* if set.
*/
- buf = getenv("NCPUS");
+ buf = getenv("GMX_QM_GAUSSIAN_NCPUS");
if (buf)
{
sscanf(buf, "%d", &qm->nQMcpus);
qm->nQMcpus = 1;
}
fprintf(stderr, "number of CPUs for gaussian = %d\n", qm->nQMcpus);
- buf = getenv("MEM");
+ buf = getenv("GMX_QM_GAUSSIAN_MEMORY");
if (buf)
{
sscanf(buf, "%d", &qm->QMmem);
qm->QMmem = 50000000;
}
fprintf(stderr, "memory for gaussian = %d\n", qm->QMmem);
- buf = getenv("ACC");
+ buf = getenv("GMX_QM_ACCURACY");
if (buf)
{
sscanf(buf, "%d", &qm->accuracy);
}
fprintf(stderr, "accuracy in l510 = %d\n", qm->accuracy);
- buf = getenv("CPMCSCF");
+ buf = getenv("GMX_QM_CPMCSCF");
if (buf)
{
sscanf(buf, "%d", &i);
{
fprintf(stderr, "NOT using cp-mcscf in l1003\n");
}
- buf = getenv("SASTEP");
+ buf = getenv("GMX_QM_SA_STEP");
if (buf)
{
sscanf(buf, "%d", &qm->SAstep);
fclose(out);
}
/* gaussian settings on the system */
- buf = getenv("GAUSS_DIR");
+ buf = getenv("GMX_QM_GAUSS_DIR");
fprintf(stderr, "%s", buf);
if (buf)
}
else
{
- gmx_fatal(FARGS, "no $GAUSS_DIR, check gaussian manual\n");
+ gmx_fatal(FARGS, "no $GMX_QM_GAUSS_DIR, check gaussian manual\n");
}
- buf = getenv("GAUSS_EXE");
+ buf = getenv("GMX_QM_GAUSS_EXE");
if (buf)
{
qm->gauss_exe = strdup(buf);
}
else
{
- gmx_fatal(FARGS, "no $GAUSS_EXE, check gaussian manual\n");
+ gmx_fatal(FARGS, "no $GMX_QM_GAUSS_EXE set, check gaussian manual\n");
}
- buf = getenv("DEVEL_DIR");
+ buf = getenv("GMX_QM_MODIFIED_LINKS_DIR");
if (buf)
{
qm->devel_dir = strdup (buf);
}
else
{
- gmx_fatal(FARGS, "no $DEVEL_DIR, this is were the modified links reside.\n");
+ gmx_fatal(FARGS, "no $GMX_QM_MODIFIED_LINKS_DIR, this is were the modified links reside.\n");
}
/* if(fr->bRF){*/
if (!step)
{
snew(buf, 20);
- buf = getenv("STATE");
+ buf = getenv("GMX_QM_GROUND_STATE");
if (buf)
{
sscanf(buf, "%d", &state);
#endif
#include <math.h>
-#include "sysstuff.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
#include "typedefs.h"
#include "macros.h"
#include "gromacs/utility/smalloc.h"
-#include "physics.h"
-#include "macros.h"
-#include "vec.h"
+#include "gromacs/math/units.h"
+#include "gromacs/math/vec.h"
#include "force.h"
-#include "invblock.h"
#include "gromacs/fileio/confio.h"
#include "names.h"
#include "network.h"
-#include "pbc.h"
#include "ns.h"
#include "nrnb.h"
#include "bondf.h"
-#include "mshift.h"
#include "txtdump.h"
#include "qmmm.h"
-#include <stdio.h>
-#include <string.h>
-#include "gmx_fatal.h"
-#include "typedefs.h"
-#include <stdlib.h>
+#include "gromacs/utility/fatalerror.h"
/* ORCA interface routines */
snew(buf, 200);
/* ORCA settings on the system */
- buf = getenv("BASENAME");
+ buf = getenv("GMX_QM_ORCA_BASENAME");
if (buf)
{
snew(qm->orca_basename, 200);
}
else
{
- gmx_fatal(FARGS, "$BASENAME not set\n");
+ gmx_fatal(FARGS, "$GMX_QM_ORCA_BASENAME is not set\n");
}
/* ORCA directory on the system */
snew(buf, 200);
- buf = getenv("ORCA_PATH");
+ buf = getenv("GMX_ORCA_PATH");
if (buf)
{
}
else
{
- gmx_fatal(FARGS, "$ORCA_PATH not set, check manual\n");
+ gmx_fatal(FARGS, "$GMX_ORCA_PATH not set, check manual\n");
}
fprintf(stderr, "Setting ORCA path to: %s...\n", qm->orca_dir);
--- /dev/null
- #if defined GMX_LIB_MPI && defined GMX_TARGET_BGQ
- #include <spi/include/kernel/location.h>
- #endif
-
- int gmx_physicalnode_id_hash(void)
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * 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
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+#include "basenetwork.h"
+
+#include "config.h"
+
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include <algorithm>
+#include <exception>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/programcontext.h"
+
+int gmx_gethostname(char *name, size_t len)
+{
+ if (len < 8)
+ {
+ gmx_incons("gmx_gethostname called with len<8");
+ }
+#if defined(HAVE_UNISTD_H) && !defined(__native_client__)
+ if (gethostname(name, len-1) != 0)
+ {
+ std::strncpy(name, "unknown", 8);
+ return -1;
+ }
+ return 0;
+#else
+ std::strncpy(name, "unknown", 8);
+ return -1;
+#endif
+}
+
+gmx_bool gmx_mpi_initialized(void)
+{
+#ifndef GMX_MPI
+ return 0;
+#else
+ int n;
+ MPI_Initialized(&n);
+
+ return n;
+#endif
+}
+
+int gmx_node_num(void)
+{
+#ifndef GMX_MPI
+ return 1;
+#else
+ int i;
+ (void) MPI_Comm_size(MPI_COMM_WORLD, &i);
+ return i;
+#endif
+}
+
+int gmx_node_rank(void)
+{
+#ifndef GMX_MPI
+ return 0;
+#else
+ int i;
+ (void) MPI_Comm_rank(MPI_COMM_WORLD, &i);
+ return i;
+#endif
+}
+
- int gmx_hostname_num()
- {
- #ifndef GMX_MPI
- return 0;
- #else
- #ifdef GMX_THREAD_MPI
- /* thread-MPI currently puts the thread number in the process name,
- * we might want to change this, as this is inconsistent with what
- * most MPI implementations would do when running on a single node.
- */
- return 0;
- #else
- int resultlen, hostnum, i, j;
- char mpi_hostname[MPI_MAX_PROCESSOR_NAME], hostnum_str[MPI_MAX_PROCESSOR_NAME];
++static int mpi_hostname_hash(void)
+{
+ int hash_int;
+
+#ifndef GMX_LIB_MPI
+ /* We have a single physical node */
+ hash_int = 0;
+#else
+ int resultlen;
+ char mpi_hostname[MPI_MAX_PROCESSOR_NAME];
+
+ /* This procedure can only differentiate nodes with different names.
+ * Architectures where different physical nodes have identical names,
+ * such as IBM Blue Gene, should use an architecture specific solution.
+ */
+ MPI_Get_processor_name(mpi_hostname, &resultlen);
+
+ /* The string hash function returns an unsigned int. We cast to an int.
+ * Negative numbers are converted to positive by setting the sign bit to 0.
+ * This makes the hash one bit smaller.
+ * A 63-bit hash (with 64-bit int) should be enough for unique node hashes,
+ * even on a million node machine. 31 bits might not be enough though!
+ */
+ hash_int =
+ (int)gmx_string_fullhash_func(mpi_hostname, gmx_string_hash_init);
+ if (hash_int < 0)
+ {
+ hash_int -= INT_MIN;
+ }
+#endif
+
+ return hash_int;
+}
+
- MPI_Get_processor_name(mpi_hostname, &resultlen);
- #ifdef GMX_TARGET_BGQ
++#if defined GMX_LIB_MPI && defined GMX_TARGET_BGQ
++#include <spi/include/kernel/location.h>
+
- #else
- /* This procedure can only differentiate nodes with host names
- * that end on unique numbers.
- */
- i = 0;
- j = 0;
- /* Only parse the host name up to the first dot */
- while (i < resultlen && mpi_hostname[i] != '.')
- {
- if (std::isdigit(mpi_hostname[i]))
- {
- hostnum_str[j++] = mpi_hostname[i];
- }
- i++;
- }
- hostnum_str[j] = '\0';
- if (j == 0)
- {
- hostnum = 0;
- }
- else
- {
- /* Use only the last 9 decimals, so we don't overflow an int */
- hostnum = std::strtol(hostnum_str + std::max(0, j-9), NULL, 10);
- }
- #endif
++static int bgq_nodenum(void)
++{
++ int hostnum;
+ Personality_t personality;
+ Kernel_GetPersonality(&personality, sizeof(personality));
+ /* Each MPI rank has a unique coordinate in a 6-dimensional space
+ (A,B,C,D,E,T), with dimensions A-E corresponding to different
+ physical nodes, and T within each node. Each node has sixteen
+ physical cores, each of which can have up to four hardware
+ threads, so 0 <= T <= 63 (but the maximum value of T depends on
+ the confituration of ranks and OpenMP threads per
+ node). However, T is irrelevant for computing a suitable return
+ value for gmx_hostname_num().
+ */
+ hostnum = personality.Network_Config.Acoord;
+ hostnum *= personality.Network_Config.Bnodes;
+ hostnum += personality.Network_Config.Bcoord;
+ hostnum *= personality.Network_Config.Cnodes;
+ hostnum += personality.Network_Config.Ccoord;
+ hostnum *= personality.Network_Config.Dnodes;
+ hostnum += personality.Network_Config.Dcoord;
+ hostnum *= personality.Network_Config.Enodes;
+ hostnum += personality.Network_Config.Ecoord;
- std::fprintf(debug, "In gmx_hostname_num: hostname '%s', hostnum %d\n",
- mpi_hostname, hostnum);
- #ifdef GMX_TARGET_BGQ
+
+ if (debug)
+ {
- #endif
+ std::fprintf(debug,
+ "Torus ID A: %d / %d B: %d / %d C: %d / %d D: %d / %d E: %d / %d\n"
+ "Node ID T: %d / %d core: %d / %d hardware thread: %d / %d\n",
+ personality.Network_Config.Acoord,
+ personality.Network_Config.Anodes,
+ personality.Network_Config.Bcoord,
+ personality.Network_Config.Bnodes,
+ personality.Network_Config.Ccoord,
+ personality.Network_Config.Cnodes,
+ personality.Network_Config.Dcoord,
+ personality.Network_Config.Dnodes,
+ personality.Network_Config.Ecoord,
+ personality.Network_Config.Enodes,
+ Kernel_ProcessorCoreID(),
+ 16,
+ Kernel_ProcessorID(),
+ 64,
+ Kernel_ProcessorThreadID(),
+ 4);
+ }
+ return hostnum;
++}
++#endif
++
++int gmx_physicalnode_id_hash(void)
++{
++ int hash;
++
++#ifndef GMX_MPI
++ hash = 0;
++#else
++#ifdef GMX_THREAD_MPI
++ /* thread-MPI currently puts the thread number in the process name,
++ * we might want to change this, as this is inconsistent with what
++ * most MPI implementations would do when running on a single node.
++ */
++ hash = 0;
++#else
++#ifdef GMX_TARGET_BGQ
++ hash = bgq_nodenum();
++#else
++ hash = mpi_hostname_hash();
+#endif
+#endif
++#endif
++
++ if (debug)
++ {
++ fprintf(debug, "In gmx_physicalnode_id_hash: hash %d\n", hash);
++ }
++
++ return hash;
+}
+
+#ifdef GMX_LIB_MPI
+void gmx_abort(int errorno)
+{
+ const char *programName = "GROMACS";
+ try
+ {
+ programName = gmx::getProgramContext().displayName();
+ }
+ catch (const std::exception &)
+ {
+ }
+ const int nnodes = gmx_node_num();
+ const int noderank = gmx_node_rank();
+ if (nnodes > 1)
+ {
+ std::fprintf(stderr, "Halting parallel program %s on node %d out of %d\n",
+ programName, noderank, nnodes);
+ }
+ else
+ {
+ std::fprintf(stderr, "Halting program %s\n", programName);
+ }
+
+ MPI_Abort(MPI_COMM_WORLD, errorno);
+ std::exit(errorno);
+}
+#endif
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#include "gmx_fatal.h"
-#include "gmx_fatal_collective.h"
+#include "fatalerror.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <ctype.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <string.h>
+#include <cerrno>
+#include <cstdarg>
+#include <cstdlib>
+#include <cstring>
-#include "thread_mpi/threads.h"
+#include <exception>
-#include "main.h"
-#include "types/commrec.h"
-#include "network.h"
-#include "copyrite.h"
-#include "macros.h"
+#include "thread_mpi/threads.h"
-#include "gromacs/fileio/futil.h"
-#include "gromacs/fileio/gmxfio.h"
+#include "gromacs/utility/basenetwork.h"
+#include "gromacs/utility/baseversion.h"
+#include "gromacs/utility/common.h"
#include "gromacs/utility/cstringutil.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/programcontext.h"
#include "gromacs/utility/smalloc.h"
static gmx_bool bDebug = FALSE;
static FILE *log_file = NULL;
-static tMPI_Thread_mutex_t debug_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
-static tMPI_Thread_mutex_t where_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
+static tMPI_Thread_mutex_t debug_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
+static tMPI_Thread_mutex_t where_mutex = TMPI_THREAD_MUTEX_INITIALIZER;
+
+static const char *const gmxuser
+ = "Please report this to the mailing list (gmx-users@gromacs.org)";
gmx_bool bDebugMode(void)
{
- gmx_bool ret;
-#if 0
- tMPI_Thread_mutex_lock(&debug_mutex);
-#endif
- ret = bDebug;
-#if 0
- tMPI_Thread_mutex_unlock(&debug_mutex);
-#endif
return bDebug;
}
if (bFirst) /* we repeat the check in the locked section because things
might have changed */
{
- if ((temp = getenv("WHERE")) != NULL)
+ if ((temp = getenv("GMX_PRINT_DEBUG_LINES")) != NULL)
{
nskip = strtol(temp, NULL, 10);
}
static int fatal_errno = 0;
-static void quit_gmx(const char *msg)
+static void default_error_handler(const char *msg)
{
tMPI_Thread_mutex_lock(&debug_mutex);
if (fatal_errno == 0)
}
perror(msg);
}
+ tMPI_Thread_mutex_unlock(&debug_mutex);
+}
-#ifdef GMX_LIB_MPI
- if (gmx_mpi_initialized())
- {
- int nnodes;
- int noderank;
+static void (*gmx_error_handler)(const char *msg) = default_error_handler;
- nnodes = gmx_node_num();
- noderank = gmx_node_rank();
+void set_gmx_error_handler(void (*func)(const char *msg))
+{
+ // TODO: Either this is unnecessary, or also reads to the handler should be
+ // protected by a mutex.
+ tMPI_Thread_mutex_lock(&debug_mutex);
+ gmx_error_handler = func;
+ tMPI_Thread_mutex_unlock(&debug_mutex);
+}
- if (nnodes > 1)
- {
- fprintf(stderr, "Error on node %d, will try to stop all the nodes\n",
- noderank);
- }
- gmx_abort(noderank, nnodes, -1);
- }
-#endif
+static void call_error_handler(const char *key, const char *file, int line, const char *msg)
+{
+ char buf[10240], errerrbuf[1024];
+ const char *llines = "-------------------------------------------------------";
+ char *strerr;
- if (debug)
+ if (msg == NULL)
{
- fflush(debug);
+ sprintf(errerrbuf, "Empty fatal_error message. %s", gmxuser);
}
- if (bDebugMode())
+ // In case ProgramInfo is not initialized and there is an issue with the
+ // initialization, fall back to "GROMACS".
+ const char *programName = "GROMACS";
+ try
+ {
+ programName = gmx::getProgramContext().displayName();
+ }
+ catch (const std::exception &)
{
- fprintf(stderr, "dump core (y/n):");
- fflush(stderr);
- if (toupper(getc(stdin)) != 'N')
- {
- (void) abort();
- }
}
- exit(fatal_errno);
- tMPI_Thread_mutex_unlock(&debug_mutex);
+ strerr = gmx_strerror(key);
+ sprintf(buf, "\n%s\nProgram %s, %s\n"
+ "Source code file: %s, line: %d\n\n"
+ "%s:\n%s\nFor more information and tips for troubleshooting, please check the GROMACS\n"
+ "website at http://www.gromacs.org/Documentation/Errors\n%s\n",
+ llines, programName, gmx_version(), file, line,
+ strerr, msg ? msg : errerrbuf, llines);
+ free(strerr);
+
+ gmx_error_handler(buf);
}
-/* The function below should be identical to quit_gmx,
- * except that is does not actually quit and call gmx_abort.
- */
-static void quit_gmx_noquit(const char *msg)
+GMX_ATTRIBUTE_NORETURN static void do_exit(bool bMaster, bool bFinalize)
{
- tMPI_Thread_mutex_lock(&debug_mutex);
- if (!fatal_errno)
- {
- if (log_file)
- {
- fprintf(log_file, "%s\n", msg);
- }
- fprintf(stderr, "%s\n", msg);
- /* we set it to no-zero because if this function is called, something
- has gone wrong */
- fatal_errno = 255;
- }
- else
- {
- if (fatal_errno != -1)
- {
- errno = fatal_errno;
- }
- perror(msg);
- }
-
-#ifndef GMX_LIB_MPI
if (debug)
{
fflush(debug);
}
- if (bDebugMode())
+
+#ifdef GMX_MPI
+ if (gmx_mpi_initialized())
{
- fprintf(stderr, "dump core (y/n):");
- fflush(stderr);
- if (toupper(getc(stdin)) != 'N')
+ if (bFinalize)
{
- (void) abort();
+ /* Broadcast the fatal error number possibly modified
+ * on the master process, in case the user would like
+ * to use the return status on a non-master process.
+ * The master process in cr and dd always has global rank 0.
+ */
+ MPI_Bcast(&fatal_errno, sizeof(fatal_errno), MPI_BYTE,
+ 0, MPI_COMM_WORLD);
+
+ /* Finalize nicely instead of aborting */
+ MPI_Finalize();
}
- }
+ else if (bMaster)
+ {
+#ifdef GMX_LIB_MPI
+ gmx_abort(1);
#endif
-
- tMPI_Thread_mutex_unlock(&debug_mutex);
-}
-
-void gmx_fatal(int f_errno, const char *file, int line, const char *fmt, ...)
-{
- va_list ap;
- char msg[STRLEN];
-
- va_start(ap, fmt);
- vsprintf(msg, fmt, ap);
- va_end(ap);
-
- tMPI_Thread_mutex_lock(&debug_mutex);
- fatal_errno = f_errno;
- tMPI_Thread_mutex_unlock(&debug_mutex);
-
- _gmx_error("fatal", msg, file, line);
-}
-
-void gmx_fatal_collective(int f_errno, const char *file, int line,
- const t_commrec *cr, gmx_domdec_t *dd,
- const char *fmt, ...)
-{
- gmx_bool bFinalize;
- va_list ap;
- char msg[STRLEN];
-#ifdef GMX_MPI
- int result;
+ }
+ else
+ {
+ /* Let all other processes wait till the master has printed
+ * the error message and issued MPI_Abort.
+ */
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+ }
+#else
+ GMX_UNUSED_VALUE(bMaster);
+ GMX_UNUSED_VALUE(bFinalize);
#endif
- bFinalize = TRUE;
-
-#ifdef GMX_MPI
- /* Check if we are calling on all processes in MPI_COMM_WORLD */
- if (cr != NULL)
- {
- MPI_Comm_compare(cr->mpi_comm_mysim, MPI_COMM_WORLD, &result);
- }
- else
+ if (bDebugMode())
{
- MPI_Comm_compare(dd->mpi_comm_all, MPI_COMM_WORLD, &result);
+ std::abort();
}
- /* Any result except MPI_UNEQUAL allows us to call MPI_Finalize */
- bFinalize = (result != MPI_UNEQUAL);
-#endif
+ std::exit(1);
+}
- if ((cr != NULL && MASTER(cr) ) ||
- (dd != NULL && DDMASTER(dd)))
+void gmx_fatal_mpi_va(int f_errno, const char *file, int line,
+ gmx_bool bMaster, gmx_bool bFinalize,
+ const char *fmt, va_list ap)
+{
+ if (bMaster)
{
- va_start(ap, fmt);
+ char msg[STRLEN];
vsprintf(msg, fmt, ap);
- va_end(ap);
tMPI_Thread_mutex_lock(&debug_mutex);
fatal_errno = f_errno;
tMPI_Thread_mutex_unlock(&debug_mutex);
- if (bFinalize)
- {
- /* Use an error handler that does not quit */
- set_gmx_error_handler(quit_gmx_noquit);
- }
-
- _gmx_error("fatal", msg, file, line);
+ call_error_handler("fatal", file, line, msg);
}
-#ifdef GMX_MPI
- if (bFinalize)
- {
- /* Broadcast the fatal error number possibly modified
- * on the master process, in case the user would like
- * to use the return status on a non-master process.
- * The master process in cr and dd always has global rank 0.
- */
- MPI_Bcast(&fatal_errno, sizeof(fatal_errno), MPI_BYTE,
- 0, MPI_COMM_WORLD);
-
- /* Finalize nicely instead of aborting */
- MPI_Finalize();
- }
- else
- {
- /* Let all other processes wait till the master has printed
- * the error message and issued MPI_Abort.
- */
- MPI_Barrier(MPI_COMM_WORLD);
- }
-#endif
+ do_exit(bMaster, bFinalize);
+}
- exit(fatal_errno);
+void gmx_fatal(int f_errno, const char *file, int line, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ gmx_fatal_mpi_va(f_errno, file, line, TRUE, FALSE, fmt, ap);
+ va_end(ap);
}
/*
if (!bDebug) /* another thread hasn't already run this*/
{
no_buffers();
- debug = gmx_fio_fopen(dbgfile, "w+");
+ debug = gmx_ffopen(dbgfile, "w+");
bDebug = TRUE;
if (dbglevel >= 2)
{
tMPI_Thread_mutex_unlock(&debug_mutex);
}
-static const char *gmxuser = "Please report this to the mailing list (gmx-users@gromacs.org)";
-
-static void (*gmx_error_handler)(const char *msg) = quit_gmx;
-
-void set_gmx_error_handler(void (*func)(const char *msg))
-{
- tMPI_Thread_mutex_lock(&debug_mutex);
- gmx_error_handler = func;
- tMPI_Thread_mutex_unlock(&debug_mutex);
-}
-
char *gmx_strerror(const char *key)
{
typedef struct {
{ "input", "Input error or input inconsistency" },
{ "mem", "Memory allocation/freeing error" },
{ "open", "Can not open file" },
- { "range", "Range checking error" }
+ { "range", "Range checking error" },
+ { NULL, NULL}
};
-#define NMSG asize(msg)
- char buf[1024];
- size_t i;
if (key == NULL)
{
}
else
{
- for (i = 0; (i < NMSG); i++)
+ for (size_t i = 0; msg[i].key != NULL; ++i)
{
if (strcmp(key, msg[i].key) == 0)
{
- break;
+ return strdup(msg[i].msg);
}
}
- if (i == NMSG)
- {
- sprintf(buf, "No error message associated with key %s\n%s", key, gmxuser);
- return strdup(buf);
- }
- else
- {
- return strdup(msg[i].msg);
- }
+ char buf[1024];
+ sprintf(buf, "No error message associated with key %s\n%s", key, gmxuser);
+ return strdup(buf);
}
}
void _gmx_error(const char *key, const char *msg, const char *file, int line)
{
- char buf[10240], errerrbuf[1024];
- const char *llines = "-------------------------------------------------------";
- char *strerr;
-
- /* protect the audience from suggestive discussions */
-
- if (msg == NULL)
- {
- sprintf(errerrbuf, "Empty fatal_error message. %s", gmxuser);
- }
-
- strerr = gmx_strerror(key);
- sprintf(buf, "\n%s\nProgram %s, %s\n"
- "Source code file: %s, line: %d\n\n"
- "%s:\n%s\nFor more information and tips for troubleshooting, please check the GROMACS\n"
- "website at http://www.gromacs.org/Documentation/Errors\n%s\n",
- llines, ShortProgram(), GromacsVersion(), file, line,
- strerr, msg ? msg : errerrbuf, llines);
- free(strerr);
-
- gmx_error_handler(buf);
+ call_error_handler(key, file, line, msg);
+ do_exit(true, false);
}
void _range_check(int n, int n_min, int n_max, const char *warn_str,
* To help us fund GROMACS development, we humbly ask that you cite
* the research papers on the package. Check out http://www.gromacs.org.
*/
+#include "gromacs/utility/futil.h"
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "thread_mpi/threads.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
-#include "gromacs/legacyheaders/types/commrec.h"
-#include "gromacs/legacyheaders/network.h"
-
-#include "gromacs/fileio/futil.h"
-#include "gromacs/fileio/path.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/path.h"
#include "gromacs/utility/programcontext.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
}
-#ifdef rewind
-#undef rewind
-#endif
-
void frewind(FILE *fp)
{
tMPI_Thread_mutex_lock(&pstack_mutex);
#endif
}
-
-gmx_bool is_pipe(FILE *fp)
-{
- tMPI_Thread_mutex_lock(&pstack_mutex);
-
- t_pstack *ps = pstack;
- while (ps != NULL)
- {
- if (ps->fp == fp)
- {
- tMPI_Thread_mutex_unlock(&pstack_mutex);
- return TRUE;
- }
- ps = ps->prev;
- }
- tMPI_Thread_mutex_unlock(&pstack_mutex);
- return FALSE;
-}
-
-
static FILE *uncompress(const char *fn, const char *mode)
{
FILE *fp;
}
}
-
-gmx_bool gmx_fexist_master(const char *fname, t_commrec *cr)
-{
- gmx_bool bExist;
-
- if (SIMMASTER(cr))
- {
- bExist = gmx_fexist(fname);
- }
- if (PAR(cr))
- {
- gmx_bcast(sizeof(bExist), &bExist, cr);
- }
- return bExist;
-}
-
-gmx_bool gmx_eof(FILE *fp)
-{
- char data[4];
- gmx_bool beof;
-
- if (is_pipe(fp))
- {
- return feof(fp);
- }
- else
- {
- if ((beof = fread(data, 1, 1, fp)) == 1)
- {
- gmx_fseek(fp, -1, SEEK_CUR);
- }
- return !beof;
- }
-}
-
static char *backup_fn(const char *file, int count_max)
{
/* Use a reasonably low value for countmax; we might
/* Check whether we should be using buffering (default) or not
* (for debugging)
*/
- if (bUnbuffered || ((bufsize = getenv("LOG_BUFS")) != NULL))
+ if (bUnbuffered || ((bufsize = getenv("GMX_LOG_BUFFER")) != NULL))
{
/* Check whether to use completely unbuffered */
if (bUnbuffered)
/* name in Buf should now be OK */
}
-int gmx_truncatefile(char *path, gmx_off_t length)
-{
-#ifdef _MSC_VER
- /* Microsoft visual studio does not have "truncate" */
- HANDLE fh;
- LARGE_INTEGER win_length;
-
- win_length.QuadPart = length;
-
- fh = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
- OPEN_EXISTING, 0, NULL);
- SetFilePointerEx(fh, win_length, NULL, FILE_BEGIN);
- SetEndOfFile(fh);
- CloseHandle(fh);
-
- return 0;
-#else
- return truncate(path, length);
-#endif
-}
-
-
int gmx_file_rename(const char *oldname, const char *newname)
{
#ifndef GMX_NATIVE_WINDOWS
--- /dev/null
- #define GMX_DOUBLE_EPS 1.11022302E-16
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * 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
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+/*! \file
+ * \brief
+ * Declares `real` and related constants.
+ *
+ * \inpublicapi
+ * \ingroup module_utility
+ */
+#ifndef GMX_UTILITY_REAL_H
+#define GMX_UTILITY_REAL_H
+
+/*! \brief Double precision accuracy */
- #define GMX_DOUBLE_MAX 1.79769312E+308
++#define GMX_DOUBLE_EPS 2.2204460492503131e-16
+
+/*! \brief Maximum double precision value - reduced 1 unit in last digit for MSVC */
- #define GMX_DOUBLE_MIN 2.22507386E-308
++#define GMX_DOUBLE_MAX 1.7976931348623157e+308
+
+/*! \brief Minimum double precision value */
- #define GMX_FLOAT_EPS 5.96046448E-08
++#define GMX_DOUBLE_MIN 2.2250738585072014e-308
+
+/*! \brief Single precision accuracy */
- #define GMX_FLOAT_MAX 3.40282346E+38
++#define GMX_FLOAT_EPS 1.19209290e-07F
+
+/*! \brief Maximum single precision value - reduced 1 unit in last digit for MSVC */
- #define GMX_FLOAT_MIN 1.17549435E-38
++#define GMX_FLOAT_MAX 3.40282346E+38F
+
+/*! \brief Minimum single precision value */
++#define GMX_FLOAT_MIN 1.175494351E-38F
+
+
+/*! \typedef real
+ * \brief Precision-dependent \Gromacs floating-point type.
+ */
+/*! \def HAVE_REAL
+ * \brief Used to check whether `real` is already defined.
+ */
+/*! \def GMX_MPI_REAL
+ * \brief MPI data type for `real`.
+ */
+/*! \def GMX_REAL_EPS
+ * \brief Accuracy for `real`.
+ */
+/*! \def GMX_REAL_MIN
+ * \brief Smallest non-zero value for `real`.
+ */
+/*! \def GMX_REAL_MAX
+ * \brief Largest finite value for `real`.
+ */
+/*! \def gmx_real_fullprecision_pfmt
+ * \brief Format string for full `real` precision.
+ */
+#ifdef GMX_DOUBLE
+
+#ifndef HAVE_REAL
+typedef double real;
+#define HAVE_REAL
+#endif
+
+#define GMX_MPI_REAL MPI_DOUBLE
+#define GMX_REAL_EPS GMX_DOUBLE_EPS
+#define GMX_REAL_MIN GMX_DOUBLE_MIN
+#define GMX_REAL_MAX GMX_DOUBLE_MAX
+#define gmx_real_fullprecision_pfmt "%21.14e"
+
+#else /* GMX_DOUBLE */
+
+#ifndef HAVE_REAL
+typedef float real;
+#define HAVE_REAL
+#endif
+
+#define GMX_MPI_REAL MPI_FLOAT
+#define GMX_REAL_EPS GMX_FLOAT_EPS
+#define GMX_REAL_MIN GMX_FLOAT_MIN
+#define GMX_REAL_MAX GMX_FLOAT_MAX
+#define gmx_real_fullprecision_pfmt "%14.7e"
+
+#endif /* GMX_DOUBLE */
+
+#endif
#include <config.h>
#endif
+#include <stdlib.h>
+
#include "typedefs.h"
-#include "gromacs/utility/smalloc.h"
-#include "sysstuff.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "vcm.h"
#include "mdebin.h"
#include "nrnb.h"
#include "calcmu.h"
-#include "index.h"
#include "vsite.h"
#include "update.h"
#include "ns.h"
#include "md_support.h"
#include "md_logging.h"
#include "network.h"
-#include "xvgr.h"
-#include "physics.h"
#include "names.h"
#include "force.h"
#include "disre.h"
#include "qmmm.h"
#include "domdec.h"
#include "domdec_network.h"
-#include "gromacs/gmxlib/topsort.h"
#include "coulomb.h"
#include "constr.h"
#include "shellfc.h"
#include "gromacs/gmxpreprocess/compute_io.h"
#include "checkpoint.h"
-#include "mtop_util.h"
+#include "gromacs/topology/mtop_util.h"
#include "sighandler.h"
#include "txtdump.h"
#include "gromacs/utility/cstringutil.h"
#include "types/iteratedconstraints.h"
#include "nbnxn_cuda_data_mgmt.h"
-#include "gromacs/utility/gmxmpi.h"
#include "gromacs/fileio/confio.h"
+#include "gromacs/fileio/mdoutf.h"
#include "gromacs/fileio/trajectory_writing.h"
#include "gromacs/fileio/trnio.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/fileio/xtcio.h"
-#include "gromacs/timing/wallcycle.h"
-#include "gromacs/timing/walltime_accounting.h"
+#include "gromacs/imd/imd.h"
+#include "gromacs/pbcutil/mshift.h"
+#include "gromacs/pbcutil/pbc.h"
#include "gromacs/pulling/pull.h"
#include "gromacs/swap/swapcoords.h"
-#include "gromacs/imd/imd.h"
+#include "gromacs/timing/wallcycle.h"
+#include "gromacs/timing/walltime_accounting.h"
+#include "gromacs/utility/gmxmpi.h"
+#include "gromacs/utility/smalloc.h"
#ifdef GMX_FAHCORE
#include "corewrap.h"
rvec mu_tot;
t_vcm *vcm;
t_state *bufstate = NULL;
- matrix *scale_tot, pcoupl_mu, M, ebox;
+ matrix pcoupl_mu, M;
gmx_nlheur_t nlh;
t_trxframe rerun_fr;
gmx_repl_ex_t repl_ex = NULL;
gmx_ekindata_t *ekind, *ekind_save;
gmx_shellfc_t shellfc;
int count, nconverged = 0;
- real timestep = 0;
- double tcount = 0;
- gmx_bool bConverged = TRUE, bOK, bSumEkinhOld, bDoReplEx, bExchanged, bNeedRepartition;
- gmx_bool bAppend;
+ double tcount = 0;
- gmx_bool bConverged = TRUE, bOK, bSumEkinhOld, bExchanged, bNeedRepartition;
++ gmx_bool bConverged = TRUE, bOK, bSumEkinhOld, bDoReplEx, bExchanged, bNeedRepartition;
gmx_bool bResetCountersHalfMaxH = FALSE;
gmx_bool bVV, bIterativeCase, bFirstIterate, bTemp, bPres, bTrotter;
gmx_bool bUpdateDoLR;
double cycles;
real saved_conserved_quantity = 0;
real last_ekin = 0;
- int iter_i;
t_extmass MassQ;
int **trotter_seq;
char sbuf[STEPSTRSIZE], sbuf2[STEPSTRSIZE];
/* Check for special mdrun options */
bRerunMD = (Flags & MD_RERUN);
- bAppend = (Flags & MD_APPENDFILES);
if (Flags & MD_RESETCOUNTERSHALFWAY)
{
if (ir->nsteps > 0)
set_constraints(constr, top, ir, mdatoms, cr);
}
- if (repl_ex_nst > 0)
- {
- /* We need to be sure replica exchange can only occur
- * when the energies are current */
- check_nst_param(fplog, cr, "nstcalcenergy", ir->nstcalcenergy,
- "repl_ex_nst", &repl_ex_nst);
- /* This check needs to happen before inter-simulation
- * signals are initialized, too */
- }
if (repl_ex_nst > 0 && MASTER(cr))
{
repl_ex = init_replica_exchange(fplog, cr->ms, state_global, ir,
bStateFromTPX = !bStateFromCP;
bInitStep = bFirstStep && (bStateFromTPX || bVV);
bStartingFromCpt = (Flags & MD_STARTFROMCPT) && bInitStep;
- bLastStep = FALSE;
bSumEkinhOld = FALSE;
- bDoReplEx = FALSE;
bExchanged = FALSE;
bNeedRepartition = FALSE;
step = ir->init_step;
step_rel = 0;
- if (ir->nstlist == -1)
- {
- init_nlistheuristics(&nlh, bGStatEveryStep, step);
- }
+ init_nlistheuristics(&nlh, bGStatEveryStep, step);
if (MULTISIM(cr) && (repl_ex_nst <= 0 ))
{
&& (ir->bExpanded) && (step > 0) && (!bStartingFromCpt));
}
+ bDoReplEx = ((repl_ex_nst > 0) && (step > 0) && !bLastStep &&
+ do_per_step(step, repl_ex_nst));
+
if (bSimAnn)
{
update_annealing_target_temp(&(ir->opts), t);
do_ene = (do_per_step(step, ir->nstenergy) || bLastStep);
- if (do_ene || do_log)
+ if (do_ene || do_log || bDoReplEx)
{
bCalcVir = TRUE;
bCalcEner = TRUE;
/* Replica exchange */
bExchanged = FALSE;
- if ((repl_ex_nst > 0) && (step > 0) && !bLastStep &&
- do_per_step(step, repl_ex_nst))
+ if (bDoReplEx)
{
bExchanged = replica_exchange(fplog, cr, repl_ex,
state_global, enerd,
#include <config.h>
#endif
-#include "sysstuff.h"
+#include <stdlib.h>
+
#include "macros.h"
#include "xutil.h"
#include "Xstuff.h"
-#include "gromacs/utility/smalloc.h"
#include "copyrite.h"
#include "logo.h"
+#include "gromacs/utility/real.h"
+#include "gromacs/utility/smalloc.h"
+
typedef struct {
int x, y, rad;
unsigned long *col;
};
#define NMESS asize(Mess)
int i;
- real wfac, hfac;
t_logo *logo;
t_windata *wd;
wd = &(logo->wd);
if (bFirst)
{
- wfac = wd->width/110.0;
- hfac = wd->height/110.0;
+ const real wfac = wd->width/110.0;
+ const real hfac = wd->height/110.0;
for (i = 0; (i < asize(c)); i++)
{
c[i].x *= wfac;
logo->bQuitOnClick = bQuitOnClick;
InitWin(&logo->wd, 0, 0, 360, 270, 1, "GROMACS");
bg = LIGHTGREY;
- if ((newcol = getenv("LOGO")) != NULL)
+ if ((newcol = getenv("GMX_LOGO_COLOR")) != NULL)
{
GetNamedColor(x11, newcol, &bg);
}
#include <config.h>
#endif
+#include <stdlib.h>
#include <string.h>
+
#include "typedefs.h"
-#include "sysstuff.h"
#include "gromacs/utility/smalloc.h"
#include "Xstuff.h"
#include "x11.h"
title = strdup(argv[0]);
/* First check environment */
- fontname = getenv("GMXFONT");
+ fontname = getenv("GMX_FONT");
display = getenv("DISPLAY");
snew(ARGV, *argc);