#include "gromacs/commandline/pargs.h"
#include "gromacs/fft/calcgrid.h"
#include "gromacs/fileio/checkpoint.h"
-#include "gromacs/fileio/readinp.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/gmxana/gmx_ana.h"
#include "gromacs/math/utilities.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/perf_est.h"
+#include "gromacs/mdrunutility/mdmodules.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
fp = fopen(fn_out, "r");
fprintf(stdout, "\n\n");
- while (fgets(buf, STRLEN-1, fp) != NULL)
+ while (fgets(buf, STRLEN-1, fp) != nullptr)
{
fprintf(stdout, "%s", buf);
}
iFound = eFoundDDStr; /* Skip some case statements */
}
- while (fgets(line, STRLEN, fp) != NULL)
+ while (fgets(line, STRLEN, fp) != nullptr)
{
/* Remove leading spaces */
ltrim(line);
/* Check for TERM and INT signals from user: */
- if (std::strstr(line, errSIG) != NULL)
+ if (std::strstr(line, errSIG) != nullptr)
{
fclose(fp);
cleandata(perfdata, test_nr);
/* Check whether cycle resetting worked */
if (presteps > 0 && !bFoundResetStr)
{
- if (std::strstr(line, matchstrcr) != NULL)
+ if (std::strstr(line, matchstrcr) != nullptr)
{
sprintf(dumstring, "step %s", "%" GMX_SCNd64);
sscanf(line, dumstring, &resetsteps);
if (gmx_fexist(errfile))
{
fp = fopen(errfile, "r");
- while (fgets(line, STRLEN, fp) != NULL)
+ while (fgets(line, STRLEN, fp) != nullptr)
{
if (str_starts(line, "Fatal error:") )
{
- if (fgets(line, STRLEN, fp) != NULL)
+ if (fgets(line, STRLEN, fp) != nullptr)
{
fprintf(stderr, "\nWARNING: An error occurred during this benchmark:\n"
"%s\n", line);
/* Get the commands we need to set up the runs from environment variables */
if (!bThreads)
{
- if ( (cp = getenv("MPIRUN")) != NULL)
+ if ( (cp = getenv("MPIRUN")) != nullptr)
{
*cmd_mpirun = gmx_strdup(cp);
}
*cmd_mpirun = gmx_strdup(empty_mpirun);
}
- if (*cmd_mdrun == NULL)
+ if (*cmd_mdrun == nullptr)
{
/* The use of MDRUN is deprecated, but made available in 5.1
for backward compatibility. It may be removed in a future
version. */
- if ( (cp = getenv("MDRUN" )) != NULL)
+ if ( (cp = getenv("MDRUN" )) != nullptr)
{
*cmd_mdrun = gmx_strdup(cp);
}
const char *cmd_mdrun,
gmx_bool bNeedGpuSupport)
{
- char *command = NULL;
+ char *command = nullptr;
char *cp;
char line[STRLEN];
FILE *fp;
while (!feof(fp) )
{
cp = fgets(line, STRLEN, fp);
- if (cp != NULL)
+ if (cp != nullptr)
{
if (str_starts(line, match_mdrun) )
{
const char *fn_best_tpr, /* tpr file with the best performance */
const char *fn_sim_tpr) /* name of tpr file to be launched */
{
- t_inputrec *ir;
- t_state state;
- gmx_mtop_t mtop;
- char buf[200];
+ t_inputrec *ir;
+ t_state state;
+ gmx_mtop_t mtop;
+ char buf[200];
- snew(ir, 1);
+ gmx::MDModules mdModules;
+ ir = mdModules.inputrec();
read_tpx_state(fn_best_tpr, ir, &state, &mtop);
/* Reset nsteps and init_step to the value of the input .tpr file */
fprintf(stdout, buf, ir->nsteps);
fflush(stdout);
write_tpx_state(fn_sim_tpr, ir, &state, &mtop);
-
- sfree(ir);
}
static gmx_bool can_scale_rvdw(int vdwtype)
}
fprintf(stdout, ".\n");
-
- snew(ir, 1);
+ gmx::MDModules mdModules;
+ ir = mdModules.inputrec();
read_tpx_state(fn_sim_tpr, ir, &state, &mtop);
/* Check if some kind of PME was chosen */
/* Scale the Fourier grid spacing */
ir->nkx = ir->nky = ir->nkz = 0;
- calc_grid(NULL, state.box, fourierspacing*fac, &ir->nkx, &ir->nky, &ir->nkz);
+ calc_grid(nullptr, state.box, fourierspacing*fac, &ir->nkx, &ir->nky, &ir->nkz);
/* Adjust other radii since various conditions need to be fulfilled */
if (eelPME == ir->coulombtype)
}
fflush(stdout);
fflush(fp);
- sfree(ir);
}
{
char numstring[STRLEN];
char newfilename[STRLEN];
- const char *fn = NULL;
+ const char *fn = nullptr;
int i;
const char *opt;
* constructing mdrun command lines */
{
int i, nr, k, ret, count = 0, totaltests;
- int *nPMEnodes = NULL;
- t_perf *pd = NULL;
+ int *nPMEnodes = nullptr;
+ t_perf *pd = nullptr;
int cmdline_length;
char *command, *cmd_stub;
char buf[STRLEN];
/* Loop over various numbers of PME nodes: */
for (i = 0; i < *pmeentries; i++)
{
- char *cmd_gpu_ids = NULL;
+ char *cmd_gpu_ids = nullptr;
pd = &perfdata[k][i];
gmx_bool bFree; /* Is a free energy simulation requested? */
gmx_bool bNM; /* Is a normal mode analysis requested? */
gmx_bool bSwap; /* Is water/ion position swapping requested? */
- t_inputrec ir;
+ t_inputrec *ir;
t_state state;
gmx_mtop_t mtop;
/* Check tpr file for options that trigger extra output files */
- read_tpx_state(opt2fn("-s", nfile, fnm), &ir, &state, &mtop);
- bFree = (efepNO != ir.efep );
- bNM = (eiNM == ir.eI );
- bSwap = (eswapNO != ir.eSwapCoords);
- bTpi = EI_TPI(ir.eI);
+ gmx::MDModules mdModules;
+ ir = mdModules.inputrec();
+ read_tpx_state(opt2fn("-s", nfile, fnm), ir, &state, &mtop);
+ bFree = (efepNO != ir->efep );
+ bNM = (eiNM == ir->eI );
+ bSwap = (eswapNO != ir->eSwapCoords);
+ bTpi = EI_TPI(ir->eI);
/* Set these output files on the tuning command-line */
- if (ir.bPull)
+ if (ir->bPull)
{
setopt("-pf", nfile, fnm);
setopt("-px", nfile, fnm);
setopt("-swap", nfile, fnm);
}
- *rcoulomb = ir.rcoulomb;
+ *rcoulomb = ir->rcoulomb;
/* Return the estimate for the number of PME nodes */
- return pme_load_estimate(&mtop, &ir, state.box);
+ float npme = pme_load_estimate(&mtop, ir, state.box);
+ return npme;
}
int presteps = 1500; /* Do a full cycle reset after presteps steps */
gmx_bool bOverwrite = FALSE, bKeepTPR;
gmx_bool bLaunch = FALSE;
- char *ExtraArgs = NULL;
- char **tpr_names = NULL;
- const char *simulation_tpr = NULL;
- char *deffnm = NULL;
+ char *ExtraArgs = nullptr;
+ char **tpr_names = nullptr;
+ const char *simulation_tpr = nullptr;
+ char *deffnm = nullptr;
int best_npme, best_tpr;
int sim_part = 1; /* For benchmarks with checkpoint files */
char bbuf[STRLEN];
/* Default program names if nothing else is found */
- char *cmd_mpirun = NULL, *cmd_mdrun = NULL;
+ char *cmd_mpirun = nullptr, *cmd_mdrun = nullptr;
char *cmd_args_bench, *cmd_args_launch;
- char *cmd_np = NULL;
+ char *cmd_np = nullptr;
/* IDs of GPUs that are eligible for computation */
- char *eligible_gpu_ids = NULL;
- t_eligible_gpu_ids *gpu_ids = NULL;
+ char *eligible_gpu_ids = nullptr;
+ t_eligible_gpu_ids *gpu_ids = nullptr;
- t_perf **perfdata = NULL;
+ t_perf **perfdata = nullptr;
t_inputinfo *info;
int i;
FILE *fp;
{ efLOG, "-err", "bencherr", ffWRITE },
{ efTPR, "-so", "tuned", ffWRITE },
/* mdrun: */
- { efTPR, NULL, NULL, ffREAD },
- { efTRN, "-o", NULL, ffWRITE },
- { efCOMPRESSED, "-x", NULL, ffOPTWR },
- { efCPT, "-cpi", NULL, ffOPTRD },
- { efCPT, "-cpo", NULL, ffOPTWR },
+ { efTPR, nullptr, nullptr, ffREAD },
+ { efTRN, "-o", nullptr, ffWRITE },
+ { efCOMPRESSED, "-x", nullptr, ffOPTWR },
+ { efCPT, "-cpi", nullptr, ffOPTRD },
+ { efCPT, "-cpo", nullptr, ffOPTWR },
{ efSTO, "-c", "confout", ffWRITE },
{ efEDR, "-e", "ener", ffWRITE },
{ efLOG, "-g", "md", ffWRITE },
int nthreads = 1;
const char *procstring[] =
- { NULL, "np", "n", "none", NULL };
+ { nullptr, "np", "n", "none", nullptr };
const char *npmevalues_opt[] =
- { NULL, "auto", "all", "subset", NULL };
+ { nullptr, "auto", "all", "subset", nullptr };
gmx_bool bAppendFiles = TRUE;
gmx_bool bKeepAndNumCPT = FALSE;
gmx_bool bBenchmark = TRUE;
gmx_bool bCheck = TRUE;
- gmx_output_env_t *oenv = NULL;
+ gmx_output_env_t *oenv = nullptr;
t_pargs pa[] = {
/***********************/
if (!parse_common_args(&argc, argv, PCA_NOEXIT_ON_ARGS,
NFILE, fnm, asize(pa), pa, asize(desc), desc,
- 0, NULL, &oenv))
+ 0, nullptr, &oenv))
{
return 0;
}
// procstring[0] is used inside two different conditionals further down
- GMX_RELEASE_ASSERT(procstring[0] != NULL, "Options inconsistency; procstring[0] is NULL");
+ GMX_RELEASE_ASSERT(procstring[0] != nullptr, "Options inconsistency; procstring[0] is NULL");
/* Store the remaining unparsed command line entries in a string which
* is then attached to the mdrun command line */
get_program_paths(bThreads, &cmd_mpirun, &cmd_mdrun);
if (bBenchmark && repeats > 0)
{
- check_mdrun_works(bThreads, cmd_mpirun, cmd_np, cmd_mdrun, NULL != eligible_gpu_ids);
+ check_mdrun_works(bThreads, cmd_mpirun, cmd_np, cmd_mdrun, nullptr != eligible_gpu_ids);
}
/* Print some header info to file */
snew(perfdata, ntprs);
if (bBenchmark)
{
- GMX_RELEASE_ASSERT(npmevalues_opt[0] != NULL, "Options inconsistency; npmevalues_opt[0] is NULL");
+ GMX_RELEASE_ASSERT(npmevalues_opt[0] != nullptr, "Options inconsistency; npmevalues_opt[0] is NULL");
do_the_tests(fp, tpr_names, maxPMEnodes, minPMEnodes, npme_fixed, npmevalues_opt[0], perfdata, &pmeentries,
repeats, nnodes, ntprs, bThreads, cmd_mpirun, cmd_np, cmd_mdrun,
cmd_args_bench, fnm, NFILE, presteps, cpt_steps, bCheck, gpu_ids);