#include "types/simple.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
extern void rangeArray(int *ar, int size);
extern void insertionSort(real *ar, int *perm, int start, int end, int direction);
extern int LinearSearch(double *array, int startindx, int stopindx,
double key, int *count, int direction);
+#ifdef __cplusplus
+}
+#endif
+
#endif
#include "types/simple.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
extern gmx_bool convolution(int dataSize, real* in, int kernelSize,
real* kernel);
extern gmx_bool periodic_convolution(int dsize, real *in, int ksize,
real* kernel);
extern void gausskernel(real *out, int size, real var);
+#ifdef __cplusplus
+}
+#endif
+
#endif
#include "gromacs/linearalgebra/eigensolver.h"
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
int gmx_covar(int argc, char *argv[])
{
const char *desc[] = {
gmx_rmpbc_t gpbc = NULL;
matrix box; /* Box - 3x3 -each step*/
rvec *x0; /* List of Coord without PBC*/
- int natoms, i, j, k, n, /* loop indices, checks etc*/
+ int i, j, /* loop indices, checks etc*/
ax1 = 0, ax2 = 0, /* tangent directions */
framenr = 0, /* frame number in trajectory*/
slicex, slicey, slicez; /*slice # of x y z position */
gmx_fatal(FARGS, "Invalid axes. Terminating\n");
}
- if ( (natoms = read_first_x(oenv, &status, fn, &t, &x0, box)) == 0)
+ if (read_first_x(oenv, &status, fn, &t, &x0, box) == 0)
{
gmx_fatal(FARGS, "Could not read coordinates from file"); /* Open trajectory for read*/
bbww[ZZ] = box[axis][axis]/ *zslices;
gmx_rmpbc(gpbc, top->atoms.nr, box, x0);
/*Reset Densslice every nsttblock steps*/
- if (framenr % nsttblock == 0)
+ /* The first conditional is for clang to understand that this branch is
+ * always taken the first time. */
+ if (Densslice == NULL || framenr % nsttblock == 0)
{
snew(Densslice, *xslices);
for (i = 0; i < *xslices; i++)
}
}
- /*Allocate Memory to extra frame in Densdevel - rather stupid approach: *A single frame each time, although only every nsttblock steps.*/
+ /* Allocate Memory to extra frame in Densdevel - rather stupid approach:
+ * A single frame each time, although only every nsttblock steps.
+ */
srenew(*Densdevel, *tblock+1);
-
+ (*Densdevel)[*tblock] = Densslice;
}
-
dscale = (*xslices)*(*yslices)*(*zslices)*AMU/ (box[ax1][ax1]*box[ax2][ax2]*box[axis][axis]*nsttblock*(NANO*NANO*NANO));
if (bCenter)
slicey = ((int) (y/bbww[YY])) % *yslices;
slicez = ((int) (z/bbww[ZZ])) % *zslices;
Densslice[slicex][slicey][slicez] += (top->atoms.atom[index[0][j]].m*dscale);
-
-
}
framenr++;
{
/*Implicit incrementation of Densdevel via renewal of Densslice*/
/*only every nsttblock steps*/
- (*Densdevel)[*tblock] = Densslice;
(*tblock)++;
}
static void filterdensmap(real ****Densmap, int xslices, int yslices, int zslices, int tblocks, int ftsize)
{
real *kernel;
- real *output;
real std, var;
- int i, j, k, n, order;
+ int i, j, n, order;
order = ftsize/2;
std = ((real)order/2.0);
var = std*std;
real *zDensavg; /* zDensavg[z]*/
int i, j, k, n;
int xysize;
- int ndx1, ndx2, deltandx, *zperm;
- real densmid, densl, densr, alpha, pos, spread;
+ int ndx1, ndx2, *zperm;
+ real densmid;
real splitpoint, startpoint, endpoint;
real *sigma1, *sigma2;
real beginfit1[4];
output_env_t oenv;
t_topology *top;
- char title[STRLEN], **grpname;
+ char **grpname;
int ePBC, *ngx;
static real binw = 0.2;
static real binwz = 0.05;
static int ftorder = 0;
static int nsttblock = 100;
static int axis = 2;
- static char *axtitle = "Z";
+ static const char *axtitle = "Z";
atom_id **index; /* Index list for single group*/
int xslices, yslices, zslices, tblock;
static gmx_bool bGraph = FALSE;
#include <string.h>
#include <math.h>
+#include <algorithm>
+
#include "macros.h"
#include "statutil.h"
#include "sysstuff.h"
if ((ptr = getenv("GKRWIDTH")) != NULL)
{
- double bw;
-
- sscanf(ptr, "%lf", &bw);
+ double bw = strtod(ptr, NULL);
gb->spacing = bw;
}
else
{
gb->spacing = 0.01; /* nm */
}
- gb->nelem = 1 + radius/gb->spacing;
+ gb->nelem = 1 + static_cast<int>(radius/gb->spacing);
if (rcmax == 0)
{
gb->nx = gb->nelem;
}
else
{
- gb->nx = 1 + rcmax/gb->spacing;
+ gb->nx = 1 + static_cast<int>(rcmax/gb->spacing);
}
gb->radius = radius;
snew(gb->elem, gb->nelem);
snew(gb->count, gb->nelem);
snew(gb->cmap, gb->nx);
- gb->ny = max(2, ndegrees);
+ gb->ny = std::max(2, ndegrees);
for (i = 0; (i < gb->nx); i++)
{
snew(gb->cmap[i], gb->ny);
alpha = acos(cosa);
if (gb->bPhi)
{
- cy = (M_PI+phi)*gb->ny/(2*M_PI);
+ cy = static_cast<int>((M_PI+phi)*gb->ny/(2*M_PI));
}
else
{
- cy = (alpha*gb->ny)/M_PI; /*((1+cosa)*0.5*(gb->ny));*/
+ cy = static_cast<int>((alpha*gb->ny)/M_PI); /*((1+cosa)*0.5*(gb->ny));*/
}
- cy = min(gb->ny-1, max(0, cy));
+ cy = std::min(gb->ny-1, std::max(0, cy));
if (debug)
{
fprintf(debug, "CY: %10f %5d\n", alpha, cy);
int ePBC, matrix box, t_atom *atom, int *nAtom)
{
static rvec *xcm[2] = { NULL, NULL};
- int gi, gj, j0, j1, i, j, k, n, index, grp0, grp1;
- real qtot, q, r2, cosa, rr, phi;
+ int gi, gj, j0, j1, i, j, k, n, grp0, grp1;
+ real qtot, q, cosa, rr, phi;
rvec dx;
t_pbc pbc;
cosa = cos_angle(mu[gi], mu[gj]);
phi = 0;
}
- if (debug || (cosa != cosa))
+ if (debug || gmx_isnan(cosa))
{
fprintf(debug ? debug : stderr,
"mu[%d] = %5.2f %5.2f %5.2f |mi| = %5.2f, mu[%d] = %5.2f %5.2f %5.2f |mj| = %5.2f rr = %5.2f cosa = %5.2f\n",
static real normalize_cmap(t_gkrbin *gb)
{
int i, j;
- double hi, vol;
+ real hi;
+ double vol;
hi = 0;
for (i = 0; (i < gb->nx); i++)
for (j = 0; (j < gb->ny); j++)
{
gb->cmap[i][j] /= vol;
- hi = max(hi, gb->cmap[i][j]);
+ hi = std::max(hi, gb->cmap[i][j]);
}
}
if (hi <= 0)
*/
FILE *fp;
const char *leg[] = { "G\\sk\\N(r)", "< cos >", "h\\sOO\\N", "g\\sOO\\N", "Energy" };
- int i, j, n, last;
+ int i, last;
real x0, x1, ggg, Gkr, vol_s, rho, gOO, hOO, cosav, ener;
double fac;
real q, r2, mass, masstot;
rvec com; /* center of mass */
rvec r; /* distance of atoms to center of mass */
- real rcom_m, rcom_n;
double **inten;
double dd[DIM], **ev, tmp;
static void compute_avercos(int n, rvec dip[], real *dd, rvec axis, gmx_bool bPairs)
{
int i, j, k;
- double dc, dc1, d, n5, ddc1, ddc2, ddc3;
+ double dc, d, ddc1, ddc2, ddc3;
rvec xxx = { 1, 0, 0 };
rvec yyy = { 0, 1, 0 };
rvec zzz = { 0, 0, 1 };
t_enxframe *fr;
int nframes = 1000, nre, timecheck = 0, ncolour = 0;
ener_file_t fmu = NULL;
- int i, j, k, n, m, natom = 0, nmol, gnx_tot, teller, tel3;
+ int i, n, m, natom = 0, gnx_tot, teller, tel3;
t_trxstatus *status;
- int *dipole_bin, ndipbin, ibin, iVol, step, idim = -1;
+ int *dipole_bin, ndipbin, ibin, iVol, idim = -1;
unsigned long mode;
- char buf[STRLEN];
- real rcut = 0, t, t0, t1, dt, lambda, dd, rms_cos;
+ real rcut = 0, t, t0, t1, dt, dd, rms_cos;
rvec dipaxis;
matrix box;
gmx_bool bCorr, bTotal, bCont;
double M_diff = 0, epsilon, invtel, vol_aver;
double mu_ave, mu_mol, M2_ave = 0, M_ave2 = 0, M_av[DIM], M_av2[DIM];
double M[3], M2[3], M4[3], Gk = 0, g_k = 0;
- gmx_stats_t Mx, My, Mz, Msq, Vol, *Qlsq, mulsq, muframelsq = NULL;
+ gmx_stats_t *Qlsq, mulsq, muframelsq = NULL;
ivec iMu;
real **muall = NULL;
rvec *slab_dipoles = NULL;
}
/* Calculate spacing for dipole bin (simple histogram) */
- ndipbin = 1+(mu_max/0.01);
+ ndipbin = 1 + static_cast<int>(mu_max/0.01);
snew(dipole_bin, ndipbin);
- epsilon = 0.0;
mu_ave = 0.0;
for (m = 0; (m < DIM); m++)
{
gpbc = gmx_rmpbc_init(&top->idef, ePBC, natom);
/* Start while loop over frames */
- t1 = t0 = t;
+ t0 = t;
teller = 0;
do
{
{
for (i = 0; (i < gnx[n]); i++)
{
- int gi, ind0, ind1;
+ int ind0, ind1;
ind0 = mols->index[molindex[n][i]];
ind1 = mols->index[molindex[n][i]+1];
}
if (!bMU)
{
- real aver, sigma, error, lsq;
+ real aver, sigma, error;
gmx_stats_get_ase(mulsq, &aver, &sigma, &error);
printf("\nDipole moment (Debye)\n");
if (bQuad)
{
rvec a, s, e;
- int mm;
for (m = 0; (m < DIM); m++)
{
gmx_stats_get_ase(mulsq, &(a[m]), &(s[m]), &(e[m]));
};
real mu_max = 5, mu_aver = -1, rcmax = 0;
real epsilonRF = 0.0, temp = 300;
- gmx_bool bAverCorr = FALSE, bMolCorr = FALSE, bPairs = TRUE, bPhi = FALSE, bQuad = FALSE;
+ gmx_bool bPairs = TRUE, bPhi = FALSE, bQuad = FALSE;
const char *corrtype[] = {NULL, "none", "mol", "molsep", "total", NULL};
const char *axtitle = "Z";
int nslices = 10; /* nr of slices defined */
int nFF[2];
atom_id **grpindex;
char **grpname = NULL;
- gmx_bool bCorr, bGkr, bMU, bSlab;
+ gmx_bool bGkr, bMU, bSlab;
t_filenm fnm[] = {
{ efEDR, "-en", NULL, ffOPTRD },
{ efTRX, "-f", NULL, ffREAD },
opt2parg_bSet("-axis", asize(pa), pa));
if (bMU)
{
- bAverCorr = TRUE;
if (bQuad)
{
printf("WARNING: Can not determine quadrupoles from energy file\n");
#include "typedefs.h"
#include "interf.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
extern void powerspectavg(real ***interface, int t, int xbins, int ybins,
char **outfiles);
extern void powerspectavg_intf(t_interf ***if1, t_interf ***if2, int t,
int xbins, int ybins, char **outfiles);
+#ifdef __cplusplus
+}
+#endif
+
#endif
#include "corewrap.h"
#endif
-
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
#define CPT_MAGIC1 171817
#define CPT_MAGIC2 171819
#define CPTSTRLEN 1024
#include <process.h>
#endif
-
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
#define BUFSIZE 1024
gmx_bool bAppendSimId, gmx_bool bAppendNodeId,
char buf[], int bufsize)
{
- int n;
-
if ((size_t)bufsize < (strlen(base)+10))
{
gmx_mem("Character buffer too small!");
void gmx_log_open(const char *lognm, const t_commrec *cr, gmx_bool bMasterOnly,
gmx_bool bAppendFiles, FILE** fplog)
{
- int len, testlen, pid;
+ int len, pid;
char buf[256], host[256];
time_t t;
char timebuf[STRLEN];
char buf[256];
#ifdef GMX_MPI
MPI_Group mpi_group_world;
-#endif
int *rank;
+#endif
#ifndef GMX_MPI
if (nsim > 1)
if (multidirs)
{
- int ret;
if (debug)
{
fprintf(debug, "Changing to directory %s\n", multidirs[cr->ms->sim]);
t_commrec *init_par(int gmx_unused *argc, char ***argv_ptr)
{
t_commrec *cr;
- char **argv;
- int i;
- gmx_bool pe = FALSE;
snew(cr, 1);
- argv = argv_ptr ? *argv_ptr : NULL;
-
#if defined GMX_MPI && !defined GMX_THREAD_MPI
+ char **argv = argv_ptr ? *argv_ptr : NULL;
cr->sim_nodeid = gmx_setup(argc, argv, &cr->nnodes);
if (!PAR(cr) && (cr->sim_nodeid != 0))
return returnval;
}
+gmx_bool gmx_isnan(real x)
+{
+ /* cppcheck-suppress duplicateExpression */
+ return x != x;
+}
+
gmx_bool
check_int_multiply_for_overflow(gmx_large_int_t a,
gmx_large_int_t b,
#include <stdio.h>
#include <ctype.h>
+
+#include <algorithm>
+
#include "sysstuff.h"
#include "futil.h"
#include "string2.h"
{
t_mapping *map;
char *line_buf = NULL, *line = NULL, *str, buf[256] = {0};
- int i, m, col_len, nch, n_axis_x, n_axis_y, llmax;
+ int i, m, col_len, nch = 0, n_axis_x, n_axis_y, llmax;
int llalloc = 0;
unsigned int r, g, b;
double u;
{
gmx_fatal(FARGS, "Dimensions of xpm-file have to be larger than 0\n");
}
- llmax = max(STRLEN, mm->nx+10);
+ llmax = std::max(STRLEN, mm->nx+10);
bGetOnWithIt = TRUE;
}
}
fprintf(debug, "mm->nx %d mm->ny %d mm->nmap %d nch %d\n",
mm->nx, mm->ny, mm->nmap, nch);
}
+ if (nch == 0)
+ {
+ gmx_fatal(FARGS, "Number of characters per pixel not found in xpm\n");
+ }
/* Read color map */
snew(map, mm->nmap);
/* Read axes, if there are any */
n_axis_x = 0;
n_axis_y = 0;
- bGetOnWithIt = FALSE;
bSetLine = FALSE;
do
{
{
/* Take care that we have at least 1 entry in the mid to hi range
*/
- return min(max(0, ((mid-lo)/(hi-lo))*(nlevels-1)), nlevels-1);
+ return std::min(std::max(0, static_cast<int>(((mid-lo)/(hi-lo))*(nlevels-1))),
+ nlevels-1);
}
void write_xpm_map3(FILE *out, int n_x, int n_y, int *nlevels,
int i, n;
- *nlevel = min(16, *nlevel);
+ *nlevel = std::min(16, *nlevel);
n = *nlevel;
for (i = 0; (i < n); i++)
{
int *nlevel_bot, real lo_bot, real hi_bot,
t_rgb rlo_bot, t_rgb rhi_bot)
{
- int i, ntot;
- real r, g, b, fac;
+ int ntot;
ntot = *nlevel_top + *nlevel_bot;
if (ntot > NMAP)
#include "vec.h"
#include "gmxfio.h"
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
gmx_bool output_env_get_print_xvgr_codes(const output_env_t oenv)
{
int xvg_format;
const output_env_t oenv)
{
FILE *fp;
- time_t t;
fp = gmx_fio_fopen(fn, "w");
/* reads a line into ptr, adjusting len and renewing ptr if neccesary */
static char *fgets3(FILE *fp, char **ptr, int *len, int maxlen)
{
- char *p;
int len_remaining = *len; /* remaining amount of allocated bytes in buf */
int curp = 0; /* current position in buf to read into */
char **subtitle, char ***legend)
{
FILE *fp;
- char *ptr, *ptr0, *ptr1;
+ char *ptr;
char *base = NULL;
char *fmt = NULL;
int k, line = 0, nny, nx, maxx, rval, legend_nalloc, set, nchar;
char line0[MAXLINELEN];
char *line;
int t_nalloc, *val_nalloc, a, narg, n, sin, set, nchar;
- double dbl, tend = 0;
+ double dbl;
gmx_bool bEndOfSet, bTimeInRange, bFirstLine = TRUE;
real **val;
-file(GLOB GMXPREPROCESS_SOURCES *.c)
+file(GLOB GMXPREPROCESS_SOURCES *.c *.cpp)
set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${GMXPREPROCESS_SOURCES} PARENT_SCOPE)
#include "typedefs.h"
#include "pdb2top.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
extern void add_param(t_params *ps, int ai, int aj, real *c, char *s);
extern void add_imp_param(t_params *ps, int ai, int aj, int ak, int al,
extern int search_jtype(t_restp *rp, char *name, gmx_bool bFirstRes);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _add_par_h */
#include "gpp_atomtype.h"
#include "hackblock.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
/* stuff for pdb2gmx */
extern void do_vsites(int nrtp, t_restp rtp[], gpp_atomtype_t atype,
extern void do_h_mass(t_params *psb, int vsite_type[], t_atoms *at, real mHmult,
gmx_bool bDeuterate);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _gen_vsite_h */
{
int j, k, nmiss;
char *name;
- gmx_bool bFound, bRet;
+ gmx_bool bFound;
nmiss = 0;
for (j = 0; j < rp->natom; j++)
}
sfree(desc);
+ sel = -1;
do
{
pret = fgets(buf, STRLEN, stdin);
if (pret != NULL)
{
- sscanf(buf, "%d", &sel);
+ sel = strtol(buf, NULL, 10);
sel--;
}
}
ffclose(fp);
fprintf(stderr, "%2d: %s\n", nwm+1, "None");
+ sel = -1;
do
{
pret = fgets(buf, STRLEN, stdin);
if (pret != NULL)
{
- sscanf(buf, "%d", &sel);
+ sel = strtol(buf, NULL, 10);
sel--;
}
}
{
int i, j, prevresind, resind, i0, prevcg, cg, curcg;
char *name;
- gmx_bool bProt, bNterm;
+ gmx_bool bNterm;
double qt;
int nmissat;
nmissat = 0;
resind = -1;
- bProt = FALSE;
bNterm = FALSE;
i0 = 0;
snew(*cgnr, at->nr);
prevresind = resind;
if (at->atom[i].resind != resind)
{
+ gmx_bool bProt;
resind = at->atom[i].resind;
bProt = gmx_residuetype_is_protein(rt, *(at->resinfo[resind].name));
bNterm = bProt && (resind == 0);
const char *ffdir,
gmx_bool bITP)
{
- char tmp[256];
char ffdir_parent[STRLEN];
char *p;
* for missing atoms in bonds, as the hydrogens and terminal atoms
* have not been added yet.
*/
- ai = search_atom(hb[resind].rb[ebtsBONDS].b[j].AI, i, atoms,
+ ai = search_atom(hb[resind].rb[ebtsBONDS].b[j].a[0], i, atoms,
ptr, TRUE);
- aj = search_atom(hb[resind].rb[ebtsBONDS].b[j].AJ, i, atoms,
+ aj = search_atom(hb[resind].rb[ebtsBONDS].b[j].a[1], i, atoms,
ptr, TRUE);
if (ai != NO_ATID && aj != NO_ATID)
{
{
if ( ( hb[resind].hack[j].tp > 0 ||
hb[resind].hack[j].oname == NULL ) &&
- strcmp(hb[resind].hack[j].AI, *(atoms->atomname[i])) == 0)
+ strcmp(hb[resind].hack[j].a[0], *(atoms->atomname[i])) == 0)
{
switch (hb[resind].hack[j].tp)
{
pa = (t_param *)a;
pb = (t_param *)b;
- d = pa->AI - pb->AI;
+ d = pa->a[0] - pb->a[0];
if (d == 0)
{
- d = pa->AJ - pb->AJ;
+ d = pa->a[1] - pb->a[1];
}
if (d == 0)
{
/* swap atomnumbers in bond if first larger than second: */
for (i = 0; (i < ps->nr); i++)
{
- if (ps->param[i].AJ < ps->param[i].AI)
+ if (ps->param[i].a[1] < ps->param[i].a[0])
{
- a = ps->param[i].AI;
- ps->param[i].AI = ps->param[i].AJ;
- ps->param[i].AJ = a;
+ a = ps->param[i].a[0];
+ ps->param[i].a[0] = ps->param[i].a[1];
+ ps->param[i].a[1] = a;
}
}
j = 1;
for (i = 1; (i < ps->nr); i++)
{
- if ((ps->param[i].AI != ps->param[j-1].AI) ||
- (ps->param[i].AJ != ps->param[j-1].AJ) )
+ if ((ps->param[i].a[0] != ps->param[j-1].a[0]) ||
+ (ps->param[i].a[1] != ps->param[j-1].a[1]) )
{
if (j != i)
{
int i, j, k, l;
char *key;
t_restp *res;
- char buf[STRLEN];
- const char *Hnum = "123456";
int tern, terc;
- gmx_bool bN, bC, bRM;
+ gmx_bool bRM;
snew(*hb, nres);
snew(*restp, nres);
for (l = 0; l < (*restp)[i].natom; l++)
{
if ( ( (*hb)[i].hack[j].oname == NULL &&
- strcmp((*hb)[i].hack[j].AI, *(*restp)[i].atomname[l]) == 0 ) ||
+ strcmp((*hb)[i].hack[j].a[0], *(*restp)[i].atomname[l]) == 0 ) ||
( (*hb)[i].hack[j].oname != NULL &&
strcmp((*hb)[i].hack[j].oname, *(*restp)[i].atomname[l]) == 0 ) )
{
"atom %s not found in buiding block %d%s "
"while combining tdb and rtp",
(*hb)[i].hack[j].oname != NULL ?
- (*hb)[i].hack[j].oname : (*hb)[i].hack[j].AI,
+ (*hb)[i].hack[j].oname : (*hb)[i].hack[j].a[0],
i+1, *resinfo[i].rtp);
}
}
gmx_bool bVerbose)
{
int resnr;
- int i, j, k;
+ int j, k;
char *oldnm, *newnm;
int anmnr;
char *start_at, buf[STRLEN];
t_atoms *pdba, rvec *x,
gmx_bool bVerbose)
{
- int i, j, k;
- char *oldnm, *newnm;
- int resnr;
+ int i, j;
+ char *oldnm;
t_restp *rptr;
- t_hackblock *hbr;
- int anmnr;
- char *start_at, buf[STRLEN];
- int start_nr;
- gmx_bool bFoundInAdd;
for (i = 0; i < pdba->nr; i++)
{
oldnm = *pdba->atomname[i];
- resnr = pdba->resinfo[pdba->atom[i].resind].nr;
rptr = &restp[pdba->atom[i].resind];
for (j = 0; (j < rptr->natom); j++)
{
#include "typedefs.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
extern atom_id search_atom(const char *type, int start,
t_atoms *atoms,
const char *bondtype, gmx_bool bAllowMissing);
extern void set_at(t_atom *at, real m, real q, int type, int resind);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _pgutil_h */
* make a rest group for the remaining particles. */
};
+static const char *constraints[eshNR+1] = {
+ "none", "h-bonds", "all-bonds", "h-angles", "all-angles", NULL
+};
+
+static const char *couple_lam[ecouplamNR+1] = {
+ "vdw-q", "vdw", "q", "none", NULL
+};
void init_ir(t_inputrec *ir, t_gromppopts *opts)
{
eshNONE, eshHBONDS, eshALLBONDS, eshHANGLES, eshALLANGLES, eshNR
};
-static const char *constraints[eshNR+1] = {
- "none", "h-bonds", "all-bonds", "h-angles", "all-angles", NULL
-};
-
enum {
ecouplamVDWQ, ecouplamVDW, ecouplamQ, ecouplamNONE, ecouplamNR
};
-static const char *couple_lam[ecouplamNR+1] = {
- "vdw-q", "vdw", "q", "none", NULL
-};
-
typedef struct {
int warnings;
int nshake;
#include "grompp.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
typedef struct tagDirStack {
directive d;
struct tagDirStack *prev;
extern int DS_Check_Order (DirStack *DS, directive d);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _topdirs_h */
#endif
gmx_bool gmx_isfinite(real x);
+gmx_bool gmx_isnan(real x);
/*! \brief Check if two numbers are within a tolerance
*
#include "toputil.h"
#include "hackblock.h"
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
/* this *MUST* correspond to array in pdb2top.c */
enum {
ehisA, ehisB, ehisH, ehis1, ehisNR
void print_sums(t_atoms *atoms, gmx_bool bSystem);
+#ifdef __cplusplus
+}
+#endif
#endif /* _pdb2top_h */
/* Use of sizeof(T) in _snew() and _srenew() can cause obscure bugs if
* several files define distinct data structures with identical names and
- * allocate memory for them using the macros below.
- * For this reason, the size of an element is passed as a parameter.
- *
+ * allocate memory for them using the macros below. Note that by the standard,
+ * such declarations cause undefined behavior.
* The C versions work fine in such cases, but when compiled with a C++
* compiler (and if the compiler does not inline the calls), the linker cannot
* tell that data structures with identical names are actually different and
* links calls to these template functions incorrectly, which can result in
* allocation of an incorrect amount of memory if the element size is computed
- * within the function. Even with the size passed as a parameter, incorrect
- * linkage will occur, but as the type is now only present in the cast, it
- * should not cause problems.
+ * within the function.
+ *
+ * This could be solved by passing the size as a parameter, but this has other
+ * issues: it provokes warnings from cppcheck for some invokations.
+ * Even with the size passed as a parameter, incorrect linkage will occur.
+ * When converting files to C++, locally declared structs should be enclosed in
+ * anonymous namespaces or some other means taken to ensure they are unique.
*/
-template <typename T>
+template <typename T> inline
void _snew(const char *name, const char *file, int line,
- T * &ptr, size_t nelem, size_t elsize)
+ T * &ptr, size_t nelem)
{
- ptr = (T *)save_calloc(name, file, line, nelem, elsize);
+ ptr = (T *)save_calloc(name, file, line, nelem, sizeof(T));
}
-template <typename T>
+template <typename T> inline
void _srenew(const char *name, const char *file, int line,
- T * &ptr, size_t nelem, size_t elsize)
+ T * &ptr, size_t nelem)
{
- ptr = (T *)save_realloc(name, file, line, ptr, nelem, elsize);
+ ptr = (T *)save_realloc(name, file, line, ptr, nelem, sizeof(T));
}
-template <typename T>
+template <typename T> inline
void _smalloc(const char *name, const char *file, int line, T * &ptr, size_t size)
{
ptr = (T *)save_malloc(name, file, line, size);
}
-template <typename T>
+template <typename T> inline
void _srealloc(const char *name, const char *file, int line, T * &ptr, size_t size)
{
ptr = (T *)save_realloc(name, file, line, ptr, size, sizeof(char));
}
-template <typename T>
+template <typename T> inline
void _snew_aligned(const char *name, const char *file, int line,
- T * &ptr, size_t nelem, size_t elsize, size_t alignment)
+ T * &ptr, size_t nelem, size_t alignment)
{
- ptr = (T *)save_calloc_aligned(name, file, line, nelem, elsize, alignment);
+ ptr = (T *)save_calloc_aligned(name, file, line, nelem, sizeof(T), alignment);
}
-#define snew(ptr, nelem) _snew(#ptr, __FILE__, __LINE__, (ptr), (nelem), sizeof(*(ptr)))
-#define srenew(ptr, nelem) _srenew(#ptr, __FILE__, __LINE__, (ptr), (nelem), sizeof(*(ptr)))
+#define snew(ptr, nelem) _snew(#ptr, __FILE__, __LINE__, (ptr), (nelem))
+#define srenew(ptr, nelem) _srenew(#ptr, __FILE__, __LINE__, (ptr), (nelem))
#define smalloc(ptr, size) _smalloc(#ptr, __FILE__, __LINE__, (ptr), (size))
#define srealloc(ptr, size) _srealloc(#ptr, __FILE__, __LINE__, (ptr), (size))
-#define snew_aligned(ptr, nelem, alignment) _snew_aligned(#ptr, __FILE__, __LINE__, (ptr), (nelem), sizeof(*(ptr)), alignment)
+#define snew_aligned(ptr, nelem, alignment) _snew_aligned(#ptr, __FILE__, __LINE__, (ptr), (nelem), alignment)
#else /* __cplusplus */
/** Remove leading and trailing whitespace from a string. */
void trim(char *str);
+/** Portable version of ctime_r. */
+char *gmx_ctime_r(const time_t *clock, char *buf, int n);
+
/** Prints creation time stamp and user information into a file as comments. */
void nice_header(FILE *out, const char *fn);
*/
/* Over allocation for small data types: int, real etc. */
-#define over_alloc_small(n) (OVER_ALLOC_FAC*(n) + 8000)
+#define over_alloc_small(n) (int)(OVER_ALLOC_FAC*(n) + 8000)
/* Over allocation for large data types: complex structs */
-#define over_alloc_large(n) (OVER_ALLOC_FAC*(n) + 1000)
+#define over_alloc_large(n) (int)(OVER_ALLOC_FAC*(n) + 1000)
int gmx_large_int_to_int(gmx_large_int_t step, const char *warn);
/* Convert a gmx_large_int_t value to int.
#include "nbnxn_cuda_data_mgmt.h"
#include "nbnxn_cuda/nbnxn_cuda.h"
-#if 0
-typedef struct gmx_timeprint {
-
-} t_gmx_timeprint;
-#endif
-
-/* Portable version of ctime_r implemented in src/gmxlib/string2.c, but we do not want it declared in public installed headers */
-char *
-gmx_ctime_r(const time_t *clock, char *buf, int n);
-
-
double
gmx_gettime()
{
--suppress=missingInclude:src/programs/mdrun/gmx_gpu_utils/gmx_gpu_utils.cu
--inline-suppr)
set(_cxx_flags
+ -D__cplusplus
--suppress=variableScope
--suppress=unnecessaryForwardDeclaration
+ --suppress=invalidscanf:src/gromacs/gmxlib/matio.cpp
+ --suppress=invalidscanf:src/gromacs/gmxlib/xvgr.cpp
+ --suppress=invalidscanf:src/gromacs/gmxpreprocess/pdb2top.cpp
--suppress=*:src/gromacs/selection/scanner.cpp)
# This list will hold the list of all files with cppcheck errors