#include "xdrf.h"
#include "xdr_datatype.h"
-#include "futil.h"
+#include "gromacs/utility/futil.h"
/* This is just for clarity - it can never be anything but 4! */
#define XDR_INT_SIZE 4
return res;
}
-
int
xdr_xtc_seek_frame(int frame, FILE *fp, XDR *xdrs, int natoms)
{
{
return -1;
}
- if (fr != frame && abs(low-high) > header_size)
+ if (fr != frame && llabs(low-high) > header_size)
{
if (fr < frame)
{
the current time and the target time is bigger than dt and above all the distance between high
and low is bigger than 1 frame, then do another step of binary search. Otherwise stop and check
if we reached the solution */
- if ((((t < time && dt_sign >= 0) || (t > time && dt_sign == -1)) || ((t
- - time) >= dt && dt_sign >= 0)
- || ((time - t) >= -dt && dt_sign < 0)) && (abs(low - high)
- > header_size))
+ if ((((t < time && dt_sign >= 0) || (t > time && dt_sign == -1)) ||
+ ((t - time) >= dt && dt_sign >= 0) || ((time - t) >= -dt && dt_sign < 0)) &&
+ (llabs(low - high) > header_size))
{
if (dt >= 0 && dt_sign != -1)
{
}
else
{
- if (abs(low - high) <= header_size)
+ if (llabs(low - high) <= header_size)
{
break;
}
#endif
#include "gromacs/legacyheaders/copyrite.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
-#include "gromacs/legacyheaders/main.h"
#include "gromacs/legacyheaders/physics.h"
+
+#include "gromacs/fileio/gmxfio.h"
#include "gromacs/math/utilities.h"
+#include "gromacs/utility/basenetwork.h"
#include "gromacs/utility/common.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/programcontext.h"
-#include "gmxfio.h"
static const char *modeToVerb(char mode)
{
/* FIXME: The TNG atoms should contain mass and atomB info (for free
* energy calculations), i.e. in when it's available in TNG (2.0). */
- for (int atomIt = 0; atomIt < atoms->nr; atomIt++)
+ for (int atomIndex = 0; atomIndex < atoms->nr; atomIndex++)
{
- const t_atom *at = &atoms->atom[atomIt];
+ const t_atom *at = &atoms->atom[atomIndex];
/* FIXME: Currently the TNG API can only add atoms belonging to a
* residue and chain. Wait for TNG 2.0*/
if (atoms->nres > 0)
{
tng_chain_residue_add(tng, tngChain, *resInfo->name, &tngRes);
}
- tng_residue_atom_add(tng, tngRes, *(atoms->atomname[atomIt]), *(atoms->atomtype[atomIt]), &tngAtom);
+ tng_residue_atom_add(tng, tngRes, *(atoms->atomname[atomIndex]), *(atoms->atomtype[atomIndex]), &tngAtom);
}
}
tng_molecule_cnt_set(tng, *tngMol, numMolecules);
return;
}
- for (int molIt = 0; molIt < mtop->nmolblock; molIt++)
+ for (int molIndex = 0; molIndex < mtop->nmolblock; molIndex++)
{
tng_molecule_t tngMol = NULL;
const gmx_moltype_t *molType =
- &mtop->moltype[mtop->molblock[molIt].type];
+ &mtop->moltype[mtop->molblock[molIndex].type];
/* Add a molecule to the TNG trajectory with the same name as the
* current molecule. */
addTngMoleculeFromTopology(tng,
*(molType->name),
&molType->atoms,
- mtop->molblock[molIt].nmol,
+ mtop->molblock[molIndex].nmol,
&tngMol);
/* Bonds have to be deduced from interactions (constraints etc). Different
}
#ifdef GMX_USE_TNG
- /* Create a TNG molecule representing the selection groups
- * to write */
+ /* Check if all atoms in the molecule system are selected
+ * by a selection group of type specified by gtype. */
+ static gmx_bool all_atoms_selected(const gmx_mtop_t *mtop,
+ const int gtype)
+ {
+ const gmx_moltype_t *molType;
+ const t_atoms *atoms;
+
+ /* Iterate through all atoms in the molecule system and
+ * check if they belong to a selection group of the
+ * requested type. */
+ for (int molIndex = 0, i = 0; molIndex < mtop->nmoltype; molIndex++)
+ {
+ molType = &mtop->moltype[mtop->molblock[molIndex].type];
+
+ atoms = &molType->atoms;
+
+ for (int j = 0; j < mtop->molblock[molIndex].nmol; j++)
+ {
+ for (int atomIndex = 0; atomIndex < atoms->nr; atomIndex++, i++)
+ {
+ if (ggrpnr(&mtop->groups, gtype, i) != 0)
+ {
+ return FALSE;
+ }
+ }
+ }
+ }
+ return TRUE;
+ }
+
+ /* Create TNG molecules which will represent each of the selection
+ * groups for writing. But do that only if there is actually a
+ * specified selection group and it is not the whole system.
+ * TODO: Currently the only selection that is taken into account
+ * is egcCompressedX, but other selections should be added when
+ * e.g. writing energies is implemented.
+ */
static void add_selection_groups(tng_trajectory_t tng,
const gmx_mtop_t *mtop)
{
const t_atom *at;
const t_resinfo *resInfo;
const t_ilist *ilist;
- int nAtoms = 0, i = 0, j, molIt, atomIt, nameIndex;
+ int nameIndex;
int atom_offset = 0;
tng_molecule_t mol, iterMol;
tng_chain_t chain;
gmx_int64_t nMols;
char *groupName;
+ /* TODO: When the TNG molecules block is more flexible TNG selection
+ * groups should not need all atoms specified. It should be possible
+ * just to specify what molecules are selected (and/or which atoms in
+ * the molecule) and how many (if applicable). */
+
+ /* If no atoms are selected we do not need to create a
+ * TNG selection group molecule. */
+ if (mtop->groups.ngrpnr[egcCompressedX] == 0)
+ {
+ return;
+ }
+
+ /* If all atoms are selected we do not have to create a selection
+ * group molecule in the TNG molecule system. */
+ if (all_atoms_selected(mtop, egcCompressedX))
+ {
+ return;
+ }
+
/* The name of the TNG molecule containing the selection group is the
* same as the name of the selection group. */
nameIndex = *mtop->groups.grps[egcCompressedX].nm_ind;
tng_molecule_alloc(tng, &mol);
tng_molecule_name_set(tng, mol, groupName);
tng_molecule_chain_add(tng, mol, "", &chain);
- for (molIt = 0; molIt < mtop->nmoltype; molIt++)
+ for (int molIndex = 0, i = 0; molIndex < mtop->nmoltype; molIndex++)
{
- molType = &mtop->moltype[mtop->molblock[molIt].type];
+ molType = &mtop->moltype[mtop->molblock[molIndex].type];
atoms = &molType->atoms;
- for (j = 0; j < mtop->molblock[molIt].nmol; j++)
+ for (int j = 0; j < mtop->molblock[molIndex].nmol; j++)
{
bool bAtomsAdded = FALSE;
- for (atomIt = 0; atomIt < atoms->nr; atomIt++, i++)
+ for (int atomIndex = 0; atomIndex < atoms->nr; atomIndex++, i++)
{
char *res_name;
int res_id;
{
continue;
}
- at = &atoms->atom[atomIt];
+ at = &atoms->atom[atomIndex];
if (atoms->nres > 0)
{
resInfo = &atoms->resinfo[at->resind];
* original residue IDs - otherwise there might be conflicts. */
tng_chain_residue_add(tng, chain, res_name, &res);
}
- tng_residue_atom_w_id_add(tng, res, *(atoms->atomname[atomIt]),
- *(atoms->atomtype[atomIt]),
- atom_offset + atomIt, &atom);
- nAtoms++;
+ tng_residue_atom_w_id_add(tng, res, *(atoms->atomname[atomIndex]),
+ *(atoms->atomtype[atomIndex]),
+ atom_offset + atomIndex, &atom);
bAtomsAdded = TRUE;
}
/* Add bonds. */
atom_offset += atoms->nr;
}
}
- if (nAtoms != i)
+ tng_molecule_existing_add(tng, &mol);
+ tng_molecule_cnt_set(tng, mol, 1);
+ tng_num_molecule_types_get(tng, &nMols);
+ for (gmx_int64_t k = 0; k < nMols; k++)
{
- tng_molecule_existing_add(tng, &mol);
- tng_molecule_cnt_set(tng, mol, 1);
- tng_num_molecule_types_get(tng, &nMols);
- for (gmx_int64_t k = 0; k < nMols; k++)
+ tng_molecule_of_index_get(tng, k, &iterMol);
+ if (iterMol == mol)
{
- tng_molecule_of_index_get(tng, k, &iterMol);
- if (iterMol == mol)
- {
- continue;
- }
- tng_molecule_cnt_set(tng, iterMol, 0);
+ continue;
}
- }
- else
- {
- tng_molecule_free(tng, &mol);
+ tng_molecule_cnt_set(tng, iterMol, 0);
}
}
#endif
real prec)
{
#ifdef GMX_USE_TNG
- tng_compression_precision_set(tng, 1.0/prec);
+ tng_compression_precision_set(tng, prec);
#else
GMX_UNUSED_VALUE(tng);
GMX_UNUSED_VALUE(prec);
#endif
#include <math.h>
+#include <stdlib.h>
+
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "geminate.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxomp.h"
static void missing_code_message()
bBad = FALSE;
/* An acf of binary data must be one at t=0. */
- if (abs(ct[0]-1.0) > 1e-6)
+ if (fabs(ct[0]-1.0) > 1e-6)
{
ct[0] = 1.0;
- fprintf(stderr, "|ct[0]-1.0| = %1.6d. Setting ct[0] to 1.0.\n", abs(ct[0]-1.0));
+ fprintf(stderr, "|ct[0]-1.0| = %1.6f. Setting ct[0] to 1.0.\n", fabs(ct[0]-1.0));
}
for (i = 0; i < len; i++)
#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/utility/fatalerror.h"
+#include "gromacs/math/vec.h"
#include "pbc.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "index.h"
#include "gromacs/fileio/pdbio.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/fileio/matio.h"
#include "mshift.h"
-#include "xvgr.h"
+#include "gromacs/fileio/xvgr.h"
+#include "viewit.h"
#include "rmpbc.h"
#include "txtdump.h"
#include "eigio.h"
{
for (i = 0; i < n; i++)
{
- if (bSplit && i > 0 && abs(x[i]) < 1e-5)
+ if (bSplit && i > 0 && fabs(x[i]) < 1e-5)
{
if (output_env_get_print_xvgr_codes(oenv))
{
oenv);
for (i = 0; i < nframes; i++)
{
- if (bSplit && i > 0 && abs(inprod[noutvec][i]) < 1e-5)
+ if (bSplit && i > 0 && fabs(inprod[noutvec][i]) < 1e-5)
{
fprintf(xvgrout, "&\n");
}
j = 0;
for (i = 0; i < atoms.nr; i++)
{
- if (j > 0 && bSplit && abs(inprod[noutvec][i]) < 1e-5)
+ if (j > 0 && bSplit && fabs(inprod[noutvec][i]) < 1e-5)
{
fprintf(out, "TER\n");
j = 0;
#include <config.h>
#endif
+#include <assert.h>
+#include <stdlib.h>
+
#include "gromacs/commandline/pargs.h"
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
-#include "xvgr.h"
+#include "gromacs/fileio/xvgr.h"
#include "rmpbc.h"
#include "pbc.h"
#include "physics.h"
#include "gmx_ana.h"
#include "macros.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#define SQR(x) (pow(x, 2.0))
#define EPSI0 (EPSILON0*E_CHARGE*E_CHARGE*AVOGADRO/(KILO*NANO)) /* EPSILON0 in SI units */
}
}
- if (abs(qall) > 0.01)
+ if (fabs(qall) > 0.01)
{
printf("\n\nSystem not neutral (q=%f) will not calculate translational part of the dipole moment.\n", qall);
bNEU = FALSE;
xshfr[i] = 0.0;
}
}
-
+ assert(time != NULL);
if (nfr == 0)
#include <math.h>
#include <stdlib.h>
-
-#include "sysstuff.h"
#include <string.h>
+
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
#include "macros.h"
-#include "vec.h"
-#include "xvgr.h"
+#include "gromacs/math/vec.h"
+#include "gromacs/fileio/xvgr.h"
+#include "viewit.h"
#include "pbc.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/commandline/pargs.h"
#include "index.h"
#include "gromacs/fileio/tpxio.h"
ind_mini = ind_min[0];
ind_minj = ind_min[1];
}
- if (bSplit && !bFirst && abs(t/output_env_get_time_factor(oenv)) < 1e-5)
+ if (bSplit && !bFirst && fabs(t/output_env_get_time_factor(oenv)) < 1e-5)
{
fprintf(out, "&\n");
}
bFirst = TRUE;
do
{
- if (bSplit && !bFirst && abs(t/output_env_get_time_factor(oenv)) < 1e-5)
+ if (bSplit && !bFirst && fabs(t/output_env_get_time_factor(oenv)) < 1e-5)
{
fprintf(dist, "&\n");
if (num)
#include <config.h>
#endif
-#include "gromacs/utility/smalloc.h"
#include <math.h>
+#include <stdlib.h>
+
+#include "gromacs/utility/smalloc.h"
#include "macros.h"
#include "typedefs.h"
-#include "xvgr.h"
+#include "gromacs/fileio/xvgr.h"
#include "copyrite.h"
#include "gromacs/commandline/pargs.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "index.h"
-#include "gmx_fatal.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
#include "princ.h"
#include "rmpbc.h"
#include "gromacs/fileio/matio.h"
int ePBC;
t_iatom *iatom = NULL;
- matrix box;
+ matrix box = {{0}};
rvec *x, *xp, *xm = NULL, **mat_x = NULL, **mat_x2, *mat_x2_j = NULL, vec1,
vec2;
t_trxstatus *status;
for (i = 0; (i < teller); i++)
{
if (bSplit && i > 0 &&
- abs(time[bPrev ? freq*i : i]/output_env_get_time_factor(oenv)) < 1e-5)
+ fabs(time[bPrev ? freq*i : i]/output_env_get_time_factor(oenv)) < 1e-5)
{
fprintf(fp, "&\n");
}
}
for (i = 0; (i < teller); i++)
{
- if (bSplit && i > 0 && abs(time[i]) < 1e-5)
+ if (bSplit && i > 0 && fabs(time[i]) < 1e-5)
{
fprintf(fp, "&\n");
}
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/fileio/strdb.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "macros.h"
#include "index.h"
#include "pbc.h"
-#include "xvgr.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/fileio/xvgr.h"
+#include "viewit.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/fileio/matio.h"
#include "gmx_ana.h"
if (bEquiv)
{
/* set index for matching atom */
- noe_index[j] = groupnr;
+ noe_index[i] = groupnr;
/* skip matching atom */
i = j;
}
This is supposed to cover all CH3 groups and the like */
anmi = *atoms->atomname[index[i]];
anmil = strlen(anmi);
- bMatch = i < isize-3 && anmi[anmil-1] == '1';
+ bMatch = i <= isize-3 && anmi[anmil-1] == '1';
if (bMatch)
{
for (j = 1; j < 3; j++)
"equivalent atoms can be supplied ([TT]-equiv[tt]), each line containing",
"a set of equivalent atoms specified as residue number and name and",
"atom name; e.g.:[PAR]",
- "[TT]3 SER HB1 3 SER HB2[tt][PAR]",
+ "[TT]HB* 3 SER HB1 3 SER HB2[tt][PAR]",
"Residue and atom names must exactly match those in the structure",
"file, including case. Specifying non-sequential atoms is undefined."
}
/*do a first step*/
- natom = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
+ natom = read_first_x(oenv, &status, ftp2fn(efTRX, NFILE, fnm), &t, &x, box);
+ teller = 0;
do
{
rmsnow = rms_diff(isize, d, d_r);
fprintf(fp, "%g %g\n", t, rmsnow);
+ teller++;
}
while (read_next_x(oenv, status, &t, x, box));
fprintf(stderr, "\n");
gmx_ffclose(fp);
- teller = nframes_read(status);
-
close_trj(status);
calc_rms(isize, teller, dtot, dtot2, mean, &meanmax, rms, &rmsmax, rmsc, &rmscmax);
#include <math.h>
#include "typedefs.h"
#include "macros.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
#include "viewit.h"
#include "gmx_ana.h"
#include "gromacs/commandline/pargs.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/fileio/matio.h"
#include "gromacs/fileio/trxio.h"
#include "gromacs/fileio/writeps.h"
xx = xx00+(x+0.7)*psr->xboxsize;
/* draw lines whenever tick label almost zero (e.g. next trajectory) */
if (x != 0 && x < mat[i].nx-1 &&
- abs(mat[i].axis_x[x]) <
- 0.1*abs(mat[i].axis_x[x+1]-mat[i].axis_x[x]) )
+ fabs(mat[i].axis_x[x]) <
+ 0.1*fabs(mat[i].axis_x[x+1]-mat[i].axis_x[x]) )
{
ps_line (out, xx, yy00, xx, yy00+dy+2);
}
yy = yy00+(y+0.7)*psr->yboxsize;
/* draw lines whenever tick label almost zero (e.g. next trajectory) */
if (y != 0 && y < mat[i].ny-1 &&
- abs(mat[i].axis_y[y]) <
- 0.1*abs(mat[i].axis_y[y+1]-mat[i].axis_y[y]) )
+ fabs(mat[i].axis_y[y]) <
+ 0.1*fabs(mat[i].axis_y[y+1]-mat[i].axis_y[y]) )
{
ps_line (out, xx00, yy, xx00+w+2, yy);
}
sfree(mat[i].map);
mat[i].nmap = nmap;
mat[i].map = map;
- if (mat2 && (strcmp(mat[i].title, mat2[i].title) != 0))
+ if (strcmp(mat[i].title, mat2[i].title) != 0)
{
sprintf(mat[i].title+strlen(mat[i].title), " / %s", mat2[i].title);
}
- if (mat2 && (strcmp(mat[i].legend, mat2[i].legend) != 0))
+ if (strcmp(mat[i].legend, mat2[i].legend) != 0)
{
sprintf(mat[i].legend+strlen(mat[i].legend), " / %s", mat2[i].legend);
}
}
for (x = 0; x < mats[i].nx-1; x++)
{
- if (abs(mats[i].axis_x[x+1]) < 1e-5)
+ if (fabs(mats[i].axis_x[x+1]) < 1e-5)
{
for (y = 0; y < mats[i].ny; y++)
{
}
for (y = 0; y < mats[i].ny-1; y++)
{
- if (abs(mats[i].axis_y[y+1]) < 1e-5)
+ if (fabs(mats[i].axis_y[y+1]) < 1e-5)
{
for (x = 0; x < mats[i].nx; x++)
{
#include <config.h>
#endif
-#include <stdlib.h>
#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include "types/enums.h"
#include "types/hw_info.h"
#include "types/commrec.h"
-#include "gmx_fatal.h"
-#include "gmx_fatal_collective.h"
+#include "network.h"
#include "md_logging.h"
#include "gmx_cpuid.h"
-#include "gromacs/utility/smalloc.h"
#include "gpu_utils.h"
#include "copyrite.h"
#include "gmx_detect_hardware.h"
-#include "main.h"
#include "md_logging.h"
-#include "gromacs/utility/gmxomp.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"
#include "thread_mpi/threads.h"
if (detect_cuda_gpus(&hwinfo_g->gpu_info, detection_error) != 0)
{
- if (detection_error != NULL && detection_error[0] != '\0')
+ if (detection_error[0] != '\0')
{
sprintf(sbuf, ":\n %s\n", detection_error);
}
#include <math.h>
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "typedefs.h"
#include "nonbonded.h"
#include "nb_kernel.h"
#include "macros.h"
#include "nb_free_energy.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
void
gmx_nb_free_energy_kernel(const t_nblist * gmx_restrict nlist,
* 12 flops per outer iteration
* 150 flops per inner iteration
*/
+ #pragma omp atomic
inc_nrnb(nrnb, eNR_NBKERNEL_FREE_ENERGY, nlist->nri*12 + nlist->jindex[n]*150);
}
#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
-#include "sysstuff.h"
#include "gromacs/utility/smalloc.h"
#include "typedefs.h"
#include "physics.h"
#include "names.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "macros.h"
#include "index.h"
#include "symtab.h"
#include "toputil.h"
#include "index.h"
#include "network.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "pbc.h"
#include "mtop_util.h"
#include "chargegroup.h"
warning_note(wi, warn_buf);
}
- if (ir->coulombtype == eelPMESWITCH)
+ if (ir->coulombtype == eelPMESWITCH || ir->coulomb_modifier == eintmodPOTSWITCH)
{
if (ir->rcoulomb_switch/ir->rcoulomb < 0.9499)
{
- sprintf(warn_buf, "The switching range for %s should be 5%% or less, energy conservation will be good anyhow, since ewald_rtol = %g",
- eel_names[ir->coulombtype],
- ir->ewald_rtol);
+ real percentage = 100*(ir->rcoulomb-ir->rcoulomb_switch)/ir->rcoulomb;
+ sprintf(warn_buf, "The switching range for should be 5%% or less (currently %.2f%% using a switching range of %4f-%4f) for accurate electrostatic energies, energy conservation will be good regardless, since ewald_rtol = %g.",
+ percentage, ir->rcoulomb_switch, ir->rcoulomb, ir->ewald_rtol);
+ warning(wi, warn_buf);
+ }
+ }
+
+ if (ir->vdwtype == evdwSWITCH || ir->vdw_modifier == eintmodPOTSWITCH)
+ {
+ if (ir->rvdw_switch == 0)
+ {
+ sprintf(warn_buf, "rvdw-switch is equal 0 even though you are using a switched Lennard-Jones potential. This suggests it was not set in the mdp, which can lead to large energy errors. In GROMACS, 0.05 to 0.1 nm is often a reasonable vdw switching range.");
warning(wi, warn_buf);
}
}
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);
#endif
#include <ctype.h>
+#include <stdlib.h>
#include <string.h>
-#include "sysstuff.h"
#include "gromacs/utility/cstringutil.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/utility/smalloc.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "symtab.h"
#include "macros.h"
#include "resall.h"
/* Skip blank or comment-only lines */
do
{
- fgets2(buf, STRLEN, in);
- if (NULL != buf)
+ if (fgets2(buf, STRLEN, in) != NULL)
{
strip_comment(buf);
trim(buf);
}
}
- while (!feof(in) && NULL != buf && strlen(buf) == 0);
+ while (!feof(in) && strlen(buf) == 0);
- if ((buf != NULL) && (sscanf(buf, "%s%lf", name, &m) == 2))
+ if (sscanf(buf, "%s%lf", name, &m) == 2)
{
a->m = m;
add_atomtype(at, tab, a, name, nb, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 );
- fprintf(stderr, "\rAtomtype %d", nratt+1);
+ fprintf(stderr, "\rAtomtype %d", ++nratt);
+ }
+ else
+ {
+ fprintf(stderr, "\nInvalid format: %s\n", buf);
}
}
gmx_ffclose(in);
#include "types/commrec.h"
#include "gromacs/utility/smalloc.h"
#include "update.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "macros.h"
#include "physics.h"
#include "names.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "txtdump.h"
#include "nrnb.h"
#include "gromacs/random/random.h"
return ener_npt;
}
- static real vrescale_gamdev(int ia,
+ static real vrescale_gamdev(real ia,
gmx_int64_t step, gmx_int64_t *count,
gmx_int64_t seed1, gmx_int64_t seed2)
/* Gamma distribution, adapted from numerical recipes */
{
- int j;
real am, e, s, v1, v2, x, y;
double rnd[2];
- if (ia < 6)
+ assert(ia > 1);
+
+ do
{
do
{
- x = 1.0;
- for (j = 1; j <= ia; j++)
+ do
{
gmx_rng_cycle_2uniform(step, (*count)++, seed1, seed2, rnd);
- x *= rnd[0];
+ v1 = rnd[0];
+ v2 = 2.0*rnd[1] - 1.0;
}
+ while (v1*v1 + v2*v2 > 1.0 ||
+ v1*v1*GMX_REAL_MAX < 3.0*ia);
+ /* The last check above ensures that both x (3.0 > 2.0 in s)
+ * and the pre-factor for e do not go out of range.
+ */
+ y = v2/v1;
+ am = ia - 1;
+ s = sqrt(2.0*am + 1.0);
+ x = s*y + am;
}
- while (x == 0);
- x = -log(x);
- }
- else
- {
- do
- {
- do
- {
- do
- {
- gmx_rng_cycle_2uniform(step, (*count)++, seed1, seed2, rnd);
- v1 = rnd[0];
- v2 = 2.0*rnd[1] - 1.0;
- }
- while (v1*v1 + v2*v2 > 1.0 ||
- v1*v1*GMX_REAL_MAX < 3.0*ia);
- /* The last check above ensures that both x (3.0 > 2.0 in s)
- * and the pre-factor for e do not go out of range.
- */
- y = v2/v1;
- am = ia - 1;
- s = sqrt(2.0*am + 1.0);
- x = s*y + am;
- }
- while (x <= 0.0);
- e = (1.0 + y*y)*exp(am*log(x/am) - s*y);
+ while (x <= 0.0);
- gmx_rng_cycle_2uniform(step, (*count)++, seed1, seed2, rnd);
- }
- while (rnd[0] > e);
+ e = (1.0 + y*y)*exp(am*log(x/am) - s*y);
+
+ gmx_rng_cycle_2uniform(step, (*count)++, seed1, seed2, rnd);
}
+ while (rnd[0] > e);
return x;
}
return x*r;
}
- static real vrescale_sumnoises(int nn,
+ static real vrescale_sumnoises(real nn,
gmx_int64_t step, gmx_int64_t *count,
gmx_int64_t seed1, gmx_int64_t seed2)
{
/*
- * Returns the sum of n independent gaussian noises squared
+ * Returns the sum of nn independent gaussian noises squared
* (i.e. equivalent to summing the square of the return values
- * of nn calls to gmx_rng_gaussian_real).xs
+ * of nn calls to gmx_rng_gaussian_real).
*/
- real r, gauss;
-
- r = 2.0*vrescale_gamdev(nn/2, step, count, seed1, seed2);
+ const real ndeg_tol = 0.0001;
+ real r;
- if (nn % 2 == 1)
+ if (nn < 2 + ndeg_tol)
{
- gauss = gaussian_count(step, count, seed1, seed2);
+ int nn_int, i;
+ real gauss;
+
+ nn_int = (int)(nn + 0.5);
+
+ if (nn - nn_int < -ndeg_tol || nn - nn_int > ndeg_tol)
+ {
+ gmx_fatal(FARGS, "The v-rescale thermostat was called with a group with #DOF=%f, but for #DOF<3 only integer #DOF are supported", nn + 1);
+ }
+
+ r = 0;
+ for (i = 0; i < nn_int; i++)
+ {
+ gauss = gaussian_count(step, count, seed1, seed2);
- r += gauss*gauss;
+ r += gauss*gauss;
+ }
+ }
+ else
+ {
+ /* Use a gamma distribution for any real nn > 2 */
+ r = 2.0*vrescale_gamdev(0.5*nn, step, count, seed1, seed2);
}
return r;
}
- static real vrescale_resamplekin(real kk, real sigma, int ndeg, real taut,
+ static real vrescale_resamplekin(real kk, real sigma, real ndeg, real taut,
gmx_int64_t step, gmx_int64_t seed)
{
/*
#include "typedefs.h"
#include "gromacs/utility/smalloc.h"
-#include "gmx_fatal.h"
-#include "gmx_fatal_collective.h"
-#include "vec.h"
+#include "gromacs/utility/fatalerror.h"
+#include "network.h"
+#include "gromacs/math/vec.h"
#include "domdec.h"
#include "domdec_network.h"
#include "nrnb.h"
#include "gmx_omp_nthreads.h"
#include "gpu_utils.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/pdbio.h"
+#include "gromacs/imd/imd.h"
+#include "gromacs/pulling/pull.h"
+#include "gromacs/pulling/pull_rotation.h"
+#include "gromacs/swap/swapcoords.h"
#include "gromacs/timing/wallcycle.h"
+#include "gromacs/utility/basenetwork.h"
#include "gromacs/utility/gmxmpi.h"
-#include "gromacs/swap/swapcoords.h"
#include "gromacs/utility/qsort_threadsafe.h"
-#include "gromacs/pulling/pull.h"
-#include "gromacs/pulling/pull_rotation.h"
-#include "gromacs/imd/imd.h"
#define DDRANK(dd, rank) (rank)
#define DDMASTERRANK(dd) (dd->masterrank)
/* Factor to account for pressure scaling during nstlist steps */
#define DD_PRES_SCALE_MARGIN 1.02
- /* Allowed performance loss before we DLB or warn */
- #define DD_PERF_LOSS 0.05
+ /* Turn on DLB when the load imbalance causes this amount of total loss.
+ * There is a bit of overhead with DLB and it's difficult to achieve
+ * a load imbalance of less than 2% with DLB.
+ */
+ #define DD_PERF_LOSS_DLB_ON 0.02
+
+ /* Warn about imbalance due to PP or PP/PME load imbalance at this loss */
+ #define DD_PERF_LOSS_WARN 0.05
#define DD_CELL_F_SIZE(dd, di) ((dd)->nc[(dd)->dim[(di)]]+1+(di)*2+1+(di))
snew(grid_r, 2*dd->nnodes);
}
- dd_gather(dd, 2*sizeof(rvec), grid_s[0], DDMASTER(dd) ? grid_r[0] : NULL);
+ dd_gather(dd, 2*sizeof(rvec), grid_s, DDMASTER(dd) ? grid_r : NULL);
if (DDMASTER(dd))
{
fprintf(fplog, "\n");
fprintf(stderr, "\n");
- if (lossf >= DD_PERF_LOSS)
+ if (lossf >= DD_PERF_LOSS_WARN)
{
sprintf(buf,
"NOTE: %.1f %% of the available CPU time was lost due to load imbalance\n"
fprintf(fplog, "%s\n", buf);
fprintf(stderr, "%s\n", buf);
}
- if (npme > 0 && fabs(lossp) >= DD_PERF_LOSS)
+ if (npme > 0 && fabs(lossp) >= DD_PERF_LOSS_WARN)
{
sprintf(buf,
"NOTE: %.1f %% performance was lost because the PME nodes\n"
if (DDMASTER(dd))
{
bTurnOnDLB =
- (dd_force_imb_perf_loss(dd) >= DD_PERF_LOSS);
+ (dd_force_imb_perf_loss(dd) >= DD_PERF_LOSS_DLB_ON);
if (debug)
{
fprintf(debug, "step %s, imb loss %f\n",
#include "physics.h"
#include "gromacs/utility/smalloc.h"
#include "typedefs.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "names.h"
/* Margin for setting up the DD grid */
cr->npmenodes = 0;
}
- if (cr->nnodes > 12)
+ if (nnodes_div > 12)
{
ldiv = largest_divisor(nnodes_div);
/* Check if the largest divisor is more than nnodes^2/3 */
#include <string.h>
#include <assert.h>
-#include "sysstuff.h"
#include "gromacs/utility/smalloc.h"
#include "types/commrec.h"
#include "macros.h"
#include "gromacs/math/utilities.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "pbc.h"
#include "nbnxn_consts.h"
/* nbnxn_internal.h included gromacs/simd/macros.h */
int cxy_start, int cxy_end,
int *sort_work)
{
- int cxy;
- int cx, cy, cz = -1, c = -1, ncz;
- int na, ash, na_c, ind, a;
- int subdiv_z, sub_z, na_z, ash_z;
- int subdiv_y, sub_y, na_y, ash_y;
- int subdiv_x, sub_x, na_x, ash_x;
+ int cxy;
+ int cx, cy, cz = -1, c = -1, ncz;
+ int na, ash, na_c, ind, a;
+ int subdiv_z, sub_z, na_z, ash_z;
+ int subdiv_y, sub_y, na_y, ash_y;
+ int subdiv_x, sub_x, na_x, ash_x;
- /* cppcheck-suppress unassignedVariable */
nbnxn_bb_t bb_work_array[2], *bb_work_aligned;
bb_work_aligned = (nbnxn_bb_t *)(((size_t)(bb_work_array+1)) & (~((size_t)15)));
cj_ind_start = nbl_ci->cj_ind_start;
cj_ind_end = nbl_ci->cj_ind_end;
- /* In worst case we have alternating energy groups and create npair lists */
- nri_max = nbl->na_ci*(cj_ind_end - cj_ind_start);
+ /* In worst case we have alternating energy groups
+ * and create #atom-pair lists, which means we need the size
+ * of a cluster pair (na_ci*na_cj) times the number of cj's.
+ */
+ nri_max = nbl->na_ci*nbl->na_cj*(cj_ind_end - cj_ind_start);
if (nlist->nri + nri_max > nlist->maxnri)
{
nlist->maxnri = over_alloc_large(nlist->nri + nri_max);
if (nlist->nrj > nlist->jindex[nri])
{
+ /* Actually add this new, non-empty, list */
nlist->nri++;
nlist->jindex[nlist->nri] = nlist->nrj;
}
cj4_ind_start = nbl_sci->cj4_ind_start;
cj4_ind_end = nbl_sci->cj4_ind_end;
- /* No energy groups (yet), so we split lists in max_nrj_fep pairs */
- nri_max = nbl->na_sc*(1 + ((cj4_ind_end - cj4_ind_start)*NBNXN_GPU_JGROUP_SIZE)/max_nrj_fep);
+ /* Here we process one super-cell, max #atoms na_sc, versus a list
+ * cj4 entries, each with max NBNXN_GPU_JGROUP_SIZE cj's, each
+ * of size na_cj atoms.
+ * On the GPU we don't support energy groups (yet).
+ * So for each of the na_sc i-atoms, we need max one FEP list
+ * for each max_nrj_fep j-atoms.
+ */
+ nri_max = nbl->na_sc*nbl->na_cj*(1 + ((cj4_ind_end - cj4_ind_start)*NBNXN_GPU_JGROUP_SIZE)/max_nrj_fep);
if (nlist->nri + nri_max > nlist->maxnri)
{
nlist->maxnri = over_alloc_large(nlist->nri + nri_max);
if (nlist->nrj > nlist->jindex[nri])
{
+ /* Actually add this new, non-empty, list */
nlist->nri++;
nlist->jindex[nlist->nri] = nlist->nrj;
}
#include <config.h>
#endif
+#include <assert.h>
+#include <math.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <math.h>
-#include <assert.h>
+
#include "typedefs.h"
#include "txtdump.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "gromacs/utility/smalloc.h"
#include "coulomb.h"
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "pme.h"
#include "network.h"
#include "physics.h"
#include "nrnb.h"
#include "macros.h"
+#include "gromacs/legacyheaders/types/commrec.h"
#include "gromacs/fft/parallel_3dfft.h"
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/fileio/pdbio.h"
#include "gromacs/math/gmxcomplex.h"
#include "gromacs/timing/cyclecounter.h"
}
if (flags & GMX_PME_SOLVE)
{
- int loop_count;
/* solve in k-space for our local cells */
#pragma omp parallel num_threads(pme->nthread) private(thread)
{
+ int loop_count;
thread = gmx_omp_get_thread_num();
if (thread == 0)
{
#endif
#include <math.h>
-#include "sysstuff.h"
#include "typedefs.h"
#include "types/commrec.h"
#include "macros.h"
#include "gromacs/utility/smalloc.h"
#include "physics.h"
#include "macros.h"
-#include "vec.h"
+#include "gromacs/math/vec.h"
#include "force.h"
#include "invblock.h"
#include "gromacs/fileio/confio.h"
#include "qmmm.h"
#include <stdio.h>
#include <string.h>
-#include "gmx_fatal.h"
+#include "gromacs/utility/fatalerror.h"
#include "typedefs.h"
#include <stdlib.h>
#include "mtop_util.h"
#elif defined GMX_QMMM_GAUSSIAN
QMener = call_gaussian(cr, fr, qm, mm, f, fshift);
#elif defined GMX_QMMM_ORCA
- QMener = call_orca(cr, fr, qm, mm, f, fshift);
+ QMener = call_orca(fr, qm, mm, f, fshift);
#else
gmx_fatal(FARGS, "Ab-initio calculation only supported with Gamess, Gaussian or ORCA.");
#endif
#elif defined GMX_QMMM_GAUSSIAN
init_gaussian(cr, qr->qm[0], qr->mm);
#elif defined GMX_QMMM_ORCA
- init_orca(cr, qr->qm[0], qr->mm);
+ init_orca(qr->qm[0]);
#else
gmx_fatal(FARGS, "Ab-initio calculation only supported with Gamess, Gaussian or ORCA.");
#endif
#include <unistd.h>
#endif
-#include "gromacs/legacyheaders/types/simple.h"
-#include "gromacs/legacyheaders/gmx_fatal.h"
-#include "gromacs/legacyheaders/main.h"
-
-#include "gromacs/fileio/futil.h"
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/basenetwork.h"
+#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/futil.h"
#include "gromacs/utility/smalloc.h"
int continuing(char *s)
* or because of n being too small.
* Since both cases occur very infrequently, we can check for EOF.
*/
- if (!gmx_eof(stream))
+ if (!feof(stream))
{
gmx_fatal(FARGS, "An input file contains a line longer than %d characters, while the buffer passed to fgets2 has size %d. The line starts with: '%20.20s'", n, n, line);
}