if (a[0] != 0)
{
- e1 = exp(-x/a[0]) - 1;
+ e1 = gmx_expm1(-x/a[0]);
}
else
{
}
if (a[2] != 0)
{
- e2 = exp(-x/a[2]) - 1;
+ e2 = gmx_expm1(-x/a[2]);
}
else
{
//static var
int ExpfitTest::nrLines_;
+//cppcheck-suppress arrayIndexOutOfBounds fixed in 1.68-dev
std::vector<real> ExpfitTest::values_[expTestNrTypes];
int ExpfitTest::nrColumns_;
std::vector<real> ExpfitTest::standardDev_;
#include "gromacs/ewald/pme.h"
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/fileio/pdbio.h"
+#include "gromacs/gmxlib/gpu_utils/gpu_utils.h"
#include "gromacs/imd/imd.h"
#include "gromacs/legacyheaders/chargegroup.h"
#include "gromacs/legacyheaders/constr.h"
#include "gromacs/legacyheaders/genborn.h"
#include "gromacs/legacyheaders/gmx_ga2la.h"
#include "gromacs/legacyheaders/gmx_omp_nthreads.h"
-#include "gromacs/legacyheaders/gpu_utils.h"
#include "gromacs/legacyheaders/mdatoms.h"
#include "gromacs/legacyheaders/mdrun.h"
#include "gromacs/legacyheaders/names.h"
/* Keep the curr_edi pointer for the case that the next group is empty: */
last_edi = curr_edi;
/* Let's prepare to read in the next edi data set: */
- /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
curr_edi = edi_read;
}
if (edi_nr == 0)
#include "config.h"
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
}
break;
case eioNRVEC:
+ assert(item);
for (i = 0; (i < nitem); i++)
{
ptr = ((rvec *) item)[i];
{
res = sscanf(next_item(fp, ni_buf, NEXT_ITEM_BUF_LEN), "%lf\n",
&x);
- if (item)
- {
- ptr[m] = x;
- }
+ ptr[m] = x;
}
}
break;
idef->il[i].iatoms[j] = niatoms[j];
}
idef->il[i].nr = nnr;
- /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
sfree(niatoms);
}
}
/* This returns the real-valued index(!) to an ACF, equidistant on a log scale. */
static double getLogIndex(const int i, const t_gemParams *params)
{
- return (exp(((double)(i)) * params->logQuota) -1);
+ return gmx_expm1(((double)(i)) * params->logQuota);
}
extern t_gemParams *init_gemParams(const double sigma, const double D,
lambda = eigval[i]*AMU;
w = sqrt(BOLTZMANN*temp/lambda)/NANO;
hwkT = (hbar*w)/(BOLTZMANN*temp);
- dS = (hwkT/(exp(hwkT) - 1) - log(1-exp(-hwkT)));
+ dS = (hwkT/gmx_expm1(hwkT) - gmx_log1p(-exp(-hwkT)));
S += dS;
if (debug)
{
fprintf(stdout, "First time is not larger than 0, using index number as time for power fit\n");
for (i = 0; i < n; i++)
{
- x[i] = log(i+1);
+ x[i] = gmx_log1p(i);
}
}
{
n1 = (int)(2*amax/bin + 0.5);
nradial = (int)(rmax/bin + 0.5);
+ /* cppcheck-suppress zerodiv fixed in 1.68-dev */
invspa = n1/(2*amax);
+ /* cppcheck-suppress zerodiv fixed in 1.68-dev */
invspz = nradial/rmax;
if (bMirror)
{
}
else
{
- return bhn/(exp(bhn)-1) - log(1-exp(-bhn));
+ return bhn/gmx_expm1(bhn) - gmx_log1p(-exp(-bhn));
}
}
}
else
{
- return bhn/2 + bhn/(exp(bhn)-1)-1;
+ return bhn/2 + bhn/gmx_expm1(bhn)-1;
}
}
return 0;
}
+ if (maxangle == 0)
+ {
+ gmx_fatal(FARGS, "maxangle not given");
+ }
+
get_stx_coordnum (opt2fn("-f", NFILE, fnm), &natoms);
init_t_atoms(&atoms, natoms, TRUE);
snew(x, natoms);
#include "gmxpre.h"
-#include "gromacs/legacyheaders/pmalloc_cuda.h"
+#include "pmalloc_cuda.h"
#include <stdlib.h>
#include "thread_mpi/threads.h"
+#include "gromacs/gmxlib/gpu_utils/gpu_utils.h"
#include "gromacs/legacyheaders/copyrite.h"
#include "gromacs/legacyheaders/gmx_cpuid.h"
-#include "gromacs/legacyheaders/gpu_utils.h"
#include "gromacs/legacyheaders/md_logging.h"
#include "gromacs/legacyheaders/network.h"
#include "gromacs/legacyheaders/types/commrec.h"
#include "gmxpre.h"
-#include "gromacs/legacyheaders/gpu_utils.h"
+#include "gpu_utils.h"
#include "config.h"
add_at(&att, &natt, &prop[a], nmol);
}
- /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
sfree(vsite_m);
sfree(prop);
}
}
else if (simtemp->eSimTempScale == esimtempEXPONENTIAL)
{
- simtemp->temperatures[i] = simtemp->simtemp_low + (simtemp->simtemp_high-simtemp->simtemp_low)*((exp(temperature_lambdas[i])-1)/(exp(1.0)-1));
+ simtemp->temperatures[i] = simtemp->simtemp_low + (simtemp->simtemp_high-simtemp->simtemp_low)*(gmx_expm1(temperature_lambdas[i])/gmx_expm1(1.0));
}
else
{
last++;
}
}
- /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
sfree(bRemoveHarm);
fprintf(stderr, "Converted %d out of %d %s to morse bonds for mol %d\n",
nrharm-last, nrharm, interaction_function[bb].name, i);
gmx_fatal(FARGS, "Invalid particle type %s on line %s",
ptype, line);
}
+ /* cppcheck-suppress arrayIndexOutOfBounds #6329 */
pt = xl[j].ptype;
if (debug)
{
# includes: Nothing to build, just installation
file(GLOB HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h)
-list(REMOVE_ITEM HEADERS gmx_hash.h gmx_ga2la.h gpu_utils.h pmalloc_cuda.h)
+list(REMOVE_ITEM HEADERS gmx_hash.h gmx_ga2la.h)
gmx_install_headers(${HEADERS})
add_subdirectory(types)
#define gmx_erfc(x) gmx_erfcf(x)
#endif
+#if defined(_MSC_VER) && _MSC_VER < 1800
+#define gmx_expm1(x) (exp(x)-1)
+#define gmx_log1p(x) log(1+x)
+#else
+#define gmx_expm1 expm1
+#define gmx_log1p log1p
+#endif
+
gmx_bool gmx_isfinite(real x);
gmx_bool gmx_isnan(real x);
#include "gromacs/domdec/domdec.h"
#include "gromacs/ewald/ewald.h"
+#include "gromacs/gmxlib/cuda_tools/pmalloc_cuda.h"
+#include "gromacs/gmxlib/gpu_utils/gpu_utils.h"
#include "gromacs/legacyheaders/copyrite.h"
#include "gromacs/legacyheaders/force.h"
#include "gromacs/legacyheaders/gmx_detect_hardware.h"
#include "gromacs/legacyheaders/gmx_omp_nthreads.h"
-#include "gromacs/legacyheaders/gpu_utils.h"
#include "gromacs/legacyheaders/inputrec.h"
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/legacyheaders/md_logging.h"
#include "gromacs/legacyheaders/network.h"
#include "gromacs/legacyheaders/nonbonded.h"
#include "gromacs/legacyheaders/ns.h"
-#include "gromacs/legacyheaders/pmalloc_cuda.h"
#include "gromacs/legacyheaders/qmmm.h"
#include "gromacs/legacyheaders/tables.h"
#include "gromacs/legacyheaders/txtdump.h"
#include <cuda_profiler_api.h>
#include "gromacs/gmxlib/cuda_tools/cudautils.cuh"
+#include "gromacs/gmxlib/cuda_tools/pmalloc_cuda.h"
+#include "gromacs/gmxlib/gpu_utils/gpu_utils.h"
#include "gromacs/legacyheaders/gmx_detect_hardware.h"
-#include "gromacs/legacyheaders/gpu_utils.h"
-#include "gromacs/legacyheaders/pmalloc_cuda.h"
#include "gromacs/legacyheaders/tables.h"
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/legacyheaders/types/enums.h"
static gmx_inline gmx_exclfilter gmx_simdcall
gmx_load_exclusion_filter(const unsigned *i)
{
+ /* cppcheck-suppress invalidPointerCast */
return gmx_simd_load_r((real *) (i));
}
{
if (mb >= 0)
{
+ /* cppcheck-suppress nullPointer #6330*/
if (atoms->nres <= mtop->maxres_renum)
{
/* Single residue molecule, keep counting */
+ /* cppcheck-suppress nullPointer #6330*/
maxresnr += mtop->molblock[mb].nmol*atoms->nres;
}
}
//"which can be used to restrain surface atoms.[PAR]",
"With the [TT]-tv[tt] option the total volume and density of the",
- "molecule can be computed.",
- "Please consider whether the normal probe radius is appropriate",
+ "molecule can be computed. With [TT]-pbc[tt] (the default), you",
+ "must ensure that your molecule/surface group is not split across PBC.",
+ "Otherwise, you will get non-sensical results.",
+ "Please also consider whether the normal probe radius is appropriate",
"in this case or whether you would rather use, e.g., 0. It is good",
"to keep in mind that the results for volume and density are very",
"approximate. For example, in ice Ih, one can easily fit water molecules in the",
Neighb *wknb, *ctnb;
int iii1, iii2, iiat, lfnr = 0, i_at, j_at;
real dx, dy, dz, dd, ai, aisq, ajsq, aj, as, a;
- real xi, yi, zi, xs = 0., ys = 0., zs = 0.;
+ real xi, yi, zi;
real dotarea, area, vol = 0.;
real *xus, *dots = NULL, *atom_area = NULL;
int nxbox, nybox, nzbox, nxy, nxyz;
}
ra2max = 2*ra2max;
+ // Compute the center of the molecule for volume calculation.
+ // In principle, the center should not influence the results, but that is
+ // only true at the limit of infinite dot density, so this makes the
+ // results translation-invariant.
+ // With PBC, if the molecule is broken across the boundary, the computation
+ // is broken in other ways as well, so it does not need to be considered
+ // here.
+ real xs = 0.0, ys = 0.0, zs = 0.0;
+ for (i = 0; i < nat; ++i)
+ {
+ iat = index[i];
+ xs += coords[iat][XX];
+ ys += coords[iat][YY];
+ zs += coords[iat][ZZ];
+ }
+ xs /= nat;
+ ys /= nat;
+ zs /= nat;
/* Added DvdS 2006-07-19 */
/* Updated 2008-10-09 */
if (box)
snew(x, nat);
for (i = 0; (i < nat); i++)
{
- iat = index[0];
+ iat = index[0];
copy_rvec(coords[iat], x[i]);
}
put_atoms_in_triclinic_unitcell(ecenterTRIC, box, nat, x);
{
/* dimensions of atomic set, cell edge is 2*ra_max */
iat = index[0];
- xmin = coords[iat][XX]; xmax = xmin; xs = xmin;
- ymin = coords[iat][YY]; ymax = ymin; ys = ymin;
- zmin = coords[iat][ZZ]; zmax = zmin; zs = zmin;
+ xmin = coords[iat][XX]; xmax = xmin;
+ ymin = coords[iat][YY]; ymax = ymin;
+ zmin = coords[iat][ZZ]; zmax = zmin;
for (iat_xx = 1; (iat_xx < nat); iat_xx++)
{
xmin = std::min(xmin, *pco); xmax = std::max(xmax, *pco);
ymin = std::min(ymin, *(pco+1)); ymax = std::max(ymax, *(pco+1));
zmin = std::min(zmin, *(pco+2)); zmax = std::max(zmax, *(pco+2));
- xs = xs+ *pco; ys = ys+ *(pco+1); zs = zs+ *(pco+2);
}
- xs = xs/ (real) nat;
- ys = ys/ (real) nat;
- zs = zs/ (real) nat;
if (debug)
{
fprintf(debug, "nsc_dclm: n_dot=%5d ra2max=%9.3f %9.3f\n", n_dot, ra2max, dotarea);
<DataValues>
<Int Name="Count">2</Int>
<DataValue>
- <Real Name="Value">2.7441690613360836</Real>
+ <Real Name="Value">2.5505606048765408</Real>
</DataValue>
<DataValue>
- <Real Name="Value">698.86027894441133</Real>
+ <Real Name="Value">751.9095025655306</Real>
</DataValue>
</DataValues>
</DataFrame>
<ReferenceData>
<SASA Name="100Points">
<Real Name="Area">1041.9522794772727</Real>
+ <Real Name="Volume">808.03995831604618</Real>
<Sequence Name="AtomArea">
<Int Name="Length">100</Int>
<Real>0.95131516208197198</Real>
<ReferenceData>
<SASA Name="100Points">
<Real Name="Area">1041.9522794772727</Real>
+ <Real Name="Volume">808.03995831604618</Real>
<Sequence Name="AtomArea">
<Int Name="Length">100</Int>
<Real>0.95131516208197198</Real>
box_[XX][XX] = 20.0;
box_[YY][YY] = 20.0;
box_[ZZ][ZZ] = 20.0;
- // TODO: The volume computation with PBC is broken...
- const int flags = FLAG_ATOM_AREA | FLAG_DOTS;
+ const int flags = FLAG_ATOM_AREA | FLAG_VOLUME | FLAG_DOTS;
ASSERT_NO_FATAL_FAILURE(calculate(24, flags, true));
checkReference(&checker, "100Points", false);
box_[ZZ][YY] = 10.0*sqrt(1.0/3.0);
box_[ZZ][ZZ] = 20.0*sqrt(2.0/3.0);
- // TODO: The volume computation with PBC is broken...
- const int flags = FLAG_ATOM_AREA | FLAG_DOTS;
+ const int flags = FLAG_ATOM_AREA | FLAG_VOLUME | FLAG_DOTS;
ASSERT_NO_FATAL_FAILURE(calculate(24, flags, true));
checkReference(&checker, "100Points", false);
#include "corewrap.h"
#endif
-#include "gromacs/legacyheaders/gpu_utils.h"
+#include "gromacs/gmxlib/gpu_utils/gpu_utils.h"
typedef struct {
gmx_integrator_t *func;
if (gmx_strcasecmp(buf, "nok") == 0)
{
/* An error occurred */
- for (i = 0; (i < nlines); i++)
+ if (lines)
{
- sfree(lines[i]);
+ for (i = 0; (i < nlines); i++)
+ {
+ sfree(lines[i]);
+ }
+ sfree(lines);
}
- sfree(lines);
NoHelp(dlg);
return;
}
--suppress=unusedStructMember
--suppress=invalidscanf
--suppress=sizeofCalculation
+ --suppress=invalidscanf_libc
--suppress=missingInclude:src/programs/mdrun/gmx_gpu_utils/gmx_gpu_utils.cu
--suppress=*:src/external/Random123-1.08/include/Random123/features/compilerfeatures.h
- --suppress=assignIfError:src/gromacs/mdlib/nbnxn_atomdata.c #Ticket 5695
--suppress=invalidPointerCast:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh
--suppress=passedByValue:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh
--suppress=passedByValue:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel_utils.cuh
-D__cplusplus
--suppress=variableScope
--suppress=unnecessaryForwardDeclaration
- --suppress=invalidscanf:src/gromacs/fileio/matio.cpp
- --suppress=invalidscanf:src/gromacs/fileio/xvgr.cpp
- --suppress=invalidscanf:src/gromacs/topology/index.cpp
- --suppress=invalidscanf:src/gromacs/gmxpreprocess/pdb2top.cpp
+ --suppress=memsetClassFloat #we assume IEEE754
+ --suppress=invalidscanf_libc #seems only important for security on non-std libc
+ --suppress=invalidscanf #same as last (style and portability checker have the same warning)
--suppress=passedByValue:src/gromacs/simd/tests/*
)