From cf3887c5e074683b093ca1698d9b2dd90380cc12 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 22 Feb 2018 07:53:58 -0500 Subject: [PATCH] default arguments on polymorph/pure methods can lead to unexpected overloading in derived classes argument for Integrate::setup() made explicit --- src/KOKKOS/verlet_kokkos.h | 2 +- src/REPLICA/prd.cpp | 6 +++--- src/REPLICA/tad.cpp | 6 +++--- src/REPLICA/temper.cpp | 2 +- src/REPLICA/verlet_split.cpp | 4 ++-- src/REPLICA/verlet_split.h | 2 +- src/USER-MISC/temper_grem.cpp | 2 +- src/USER-MISC/temper_npt.cpp | 2 +- src/USER-OMP/respa_omp.cpp | 30 ++++++++++++++++-------------- src/USER-OMP/respa_omp.h | 2 +- src/integrate.h | 2 +- src/respa.h | 2 +- src/run.cpp | 4 ++-- src/verlet.h | 2 +- 14 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/KOKKOS/verlet_kokkos.h b/src/KOKKOS/verlet_kokkos.h index 7b140b6f81..1e36b1cf6e 100644 --- a/src/KOKKOS/verlet_kokkos.h +++ b/src/KOKKOS/verlet_kokkos.h @@ -31,7 +31,7 @@ class VerletKokkos : public Verlet { public: VerletKokkos(class LAMMPS *, int, char **); ~VerletKokkos() {} - void setup(int flag=1); + void setup(int); void setup_minimal(int); void run(int); diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index 14eeac8d66..f7d369cee6 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -293,7 +293,7 @@ void PRD::command(int narg, char **arg) update->whichflag = 1; lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); if (temp_flag == 0) { if (universe->iworld == 0) temp_dephase = temperature->compute_scalar(); @@ -390,7 +390,7 @@ void PRD::command(int narg, char **arg) update->whichflag = 1; lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); timer->barrier_start(); @@ -545,7 +545,7 @@ void PRD::dynamics(int nsteps, double &time_category) update->nsteps = nsteps; lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); // this may be needed if don't do full init //modify->addstep_compute_all(update->ntimestep); bigint ncalls = neighbor->ncalls; diff --git a/src/REPLICA/tad.cpp b/src/REPLICA/tad.cpp index 347cd3ba67..958a57e4e8 100644 --- a/src/REPLICA/tad.cpp +++ b/src/REPLICA/tad.cpp @@ -264,7 +264,7 @@ void TAD::command(int narg, char **arg) update->whichflag = 1; lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); // main loop: look for events until out of time // (1) dynamics, store state, quench, check event, restore state @@ -342,7 +342,7 @@ void TAD::command(int narg, char **arg) update->whichflag = 1; lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); // write restart file of hot coords @@ -448,7 +448,7 @@ void TAD::dynamics() update->nsteps = t_event; lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); // this may be needed if don't do full init //modify->addstep_compute_all(update->ntimestep); int ncalls = neighbor->ncalls; diff --git a/src/REPLICA/temper.cpp b/src/REPLICA/temper.cpp index 667f2893c6..d7e8c981bb 100644 --- a/src/REPLICA/temper.cpp +++ b/src/REPLICA/temper.cpp @@ -212,7 +212,7 @@ void Temper::command(int narg, char **arg) if (me_universe == 0 && universe->uscreen) fprintf(universe->uscreen,"Setting up tempering ...\n"); - update->integrate->setup(); + update->integrate->setup(1); if (me_universe == 0) { if (universe->uscreen) { diff --git a/src/REPLICA/verlet_split.cpp b/src/REPLICA/verlet_split.cpp index 4572170f34..3d4e25b7b4 100644 --- a/src/REPLICA/verlet_split.cpp +++ b/src/REPLICA/verlet_split.cpp @@ -239,13 +239,13 @@ void VerletSplit::init() servant partition only sets up KSpace calculation ------------------------------------------------------------------------- */ -void VerletSplit::setup() +void VerletSplit::setup(int flag) { if (comm->me == 0 && screen) fprintf(screen,"Setting up Verlet/split run ...\n"); if (!master) force->kspace->setup(); - else Verlet::setup(); + else Verlet::setup(flag); } /* ---------------------------------------------------------------------- diff --git a/src/REPLICA/verlet_split.h b/src/REPLICA/verlet_split.h index 2d25131df3..b3ee87e580 100644 --- a/src/REPLICA/verlet_split.h +++ b/src/REPLICA/verlet_split.h @@ -29,7 +29,7 @@ class VerletSplit : public Verlet { VerletSplit(class LAMMPS *, int, char **); ~VerletSplit(); void init(); - void setup(); + void setup(int); void setup_minimal(int); void run(int); bigint memory_usage(); diff --git a/src/USER-MISC/temper_grem.cpp b/src/USER-MISC/temper_grem.cpp index 6ce7da8d6a..9e5a4c5c3b 100644 --- a/src/USER-MISC/temper_grem.cpp +++ b/src/USER-MISC/temper_grem.cpp @@ -214,7 +214,7 @@ void TemperGrem::command(int narg, char **arg) if (me_universe == 0 && universe->uscreen) fprintf(universe->uscreen,"Setting up tempering ...\n"); - update->integrate->setup(); + update->integrate->setup(1); if (me_universe == 0) { if (universe->uscreen) { diff --git a/src/USER-MISC/temper_npt.cpp b/src/USER-MISC/temper_npt.cpp index e405377d79..60f9313fdd 100644 --- a/src/USER-MISC/temper_npt.cpp +++ b/src/USER-MISC/temper_npt.cpp @@ -190,7 +190,7 @@ void TemperNPT::command(int narg, char **arg) if (me_universe == 0 && universe->uscreen) fprintf(universe->uscreen,"Setting up tempering ...\n"); - update->integrate->setup(); + update->integrate->setup(1); if (me_universe == 0) { if (universe->uscreen) { diff --git a/src/USER-OMP/respa_omp.cpp b/src/USER-OMP/respa_omp.cpp index aa4aa65a4f..ac1c2d53d4 100644 --- a/src/USER-OMP/respa_omp.cpp +++ b/src/USER-OMP/respa_omp.cpp @@ -67,24 +67,26 @@ void RespaOMP::init() setup before run ------------------------------------------------------------------------- */ -void RespaOMP::setup() +void RespaOMP::setup(int flag) { if (comm->me == 0 && screen) { fprintf(screen,"Setting up r-RESPA/omp run ...\n"); - fprintf(screen," Unit style : %s\n", update->unit_style); - fprintf(screen," Current step : " BIGINT_FORMAT "\n", update->ntimestep); - fprintf(screen," Time steps :"); - for (int ilevel=0; ilevel < nlevels; ++ilevel) - fprintf(screen," %d:%g",ilevel+1, step[ilevel]); - fprintf(screen,"\n r-RESPA fixes :"); - for (int l=0; l < modify->n_post_force_respa; ++l) { - Fix *f = modify->fix[modify->list_post_force_respa[l]]; - if (f->respa_level >= 0) - fprintf(screen," %d:%s[%s]", - MIN(f->respa_level+1,nlevels),f->style,f->id); + if (flag) { + fprintf(screen," Unit style : %s\n", update->unit_style); + fprintf(screen," Current step : " BIGINT_FORMAT "\n", update->ntimestep); + fprintf(screen," Time steps :"); + for (int ilevel=0; ilevel < nlevels; ++ilevel) + fprintf(screen," %d:%g",ilevel+1, step[ilevel]); + fprintf(screen,"\n r-RESPA fixes :"); + for (int l=0; l < modify->n_post_force_respa; ++l) { + Fix *f = modify->fix[modify->list_post_force_respa[l]]; + if (f->respa_level >= 0) + fprintf(screen," %d:%s[%s]", + MIN(f->respa_level+1,nlevels),f->style,f->id); + } + fprintf(screen,"\n"); + timer->print_timeout(screen); } - fprintf(screen,"\n"); - timer->print_timeout(screen); } update->setupflag = 1; diff --git a/src/USER-OMP/respa_omp.h b/src/USER-OMP/respa_omp.h index 89ddbe78af..dc01e3dc5b 100644 --- a/src/USER-OMP/respa_omp.h +++ b/src/USER-OMP/respa_omp.h @@ -30,7 +30,7 @@ class RespaOMP : public Respa, public ThrOMP { RespaOMP(class LAMMPS *, int, char **); virtual ~RespaOMP() {} virtual void init(); - virtual void setup(); + virtual void setup(int); virtual void setup_minimal(int); protected: diff --git a/src/integrate.h b/src/integrate.h index 4ca3a788fa..9a50fad1f7 100644 --- a/src/integrate.h +++ b/src/integrate.h @@ -23,7 +23,7 @@ class Integrate : protected Pointers { Integrate(class LAMMPS *, int, char **); virtual ~Integrate(); virtual void init(); - virtual void setup(int flag=1) = 0; + virtual void setup(int flag) = 0; virtual void setup_minimal(int) = 0; virtual void run(int) = 0; virtual void cleanup() {} diff --git a/src/respa.h b/src/respa.h index 0b08b12bd7..f910f0c666 100644 --- a/src/respa.h +++ b/src/respa.h @@ -48,7 +48,7 @@ class Respa : public Integrate { Respa(class LAMMPS *, int, char **); virtual ~Respa(); virtual void init(); - virtual void setup(int flag=1); + virtual void setup(int); virtual void setup_minimal(int); virtual void run(int); virtual void cleanup(); diff --git a/src/run.cpp b/src/run.cpp index 3317545342..37af977e34 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -175,7 +175,7 @@ void Run::command(int narg, char **arg) if (preflag || update->first_update == 0) { lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); } else output->setup(0); timer->init(); @@ -216,7 +216,7 @@ void Run::command(int narg, char **arg) if (preflag || iter == 0) { lmp->init(); - update->integrate->setup(); + update->integrate->setup(1); } else output->setup(0); timer->init(); diff --git a/src/verlet.h b/src/verlet.h index 29bd3f16b3..e71932a861 100644 --- a/src/verlet.h +++ b/src/verlet.h @@ -29,7 +29,7 @@ class Verlet : public Integrate { Verlet(class LAMMPS *, int, char **); virtual ~Verlet() {} virtual void init(); - virtual void setup(int flag=1); + virtual void setup(int flag); virtual void setup_minimal(int); virtual void run(int); void cleanup();