#include "gromacs/legacyheaders/calcgrid.h"
-#include <math.h>
+#include <cmath>
+
+#include <algorithm>
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/utility/fatalerror.h"
{
box_size[d] += box[d][i]*box[d][i];
}
- box_size[d] = sqrt(box_size[d]);
+ box_size[d] = std::sqrt(box_size[d]);
}
n[XX] = *nx;
{
if (n[d] <= 0)
{
- nmin = (int)(box_size[d]/gr_sp + 0.999);
+ nmin = static_cast<int>(box_size[d]/gr_sp + 0.999);
i = g_initNR - 1;
if (grid_init[i] >= nmin)
}
}
- spacing[d] = box_size[d]/n[d];
- if (spacing[d] > max_spacing)
- {
- max_spacing = spacing[d];
- }
+ spacing[d] = box_size[d]/n[d];
+ max_spacing = std::max(max_spacing, spacing[d]);
}
*nx = n[XX];
*ny = n[YY];
#include "gromacs/legacyheaders/chargegroup.h"
-#include <math.h>
+#include <cmath>
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/math/vec.h"
sfree(bLJ);
- *rvdw1 = sqrt(r2v1);
- *rvdw2 = sqrt(r2v2);
- *rcoul1 = sqrt(r2c1);
- *rcoul2 = sqrt(r2c2);
+ *rvdw1 = std::sqrt(r2v1);
+ *rvdw2 = std::sqrt(r2v2);
+ *rcoul1 = std::sqrt(r2c1);
+ *rcoul2 = std::sqrt(r2c2);
}
void calc_cgcm(FILE gmx_unused *fplog, int cg0, int cg1, t_block *cgs,
#include "config.h"
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cerrno>
+#include <cstdlib>
+#include <cstring>
#include <fcntl.h>
#ifdef GMX_NATIVE_WINDOWS
static void do_cpt_string_err(XDR *xd, gmx_bool bRead, const char *desc, char **s, FILE *list)
{
- bool_t res = 0;
-
if (bRead)
{
snew(*s, CPTSTRLEN);
}
- res = xdr_string(xd, s, CPTSTRLEN);
- if (res == 0)
+ if (xdr_string(xd, s, CPTSTRLEN) == 0)
{
cp_error();
}
static int do_cpt_int(XDR *xd, const char *desc, int *i, FILE *list)
{
- bool_t res = 0;
-
- res = xdr_int(xd, i);
- if (res == 0)
+ if (xdr_int(xd, i) == 0)
{
return -1;
}
static int do_cpt_u_chars(XDR *xd, const char *desc, int n, unsigned char *i, FILE *list)
{
- bool_t res = 1;
- int j;
if (list)
{
fprintf(list, "%s = ", desc);
}
- for (j = 0; j < n && res; j++)
+ bool_t res = 1;
+ for (int j = 0; j < n && res; j++)
{
res &= xdr_u_char(xd, &i[j]);
if (list)
static void do_cpt_step_err(XDR *xd, const char *desc, gmx_int64_t *i, FILE *list)
{
- bool_t res = 0;
char buf[STEPSTRSIZE];
- res = xdr_int64(xd, i);
- if (res == 0)
+ if (xdr_int64(xd, i) == 0)
{
cp_error();
}
static void do_cpt_double_err(XDR *xd, const char *desc, double *f, FILE *list)
{
- bool_t res = 0;
-
- res = xdr_double(xd, f);
- if (res == 0)
+ if (xdr_double(xd, f) == 0)
{
cp_error();
}
static void do_cpt_real_err(XDR *xd, real *f)
{
- bool_t res = 0;
-
#ifdef GMX_DOUBLE
- res = xdr_double(xd, f);
+ bool_t res = xdr_double(xd, f);
#else
- res = xdr_float(xd, f);
+ bool_t res = xdr_float(xd, f);
#endif
if (res == 0)
{
static void do_cpt_n_rvecs_err(XDR *xd, const char *desc, int n, rvec f[], FILE *list)
{
- int i, j;
-
- for (i = 0; i < n; i++)
+ for (int i = 0; i < n; i++)
{
- for (j = 0; j < DIM; j++)
+ for (int j = 0; j < DIM; j++)
{
do_cpt_real_err(xd, &f[i][j]);
}
{
if (dtc == xdr_datatype_float)
{
- vf = (float *)vp;
+ vf = reinterpret_cast<float *>(vp);
}
else
{
snew(vf, nf);
}
- res = xdr_vector(xd, (char *)vf, nf,
- (unsigned int)sizeof(float), (xdrproc_t)xdr_float);
+ res = xdr_vector(xd, reinterpret_cast<char *>(vf), nf,
+ static_cast<unsigned int>(sizeof(float)), (xdrproc_t)xdr_float);
if (res == 0)
{
return -1;
{
snew(vd, nf);
}
- res = xdr_vector(xd, (char *)vd, nf,
- (unsigned int)sizeof(double), (xdrproc_t)xdr_double);
+ res = xdr_vector(xd, reinterpret_cast<char *>(vd), nf,
+ static_cast<unsigned int>(sizeof(double)), (xdrproc_t)xdr_double);
if (res == 0)
{
return -1;
}
vp = *v;
}
- res = xdr_vector(xd, (char *)vp, nf,
- (unsigned int)sizeof(int), (xdrproc_t)xdr_int);
+ res = xdr_vector(xd, reinterpret_cast<char *>(vp), nf,
+ static_cast<unsigned int>(sizeof(int)), (xdrproc_t)xdr_int);
if (res == 0)
{
return -1;
}
vp = *v;
}
- res = xdr_vector(xd, (char *)vp, nf,
- (unsigned int)sizeof(double), (xdrproc_t)xdr_double);
+ res = xdr_vector(xd, reinterpret_cast<char *>(vp), nf,
+ static_cast<unsigned int>(sizeof(double)), (xdrproc_t)xdr_double);
if (res == 0)
{
return -1;
real *vr;
int ret;
- vr = (real *)&(v[0][0]);
+ vr = &(v[0][0]);
ret = do_cpte_reals_low(xd, cptp, ecpt, sflags,
DIM*DIM, NULL, &vr, NULL, ecprMATRIX);
if (bRead)
{
do_cpt_string_err(xd, bRead, "output filename", &buf, list);
- strncpy(outputfiles[i].filename, buf, CPTSTRLEN-1);
+ std::strncpy(outputfiles[i].filename, buf, CPTSTRLEN-1);
if (list == NULL)
{
sfree(buf);
{
return -1;
}
- outputfiles[i].offset = ( ((gmx_off_t) offset_high) << 32 ) | ( (gmx_off_t) offset_low & mask );
+ outputfiles[i].offset = (static_cast<gmx_off_t>(offset_high) << 32 ) | ( static_cast<gmx_off_t>(offset_low) & mask );
}
else
{
}
else
{
- offset_low = (int) (offset & mask);
- offset_high = (int) ((offset >> 32) & mask);
+ offset_low = static_cast<int>(offset & mask);
+ offset_high = static_cast<int>((offset >> 32) & mask);
}
if (do_cpt_int(xd, "file_offset_high", &offset_high, list) != 0)
{
#if !GMX_NO_RENAME
/* make the new temporary filename */
- snew(fntemp, strlen(fn)+5+STEPSTRSIZE);
- strcpy(fntemp, fn);
- fntemp[strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0';
+ snew(fntemp, std::strlen(fn)+5+STEPSTRSIZE);
+ std::strcpy(fntemp, fn);
+ fntemp[std::strlen(fn) - std::strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0';
sprintf(suffix, "_%s%s", "step", gmx_step_str(step, sbuf));
- strcat(fntemp, suffix);
- strcat(fntemp, fn+strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1);
+ std::strcat(fntemp, suffix);
+ std::strcat(fntemp, fn+std::strlen(fn) - std::strlen(ftp2ext(fn2ftp(fn))) - 1);
#else
/* if we can't rename, we just overwrite the cpt file.
* dangerous if interrupted.
*/
- snew(fntemp, strlen(fn));
- strcpy(fntemp, fn);
+ snew(fntemp, std::strlen(fn));
+ std::strcpy(fntemp, fn);
#endif
gmx_format_current_time(timebuf, STRLEN);
if (gmx_fexist(fn))
{
/* Rename the previous checkpoint file */
- strcpy(buf, fn);
- buf[strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0';
- strcat(buf, "_prev");
- strcat(buf, fn+strlen(fn) - strlen(ftp2ext(fn2ftp(fn))) - 1);
+ std::strcpy(buf, fn);
+ buf[std::strlen(fn) - std::strlen(ftp2ext(fn2ftp(fn))) - 1] = '\0';
+ std::strcat(buf, "_prev");
+ std::strcat(buf, fn+std::strlen(fn) - std::strlen(ftp2ext(fn2ftp(fn))) - 1);
#ifndef GMX_FAHCORE
/* we copy here so that if something goes wrong between now and
* the rename below, there's always a state.cpt.
{
FILE *fp = fplog ? fplog : stderr;
- if (strcmp(p, f) != 0)
+ if (std::strcmp(p, f) != 0)
{
fprintf(fp, " %s mismatch,\n", type);
fprintf(fp, " current program: %s\n", p);
else
{
gmx_fatal(FARGS, "Failed to lock: %s. %s.",
- outputfiles[i].filename, strerror(errno));
+ outputfiles[i].filename, std::strerror(errno));
}
}
}
{
if (gmx_fio_seek(chksum_file, outputfiles[i].offset))
{
- gmx_fatal(FARGS, "Seek error! Failed to truncate log-file: %s.", strerror(errno));
+ gmx_fatal(FARGS, "Seek error! Failed to truncate log-file: %s.", std::strerror(errno));
}
}
#endif
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2014,2015, 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.
#include "conformation-utilities.h"
-#include <math.h>
+#include <cmath>
+
+#include <algorithm>
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/math/vec.h"
{
int i, m;
rvec xmin, xmax;
- real max_box;
/*calculate minimum and maximum x[0..DIM-1]*/
for (m = 0; (m < DIM); m++)
{
for (m = 0; m < DIM; m++)
{
- xmin[m] = min(xmin[m], x[i][m]);
- xmax[m] = max(xmax[m], x[i][m]);
+ xmin[m] = std::min(xmin[m], x[i][m]);
+ xmax[m] = std::max(xmax[m], x[i][m]);
}
}
#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#include <algorithm>
rng = gmx_rng_init(gmx_rng_make_seed());
*cqnum = static_cast<int>(nhlp*gmx_rng_uniform_real(rng));
gmx_rng_destroy(rng);
- if (strlen(help[*cqnum]) >= STRLEN)
+ if (std::strlen(help[*cqnum]) >= STRLEN)
{
help[*cqnum][STRLEN-1] = '\0';
}
- strncpy(retstring, help[*cqnum], retsize);
+ std::strncpy(retstring, help[*cqnum], retsize);
for (i = 0; (i < nhlp); i++)
{
sfree(help[i]);
else
{
*cqnum = -1;
- strncpy(retstring, defstring, retsize);
+ std::strncpy(retstring, defstring, retsize);
}
}
pukeit("gurgle.dat", "Thanx for Using GROMACS - Have a Nice Day",
tmpstr, retsize-2, p);
- if ((ptr = strchr(tmpstr, '_')) != NULL)
+ if ((ptr = std::strchr(tmpstr, '_')) != NULL)
{
*ptr = '\0';
ptr++;
}
else
{
- strcpy(retstring, tmpstr);
+ std::strcpy(retstring, tmpstr);
}
sfree(tmpstr);
}
std::string title
= formatString(":-) GROMACS - %s, %s%s (-:", name, gmx_version(), precisionString);
const int indent
- = centeringOffset(78 - strlen(prefix) - strlen(suffix), title.length()) + 1;
+ = centeringOffset(78 - std::strlen(prefix) - std::strlen(suffix), title.length()) + 1;
fprintf(fp, "%s%*c%s%s\n", prefix, indent, ' ', title.c_str(), suffix);
fprintf(fp, "%s%s\n", prefix, suffix);
if (settings.bCopyright_)
#include "config.h"
-#include <math.h>
-#include <stdlib.h>
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
#include <algorithm>
else
{
dd->dr_bMixed = ir->bDisreMixed;
- dd->ETerm = exp(-(ir->delta_t/ir->dr_tau));
+ dd->ETerm = std::exp(-(ir->delta_t/ir->dr_tau));
}
dd->ETerm1 = 1.0 - dd->ETerm;
rt_1 = gmx_invsqrt(rt2);
rt_3 = rt_1*rt_1*rt_1;
- rt[pair] = sqrt(rt2);
+ rt[pair] = std::sqrt(rt2);
if (bTav)
{
/* Here we update rm3tav in t_fcdata using the data
{
bConservative = (dr_weighting == edrwConservative) && (npair > 1);
bMixed = dr_bMixed;
- Rt = pow(Rt_6[res], -sixth);
- Rtav = pow(Rtav_6[res], -sixth);
+ Rt = std::pow(Rt_6[res], -sixth);
+ Rtav = std::pow(Rtav_6[res], -sixth);
}
else
{
/* When rtype=2 use instantaneous not ensemble avereged distance */
bConservative = (npair > 1);
bMixed = FALSE;
- Rt = pow(Rtl_6[res], -sixth);
+ Rt = std::pow(Rtl_6[res], -sixth);
Rtav = Rt;
}
}
if (bViolation)
{
- mixed_viol = sqrt(tav_viol*instant_viol);
+ mixed_viol = std::sqrt(tav_viol*instant_viol);
f_scal = -k0*mixed_viol;
violtot += mixed_viol;
}
}
else
{
- f_scal /= (real)npair;
+ f_scal /= npair;
f_scal = std::max(f_scal, fmax_scal);
}
{
if (!dr_bMixed)
{
- weight_rt_1 *= pow(dd->rm3tav[pair], seven_three);
+ weight_rt_1 *= std::pow(dd->rm3tav[pair], seven_three);
}
else
{
- weight_rt_1 *= tav_viol_Rtav7*pow(dd->rm3tav[pair], seven_three)+
- instant_viol_Rtav7*pow(dd->rt[pair], -7);
+ weight_rt_1 *= tav_viol_Rtav7*std::pow(dd->rm3tav[pair], seven_three)+
+ instant_viol_Rtav7*std::pow(dd->rt[pair], static_cast<real>(-7));
}
}
#include "config.h"
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cerrno>
+#include <cstdlib>
+#include <cstring>
+#include <algorithm>
#include <string>
#include <vector>
#if defined GMX_MPI && !defined GMX_THREAD_MPI
/* We only print the detection on one, of possibly multiple, nodes */
- strncpy(onhost, " on host ", 10);
+ std::strncpy(onhost, " on host ", 10);
gmx_gethostname(onhost + 9, HOSTNAMELEN);
#else
/* We detect all relevant GPUs */
- strncpy(onhost, "", 1);
+ std::strncpy(onhost, "", 1);
#endif
if (ngpu > 0)
char th_or_proc[STRLEN], th_or_proc_plural[STRLEN], pernode[STRLEN];
gmx_bool btMPI, bMPI, bNthreadsAuto, bEmulateGPU;
- assert(hwinfo);
- assert(cr);
+ GMX_RELEASE_ASSERT(hwinfo, "hwinfo must be a non-NULL pointer");
+ GMX_RELEASE_ASSERT(cr, "cr must be a non-NULL pointer");
/* Below we only do consistency checks for PP and GPUs,
* this is irrelevant for PME only nodes, so in that case we return
int i, uniq_count, ngpu;
int *uniq_ids;
- assert(gpu_info);
- assert(gpu_opt);
+ GMX_RELEASE_ASSERT(gpu_info, "gpu_info must be a non-NULL pointer");
+ GMX_RELEASE_ASSERT(gpu_opt, "gpu_opt must be a non-NULL pointer");
ngpu = gpu_info->n_dev;
MPI_Comm_rank(physicalnode_comm, &rank_local);
#else
/* Here there should be only one process, check this */
- assert(cr->nnodes == 1 && cr->sim_nodeid == 0);
+ GMX_RELEASE_ASSERT(cr->nnodes == 1 && cr->sim_nodeid == 0, "Only a single (master) process should execute here");
rank_local = 0;
#endif
#include "config.h"
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "gromacs/legacyheaders/copyrite.h"
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/legacyheaders/types/commrec.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/gmxomp.h"
/** Structure with the number of threads for each OpenMP multi-threaded
gmx_bool bCommandLineSetNthreadsOMP = *nthreads_omp > 0;
char buffer[STRLEN];
- assert(nthreads_omp);
+ GMX_RELEASE_ASSERT(nthreads_omp, "nthreads_omp must be a non-NULL pointer");
if ((env = getenv("OMP_NUM_THREADS")) != NULL)
{
nth = 1;
if ((env = getenv("OMP_NUM_THREADS")) != NULL)
{
- if (!bOMP && (strncmp(env, "1", 1) != 0))
+ if (!bOMP && (std::strncmp(env, "1", 1) != 0))
{
gmx_warning("OMP_NUM_THREADS is set, but %s was compiled without OpenMP support!",
ShortProgram());
gmx_bool bThisNodePMEOnly,
gmx_bool bFullOmpSupport)
{
- int nth_pmeonly, gmx_maxth, nppn;
+ int nppn;
gmx_bool bSepPME, bOMP;
#ifdef GMX_OPENMP
{
/* Catch an attempt to set the number of threads on an invalid
* OpenMP module. */
- assert(mod >= 0 && mod < emntNR);
+ GMX_RELEASE_ASSERT(mod >= 0 && mod < emntNR, "Trying to set nthreads on invalid OpenMP module");
modth.nth[mod] = nthreads;
}
#include "config.h"
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
+#include <cerrno>
+#include <cstdio>
+#include <cstring>
#ifdef HAVE_SCHED_AFFINITY
# include <sched.h>
#include "gromacs/utility/basenetwork.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/gmxomp.h"
#include "gromacs/utility/smalloc.h"
const gmx_hw_info_t *hwinfo)
{
int nth_affinity_set, thread0_id_node,
- nthread_local, nthread_node, nthread_hw_max, nphyscore;
+ nthread_local, nthread_node;
int offset;
const int *locality_order;
int rc;
* Reducing these 0/1 values over the threads will give the total number
* of threads on which we succeeded.
*/
+
+ // To avoid warnings from the static analyzer we initialize nth_affinity_set
+ // to zero outside the OpenMP block, and then add to it inside the block.
+ // The value will still always be 0 or 1 from each thread.
nth_affinity_set = 0;
#pragma omp parallel num_threads(nthread_local) reduction(+:nth_affinity_set)
{
setaffinity_ret = tMPI_Thread_setaffinity_single(tMPI_Thread_self(), core);
/* store the per-thread success-values of the setaffinity */
- nth_affinity_set = (setaffinity_ret == 0);
+ nth_affinity_set += (setaffinity_ret == 0);
if (debug)
{
int gmx_unused nthreads_hw_avail,
gmx_bool bAfterOpenmpInit)
{
-#ifdef HAVE_SCHED_AFFINITY
- cpu_set_t mask_current;
- int i, ret, cpu_count, cpu_set;
- gmx_bool bAllSet;
-#endif
-#ifdef GMX_LIB_MPI
- gmx_bool bAllSet_All;
-#endif
+ GMX_RELEASE_ASSERT(hw_opt, "hw_opt must be a non-NULL pointer");
- assert(hw_opt);
if (!bAfterOpenmpInit)
{
/* Check for externally set OpenMP affinity and turn off internal
}
#ifdef HAVE_SCHED_GETAFFINITY
+ int ret;
+ cpu_set_t mask_current;
+
if (hw_opt->thread_affinity == threadaffOFF)
{
/* internal affinity setting is off, don't bother checking process affinity */
}
#endif /* CPU_COUNT */
- bAllSet = TRUE;
- for (i = 0; (i < nthreads_hw_avail && i < CPU_SETSIZE); i++)
+ gmx_bool bAllSet = TRUE;
+ for (int i = 0; (i < nthreads_hw_avail && i < CPU_SETSIZE); i++)
{
bAllSet = bAllSet && (CPU_ISSET(i, &mask_current) != 0);
}
#ifdef GMX_LIB_MPI
+ gmx_bool bAllSet_All;
+
MPI_Allreduce(&bAllSet, &bAllSet_All, 1, MPI_INT, MPI_LAND, MPI_COMM_WORLD);
bAllSet = bAllSet_All;
#endif
}
else
{
- n = (int)(ir->tau_p/(ir->delta_t*nmin) + 0.001);
+ n = static_cast<int>(ir->tau_p/(ir->delta_t*nmin) + 0.001);
if (n < 1)
{
n = 1;
#include "config.h"
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "gromacs/fileio/filenm.h"
#include "gromacs/fileio/gmxfio.h"
gmx_bool bAppendSimId, gmx_bool bAppendNodeId,
char buf[], int bufsize)
{
- if ((size_t)bufsize < (strlen(base)+10))
+ if (static_cast<std::size_t>(bufsize) < (std::strlen(base)+10))
{
gmx_mem("Character buffer too small!");
}
/* Copy to buf, and strip extension */
- strcpy(buf, base);
- buf[strlen(base) - strlen(ftp2ext(fn2ftp(base))) - 1] = '\0';
+ std::strcpy(buf, base);
+ buf[strlen(base) - std::strlen(ftp2ext(fn2ftp(base))) - 1] = '\0';
if (bAppendSimId)
{
}
if (bAppendNodeId)
{
- strcat(buf, "_rank");
+ std::strcat(buf, "_rank");
sprintf(buf+strlen(buf), "%d", cr->nodeid);
}
- strcat(buf, ".");
+ std::strcat(buf, ".");
/* Add extension again */
- strcat(buf, (ftp == efTPR) ? "tpr" : (ftp == efEDR) ? "edr" : ftp2ext(ftp));
+ std::strcat(buf, (ftp == efTPR) ? "tpr" : (ftp == efEDR) ? "edr" : ftp2ext(ftp));
if (debug)
{
fprintf(debug, "rank %d par_fn '%s'\n", cr->nodeid, buf);
#include "gromacs/legacyheaders/md_logging.h"
-#include <stdarg.h>
-#include <stdio.h>
+#include <cstdarg>
+#include <cstdio>
#include "gromacs/legacyheaders/types/commrec.h"
#include "config.h"
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cctype>
+#include <cstdarg>
+#include <cstdlib>
+#include <cstring>
#include "gromacs/legacyheaders/copyrite.h"
#include "gromacs/legacyheaders/macros.h"
nc->bUse = FALSE;
#ifndef GMX_THREAD_MPI
#ifdef GMX_MPI
- int n, rank, nodehash, ng, ni;
+ int n, rank;
MPI_Comm_size(cr->mpi_comm_mygroup, &n);
MPI_Comm_rank(cr->mpi_comm_mygroup, &rank);
- nodehash = gmx_physicalnode_id_hash();
+ int nodehash = gmx_physicalnode_id_hash();
if (debug)
{
*/
MPI_Comm_split(cr->mpi_comm_mygroup, nc->rank_intra, rank, &nc->comm_inter);
/* Check if this really created two step communication */
+ int ng, ni;
+
MPI_Comm_size(nc->comm_inter, &ng);
MPI_Comm_size(nc->comm_intra, &ni);
if (debug)
#include "gromacs/legacyheaders/nrnb.h"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
+
+#include <algorithm>
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/legacyheaders/names.h"
int ndays, nhours, nmins, nsecs;
gmx_bool bPrint, bPrinted;
- ndays = dt/(24*3600);
+ ndays = static_cast<int>(dt/(24*3600));
dt = dt-24*3600*ndays;
- nhours = dt/3600;
+ nhours = static_cast<int>(dt/3600);
dt = dt-3600*nhours;
- nmins = dt/60;
+ nmins = static_cast<int>(dt/60);
dt = dt-nmins*60;
- nsecs = dt;
+ nsecs = static_cast<int>(dt);
bPrint = (ndays > 0);
bPrinted = bPrint;
if (bPrint)
*nbfs = 0.0;
for (i = 0; (i < eNR_NBKERNEL_ALLVSALLGB); i++)
{
- if (strstr(nbdata[i].name, "W3-W3") != NULL)
+ if (std::strstr(nbdata[i].name, "W3-W3") != NULL)
{
*nbfs += 9e-6*nrnb->n[i];
}
- else if (strstr(nbdata[i].name, "W3") != NULL)
+ else if (std::strstr(nbdata[i].name, "W3") != NULL)
{
*nbfs += 3e-6*nrnb->n[i];
}
- else if (strstr(nbdata[i].name, "W4-W4") != NULL)
+ else if (std::strstr(nbdata[i].name, "W4-W4") != NULL)
{
*nbfs += 10e-6*nrnb->n[i];
}
- else if (strstr(nbdata[i].name, "W4") != NULL)
+ else if (std::strstr(nbdata[i].name, "W4") != NULL)
{
*nbfs += 4e-6*nrnb->n[i];
}
for (i = 0; (i < cr->nnodes); i++)
{
dperc = (100.0*ftot[i])/fav;
- unb = max(unb, dperc);
- perc = dperc;
+ unb = std::max(unb, dperc);
+ perc = static_cast<int>(dperc);
fprintf(log, "%3d ", perc);
}
if (unb > 0)
{
- perc = 10000.0/unb;
+ perc = static_cast<int>(10000.0/unb);
fprintf(log, "%6d%%\n\n", perc);
}
else
}
for (j = 0; (j < eNRNB); j++)
{
- av->n[j] = av->n[j]/(double)(cr->nnodes - cr->npmenodes);
+ av->n[j] = av->n[j]/static_cast<double>(cr->nnodes - cr->npmenodes);
}
fprintf(log, "\nDetailed load balancing info in percentage of average\n");
for (i = 0; (i < cr->nnodes); i++)
{
dperc = (100.0*nrnb[i].n[j])/av->n[j];
- unb = max(unb, dperc);
- perc = dperc;
+ unb = std::max(unb, dperc);
+ perc = static_cast<int>(dperc);
fprintf(log, "%3d ", perc);
}
if (unb > 0)
{
- perc = 10000.0/unb;
+ perc = static_cast<int>(10000.0/unb);
fprintf(log, "%6d%%\n", perc);
}
else
#include "gromacs/legacyheaders/orires.h"
+#include <cmath>
+
#include "gromacs/legacyheaders/copyrite.h"
#include "gromacs/legacyheaders/main.h"
#include "gromacs/legacyheaders/network.h"
else
{
snew(od->Dtav, od->nr);
- od->edt = exp(-ir->delta_t/ir->orires_tau);
+ od->edt = std::exp(-ir->delta_t/ir->orires_tau);
od->edt_1 = 1.0 - od->edt;
/* Extend the state with the orires history */
d++;
}
- od->rmsdev = sqrt(wsv2/sw);
+ od->rmsdev = std::sqrt(wsv2/sw);
/* Rotate the S matrices back, so we get the correct grad(tr(S D)) */
for (ex = 0; ex < od->nex; ex++)
}
else
{
- dev = sqrt(dev*devins);
+ dev = std::sqrt(dev*devins);
if (devins < 0)
{
dev = -dev;
int k, i, ni, mi, n, m;
cr = init_par(&argc, argv);
- n = strtol(argv[1], NULL, 10);
- m = strtol(argv[2], NULL, 10);
+ n = std::strtol(argv[1], NULL, 10);
+ m = std::strtol(argv[2], NULL, 10);
fprintf(stdlog, "n=%d\n", n);
rb = mk_bin();
snew(r, n);
#include "gromacs/legacyheaders/readinp.h"
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include <algorithm>
#include "gromacs/fileio/gmxfio.h"
#include "gromacs/legacyheaders/macros.h"
if (ptr)
{
/* Strip comment */
- if ((cptr = strchr(buf, COMMENTSIGN)) != NULL)
+ if ((cptr = std::strchr(buf, COMMENTSIGN)) != NULL)
{
*cptr = '\0';
}
else
{
/* override */
+ if (!inp)
+ {
+ gmx_fatal(FARGS, "Internal inconsistency; inp[] base pointer is NULL");
+ }
sfree(inp[found_index].value);
inp[found_index].value = gmx_strdup(rbuf);
sprintf(warn_buf,
static int inp_comp(const void *a, const void *b)
{
- return ((t_inpfile *)a)->count - ((t_inpfile *)b)->count;
+ return (reinterpret_cast<const t_inpfile *>(a))->count - (reinterpret_cast<const t_inpfile *>(b))->count;
}
static void sort_inp(int ninp, t_inpfile inp[])
mm = -1;
for (i = 0; (i < ninp); i++)
{
- mm = max(mm, inp[i].count);
+ mm = std::max(mm, inp[i].count);
}
for (i = 0; (i < ninp); i++)
{
inp[i].count = mm++;
}
}
- gmx_qsort(inp, ninp, (size_t)sizeof(inp[0]), inp_comp);
+ gmx_qsort(inp, ninp, static_cast<size_t>(sizeof(inp[0])), inp_comp);
}
void write_inpfile(const char *fn, int ninp, t_inpfile inp[], gmx_bool bHaltOnUnknown,
{
int i;
int notfound = FALSE;
- char warn_buf[STRLEN];
-/* if (inp==NULL)
- return -1;
- for(i=0; (i<(*ninp)); i++)
- if (gmx_strcasecmp_min(name,(*inp)[i].name) == 0)
- break;
- if (i == (*ninp)) {*/
i = search_einp(*ninp, *inp, name);
if (i == -1)
{
}
else
{
- ret = strtol((*inp)[ii].value, &ptr, 10);
+ ret = std::strtol((*inp)[ii].value, &ptr, 10);
if (ptr == (*inp)[ii].value)
{
sprintf(warn_buf, "Right hand side '%s' for parameter '%s' in parameter file is not an integer value\n", (*inp)[ii].value, (*inp)[ii].name);
if (ii == -1)
{
- sprintf(buf, "%"GMX_PRId64, def);
+ sprintf(buf, "%" GMX_PRId64, def);
(*inp)[(*ninp)-1].value = gmx_strdup(buf);
return def;
int get_eenum(int *ninp, t_inpfile **inp, const char *name, const char **defs)
{
- int dum = 0;
-
return get_eeenum(ninp, inp, name, defs, NULL);
}
#include "config.h"
-#include <stdlib.h>
+#include <cstdlib>
#include "gromacs/legacyheaders/typedefs.h"
#include "gromacs/utility/fatalerror.h"
gmx_bool gmx_got_usr_signal(void)
{
#if HAVE_SIGUSR1
- gmx_bool ret = (gmx_bool)usr_condition;
+ gmx_bool ret = static_cast<gmx_bool>(usr_condition);
usr_condition = 0;
return ret;
#else
*
* 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
+ * Copyright (c) 2013,2014,2015, 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.
#include "gromacs/legacyheaders/splitter.h"
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
+
+#include <algorithm>
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/pbcutil/mshift.h"
#include "gromacs/topology/block.h"
#include "gromacs/topology/idef.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/smalloc.h"
typedef struct {
static int ms_comp(const void *a, const void *b)
{
- t_merge_sid *ma = (t_merge_sid *)a;
- t_merge_sid *mb = (t_merge_sid *)b;
- int d;
+ const t_merge_sid *ma = reinterpret_cast<const t_merge_sid *>(a);
+ const t_merge_sid *mb = reinterpret_cast<const t_merge_sid *>(b);
+ int d;
d = ma->first-mb->first;
if (d == 0)
{
int i, j, k, n, isid, ndel;
t_merge_sid *ms;
- int nChanged;
/* We try to remdy the following problem:
* Atom: 1 2 3 4 5 6 7 8 9 10
range_check(isid, -1, nsid);
if (isid >= 0)
{
- ms[isid].first = min(ms[isid].first, sid[i].atom);
- ms[isid].last = max(ms[isid].last, sid[i].atom);
+ ms[isid].first = std::min(ms[isid].first, sid[i].atom);
+ ms[isid].last = std::max(ms[isid].last, sid[i].atom);
}
}
qsort(ms, nsid, sizeof(ms[0]), ms_comp);
{
if (ms[j].first <= ms[k].last)
{
- ms[k].last = max(ms[k].last, ms[j].last);
- ms[k].first = min(ms[k].first, ms[j].first);
+ ms[k].last = std::max(ms[k].last, ms[j].last);
+ ms[k].first = std::min(ms[k].first, ms[j].first);
ms[j].sid = -1;
ndel++;
j++;
{
for (j = k+1; (j < nsid); j++)
{
- memcpy(&(ms[j-1]), &(ms[j]), sizeof(ms[0]));
+ std::memcpy(&(ms[j-1]), &(ms[j]), sizeof(ms[0]));
}
nsid--;
}
}
}
}
- assert(k == nsid);
- /* Removed 2007-09-04
- sblock->index[k+1] = natoms;
- for(k=0; (k<natoms); k++)
- if (sid[k].sid == -1)
- sblock->a[n++] = k;
- assert(n == natoms);
- */
+
sblock->nra = n;
- assert(sblock->index[k] == sblock->nra);
+ GMX_RELEASE_ASSERT(sblock->index[k] == sblock->nra, "Internal inconsistency; sid merge failed");
+
sfree(ms);
return nsid;
gmx_bool bSettle)
{
t_graph *g;
- int i, i0, j, k, istart, n;
+ int i, i0;
t_sid *sid;
- int isid, nsid;
+ int nsid;
g = mk_graph(NULL, idef, at_start, at_end, TRUE, bSettle);
if (debug)
}
/* Now sort the shake blocks... */
- qsort(sid+at_start, at_end-at_start, (size_t)sizeof(sid[0]), sid_comp);
+ qsort(sid+at_start, at_end-at_start, static_cast<size_t>(sizeof(sid[0])), sid_comp);
if (debug)
{
* part of the shake block too. There may be cases where blocks overlap
* and they will have to be merged.
*/
- nsid = merge_sid(at_start, at_end, nsid, sid, sblock);
- /* Now sort the shake blocks again... */
- /*qsort(sid,natoms,(size_t)sizeof(sid[0]),sid_comp);*/
-
- /* Fill the sblock struct */
- /* sblock->nr = nsid;
- sblock->nra = natoms;
- srenew(sblock->a,sblock->nra);
- srenew(sblock->index,sblock->nr+1);
-
- i = i0;
- isid = sid[i].sid;
- n = k = 0;
- sblock->index[n++]=k;
- while (i < natoms) {
- istart = sid[i].atom;
- while ((i<natoms-1) && (sid[i+1].sid == isid))
- i++;*/
- /* After while: we found a new block, or are thru with the atoms */
- /* for(j=istart; (j<=sid[i].atom); j++,k++)
- sblock->a[k]=j;
- sblock->index[n] = k;
- if (i < natoms-1)
- n++;
- if (n > nsid)
- gmx_fatal(FARGS,"Death Horror: nsid = %d, n= %d",nsid,n);
- i++;
- isid = sid[i].sid;
- }
- */
+ merge_sid(at_start, at_end, nsid, sid, sblock);
sfree(sid);
/* Due to unknown reason this free generates a problem sometimes */
done_graph(g);
#include "gromacs/legacyheaders/txtdump.h"
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
#include <algorithm>
for (i = 0; i < n; i++)
{
- (void) fprintf(fp, " ");
+ fprintf(fp, " ");
}
return n;
}
{
pr_indent(fp, indent);
}
- (void) fprintf(fp, "%s: not available\n", title);
+ fprintf(fp, "%s: not available\n", title);
}
return (p != NULL);
}
int pr_title(FILE *fp, int indent, const char *title)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s:\n", title);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s:\n", title);
return (indent+INDENT);
}
int pr_title_n(FILE *fp, int indent, const char *title, int n)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s (%d):\n", title, n);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s (%d):\n", title, n);
return (indent+INDENT);
}
int pr_title_nxn(FILE *fp, int indent, const char *title, int n1, int n2)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s (%dx%d):\n", title, n1, n2);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s (%dx%d):\n", title, n1, n2);
return (indent+INDENT);
}
indent = pr_title_n(fp, indent, title, n);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d]=%d\n", title, bShowNumbers ? i : -1, vec[i]);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d]=%d\n", title, bShowNumbers ? i : -1, vec[i]);
}
}
}
{
while (i < j)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d]=%d\n",
- title, bShowNumbers ? i : -1, vec[i]);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d]=%d\n",
+ title, bShowNumbers ? i : -1, vec[i]);
i++;
}
}
else
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d,...,%d] = {%d,...,%d}\n",
- title,
- bShowNumbers ? i : -1,
- bShowNumbers ? j-1 : -1,
- vec[i], vec[j-1]);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d,...,%d] = {%d,...,%d}\n",
+ title,
+ bShowNumbers ? i : -1,
+ bShowNumbers ? j-1 : -1,
+ vec[i], vec[j-1]);
i = j;
}
}
indent = pr_title_n(fp, indent, title, n);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d]=%s\n", title, bShowNumbers ? i : -1,
- EBOOL(vec[i]));
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d]=%s\n", title, bShowNumbers ? i : -1,
+ EBOOL(vec[i]));
}
}
}
indent = pr_title_nxn(fp, indent, title, n, DIM);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d]={", title, bShowNumbers ? i : -1);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d]={", title, bShowNumbers ? i : -1);
for (j = 0; j < DIM; j++)
{
if (j != 0)
{
- (void) fprintf(fp, ", ");
+ fprintf(fp, ", ");
}
fprintf(fp, "%d", vec[i][j]);
}
- (void) fprintf(fp, "}\n");
+ fprintf(fp, "}\n");
}
}
}
indent = pr_title_nxn(fp, indent, title, n, DIM);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%5d]={", title, i);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%5d]={", title, i);
for (j = 0; j < DIM; j++)
{
if (j != 0)
{
- (void) fprintf(fp, ", ");
+ fprintf(fp, ", ");
}
- (void) fprintf(fp, "%12.5e", vec[i][j]);
+ fprintf(fp, "%12.5e", vec[i][j]);
}
- (void) fprintf(fp, "} len=%12.5e\n", norm(vec[i]));
+ fprintf(fp, "} len=%12.5e\n", norm(vec[i]));
}
}
}
indent = pr_title_nxn(fp, indent, title, n, DIM);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%5d]={", title, i);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%5d]={", title, i);
for (j = 0; j < DIM; j++)
{
if (j != 0)
{
- (void) fprintf(fp, ", ");
+ fprintf(fp, ", ");
}
- (void) fprintf(fp, format, vec[i][j]);
+ fprintf(fp, format, vec[i][j]);
}
- (void) fprintf(fp, "}\n");
+ fprintf(fp, "}\n");
}
}
}
indent = pr_title_nxn(fp, indent, title, n, dim);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%5d]={", title, i);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%5d]={", title, i);
for (j = 0; j < dim; j++)
{
if (j != 0)
{
- (void) fprintf(fp, ", ");
+ fprintf(fp, ", ");
}
- (void) fprintf(fp, format, vec[i][j]);
+ fprintf(fp, format, vec[i][j]);
}
- (void) fprintf(fp, "}\n");
+ fprintf(fp, "}\n");
}
}
}
if (available(fp, vec, indent, title))
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s:\t", title);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s:\t", title);
for (i = 0; i < n; i++)
{
fprintf(fp, " %10g", vec[i]);
}
- (void) fprintf(fp, "\n");
+ fprintf(fp, "\n");
}
}
if (available(fp, vec, indent, title))
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s:\t", title);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s:\t", title);
for (i = 0; i < n; i++)
{
fprintf(fp, " %10g", vec[i]);
}
- (void) fprintf(fp, "\n");
+ fprintf(fp, "\n");
}
}
indent = pr_title_nxn(fp, indent, title, n, dim);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%5d]={", title, i);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%5d]={", title, i);
for (j = 0; j < dim; j++)
{
if (j != 0)
{
- (void) fprintf(fp, ", ");
+ fprintf(fp, ", ");
}
- (void) fprintf(fp, format, vec[i * dim + j]);
+ fprintf(fp, format, vec[i * dim + j]);
}
- (void) fprintf(fp, "}\n");
+ fprintf(fp, "}\n");
}
}
}
else
{
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "n = %d\n", cos->n);
if (cos->n > 0)
{
- (void) pr_indent(fp, indent+2);
+ pr_indent(fp, indent+2);
fprintf(fp, "a =");
for (j = 0; (j < cos->n); j++)
{
fprintf(fp, " %e", cos->a[j]);
}
fprintf(fp, "\n");
- (void) pr_indent(fp, indent+2);
+ pr_indent(fp, indent+2);
fprintf(fp, "phi =");
for (j = 0; (j < cos->n); j++)
{
if (available(fp, ilist, indent, title) && ilist->nr > 0)
{
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "nr: %d\n", ilist->nr);
if (ilist->nr > 0)
{
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "iatoms:\n");
iatoms = ilist->iatoms;
for (i = j = 0; i < ilist->nr; )
{
#ifndef DEBUG
- (void) pr_indent(fp, indent+INDENT);
+ pr_indent(fp, indent+INDENT);
type = *(iatoms++);
ftype = functype[type];
- (void) fprintf(fp, "%d type=%d (%s)",
- bShowNumbers ? j : -1, bShowNumbers ? type : -1,
- interaction_function[ftype].name);
+ fprintf(fp, "%d type=%d (%s)",
+ bShowNumbers ? j : -1, bShowNumbers ? type : -1,
+ interaction_function[ftype].name);
j++;
for (k = 0; k < interaction_function[ftype].nratoms; k++)
{
- (void) fprintf(fp, " %d", *(iatoms++));
+ fprintf(fp, " %d", *(iatoms++));
}
- (void) fprintf(fp, "\n");
+ fprintf(fp, "\n");
i += 1+interaction_function[ftype].nratoms;
#else
fprintf(fp, "%5d%5d\n", i, iatoms[i]);
int i;
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "atnr=%d\n", ffparams->atnr);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "ntypes=%d\n", ffparams->ntypes);
+ pr_indent(fp, indent);
+ fprintf(fp, "atnr=%d\n", ffparams->atnr);
+ pr_indent(fp, indent);
+ fprintf(fp, "ntypes=%d\n", ffparams->ntypes);
for (i = 0; i < ffparams->ntypes; i++)
{
- (void) pr_indent(fp, indent+INDENT);
- (void) fprintf(fp, "functype[%d]=%s, ",
- bShowNumbers ? i : -1,
- interaction_function[ffparams->functype[i]].name);
+ pr_indent(fp, indent+INDENT);
+ fprintf(fp, "functype[%d]=%s, ",
+ bShowNumbers ? i : -1,
+ interaction_function[ffparams->functype[i]].name);
pr_iparams(fp, ffparams->functype[i], &ffparams->iparams[i]);
}
- (void) pr_double(fp, indent, "reppow", ffparams->reppow);
- (void) pr_real(fp, indent, "fudgeQQ", ffparams->fudgeQQ);
+ pr_double(fp, indent, "reppow", ffparams->reppow);
+ pr_real(fp, indent, "fudgeQQ", ffparams->fudgeQQ);
pr_cmap(fp, indent, "cmap", &ffparams->cmap_grid, bShowNumbers);
}
if (available(fp, idef, indent, title))
{
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "atnr=%d\n", idef->atnr);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "ntypes=%d\n", idef->ntypes);
+ pr_indent(fp, indent);
+ fprintf(fp, "atnr=%d\n", idef->atnr);
+ pr_indent(fp, indent);
+ fprintf(fp, "ntypes=%d\n", idef->ntypes);
for (i = 0; i < idef->ntypes; i++)
{
- (void) pr_indent(fp, indent+INDENT);
- (void) fprintf(fp, "functype[%d]=%s, ",
- bShowNumbers ? i : -1,
- interaction_function[idef->functype[i]].name);
+ pr_indent(fp, indent+INDENT);
+ fprintf(fp, "functype[%d]=%s, ",
+ bShowNumbers ? i : -1,
+ interaction_function[idef->functype[i]].name);
pr_iparams(fp, idef->functype[i], &idef->iparams[i]);
}
- (void) pr_real(fp, indent, "fudgeQQ", idef->fudgeQQ);
+ pr_real(fp, indent, "fudgeQQ", idef->fudgeQQ);
for (j = 0; (j < F_NRE); j++)
{
if (available(fp, block, indent, title))
{
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "nr=%d\n", block->nr);
+ pr_indent(fp, indent);
+ fprintf(fp, "nr=%d\n", block->nr);
}
return indent;
}
if (available(fp, block, indent, title))
{
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "nr=%d\n", block->nr);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "nra=%d\n", block->nra);
+ pr_indent(fp, indent);
+ fprintf(fp, "nr=%d\n", block->nr);
+ pr_indent(fp, indent);
+ fprintf(fp, "nra=%d\n", block->nra);
}
return indent;
}
indent = pr_blocka_title(fp, indent, title, block);
for (i = 0; i <= block->nr; i++)
{
- (void) pr_indent(fp, indent+INDENT);
- (void) fprintf(fp, "%s->index[%d]=%d\n",
- title, bShowNumbers ? i : -1, block->index[i]);
+ pr_indent(fp, indent+INDENT);
+ 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]=%d\n",
- title, bShowNumbers ? i : -1, block->a[i]);
+ pr_indent(fp, indent+INDENT);
+ fprintf(fp, "%s->a[%d]=%d\n",
+ title, bShowNumbers ? i : -1, block->a[i]);
}
}
}
start = 0;
if (block->index[start] != 0)
{
- (void) fprintf(fp, "block->index[%d] should be 0\n", start);
+ fprintf(fp, "block->index[%d] should be 0\n", start);
}
else
{
end = start;
if ((ok = (block->index[start] == 0)) == 0)
{
- (void) fprintf(fp, "block->index[%d] should be 0\n", start);
+ fprintf(fp, "block->index[%d] should be 0\n", start);
}
else
{
}
if ((size) > (USE_WIDTH))
{
- (void) fprintf(fp, "\n");
+ fprintf(fp, "\n");
size = pr_indent(fp, indent+INDENT);
}
size += fprintf(fp, "%d", block->a[j]);
}
- (void) fprintf(fp, "}\n");
+ fprintf(fp, "}\n");
start = end;
}
}
if ((end != block->nra) || (!ok))
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "tables inconsistent, dumping complete tables:\n");
+ pr_indent(fp, indent);
+ fprintf(fp, "tables inconsistent, dumping complete tables:\n");
low_pr_blocka(fp, indent, title, block, bShowNumbers);
}
}
indent = pr_title_n(fp, indent, title, n);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d]={name=\"%s\"}\n",
- title, bShowNumbers ? i : -1, *(nm[i]));
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d]={name=\"%s\"}\n",
+ title, bShowNumbers ? i : -1, *(nm[i]));
}
}
}
indent = pr_title_n(fp, indent, title, n);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d]={name=\"%s\",nameB=\"%s\"}\n",
- title, bShowNumbers ? i : -1, *(nm[i]), *(nmB[i]));
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d]={name=\"%s\",nameB=\"%s\"}\n",
+ title, bShowNumbers ? i : -1, *(nm[i]), *(nmB[i]));
}
}
}
indent = pr_title_n(fp, indent, title, n);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%s[%d]={name=\"%s\", nr=%d, ic='%c'}\n",
- title, bShowNumbers ? i : -1,
- *(resinfo[i].name), resinfo[i].nr,
- (resinfo[i].ic == '\0') ? ' ' : resinfo[i].ic);
+ pr_indent(fp, indent);
+ fprintf(fp, "%s[%d]={name=\"%s\", nr=%d, ic='%c'}\n",
+ title, bShowNumbers ? i : -1,
+ *(resinfo[i].name), resinfo[i].nr,
+ (resinfo[i].ic == '\0') ? ' ' : resinfo[i].ic);
}
}
}
indent = pr_title_n(fp, indent, title, n);
for (i = 0; i < n; i++)
{
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "%s[%6d]={type=%3d, typeB=%3d, ptype=%8s, m=%12.5e, "
"q=%12.5e, mB=%12.5e, qB=%12.5e, resind=%5d, atomnumber=%3d}\n",
title, i, atom[i].type, atom[i].typeB, ptype_str[atom[i].ptype],
pr_grps(fp, "grp", groups->grps, groups->grpname);
pr_strings(fp, indent, "grpname", groups->grpname, groups->ngrpname, bShowNumbers);
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "groups ");
for (g = 0; g < egcNR; g++)
{
}
printf("\n");
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "allocated ");
nat_max = 0;
for (g = 0; g < egcNR; g++)
if (nat_max == 0)
{
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "groupnr[%5s] =", "*");
for (g = 0; g < egcNR; g++)
{
{
for (i = 0; i < nat_max; i++)
{
- (void) pr_indent(fp, indent);
+ pr_indent(fp, indent);
fprintf(fp, "groupnr[%5d] =", i);
for (g = 0; g < egcNR; g++)
{
int j;
indent = pr_title_n(fp, indent, title, n);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "name=\"%s\"\n", *(molt->name));
+ pr_indent(fp, indent);
+ fprintf(fp, "name=\"%s\"\n", *(molt->name));
pr_atoms(fp, indent, "atoms", &(molt->atoms), bShowNumbers);
pr_block(fp, indent, "cgs", &molt->cgs, bShowNumbers);
pr_blocka(fp, indent, "excls", &molt->excls, bShowNumbers);
gmx_moltype_t *molt)
{
indent = pr_title_n(fp, indent, title, n);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "%-20s = %d \"%s\"\n",
- "moltype", molb->type, *(molt[molb->type].name));
+ pr_indent(fp, indent);
+ fprintf(fp, "%-20s = %d \"%s\"\n",
+ "moltype", molb->type, *(molt[molb->type].name));
pr_int(fp, indent, "#molecules", molb->nmol);
pr_int(fp, indent, "#atoms_mol", molb->natoms_mol);
pr_int(fp, indent, "#posres_xA", molb->nposres_xA);
if (available(fp, mtop, indent, title))
{
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "name=\"%s\"\n", *(mtop->name));
+ pr_indent(fp, indent);
+ fprintf(fp, "name=\"%s\"\n", *(mtop->name));
pr_int(fp, indent, "#atoms", mtop->natoms);
pr_int(fp, indent, "#molblock", mtop->nmolblock);
for (mb = 0; mb < mtop->nmolblock; mb++)
if (available(fp, top, indent, title))
{
indent = pr_title(fp, indent, title);
- (void) pr_indent(fp, indent);
- (void) fprintf(fp, "name=\"%s\"\n", *(top->name));
+ pr_indent(fp, indent);
+ fprintf(fp, "name=\"%s\"\n", *(top->name));
pr_atoms(fp, indent, "atoms", &(top->atoms), bShowNumbers);
pr_atomtypes(fp, indent, "atomtypes", &(top->atomtypes), bShowNumbers);
pr_block(fp, indent, "cgs", &top->cgs, bShowNumbers);
#include "gromacs/legacyheaders/typedefs.h"
-#include <string.h>
+#include <cstring>
#include <algorithm>
{
int i;
- i = (int)step;
+ i = static_cast<int>(step);
if (warn != NULL && (step < INT_MIN || step > INT_MAX))
{
void init_inputrec(t_inputrec *ir)
{
- memset(ir, 0, (size_t)sizeof(*ir));
+ std::memset(ir, 0, sizeof(*ir));
snew(ir->fepvals, 1);
snew(ir->expandedvals, 1);
snew(ir->simtempvals, 1);
*
* 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
+ * Copyright (c) 2013,2014,2015, 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.
#include "gromacs/legacyheaders/viewit.h"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
#include "gromacs/fileio/filenm.h"
#include "gromacs/legacyheaders/macros.h"
#include "gromacs/legacyheaders/warninp.h"
-#include <string.h>
+#include <cstring>
#include "gromacs/legacyheaders/copyrite.h"
#include "gromacs/utility/cstringutil.h"
{
if (s != NULL)
{
- strcpy(wi->filenm, s);
+ std::strcpy(wi->filenm, s);
}
wi->lineno = line;
}
{
s = "Empty error message.";
}
- snew(temp, strlen(s)+indent+1);
+ snew(temp, std::strlen(s)+indent+1);
for (i = 0; i < indent; i++)
{
temp[i] = ' ';
}
temp[indent] = '\0';
- strcat(temp, s);
+ std::strcat(temp, s);
temp2 = wrap_lines(temp, 78-indent, indent, FALSE);
- if (strlen(wi->filenm) > 0)
+ if (std::strlen(wi->filenm) > 0)
{
if (wi->lineno != -1)
{