From df7c56d88160add5ce3492c1f5b9e757b34ebace Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 28 Jun 2019 05:28:54 -0400 Subject: [PATCH 1/4] use suffix compatible pair style matching when looking for ReaxFF pair style --- src/QEQ/fix_qeq_shielded.cpp | 2 +- src/USER-REAXC/fix_qeq_reax.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index a74eee7d29..6367feacc5 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -80,7 +80,7 @@ void FixQEqShielded::init() void FixQEqShielded::extract_reax() { - Pair *pair = force->pair_match("reax/c",1); + Pair *pair = force->pair_match("^reax/c",0); if (pair == NULL) error->all(FLERR,"No pair reax/c for fix qeq/shielded"); int tmp; chi = (double *) pair->extract("chi",tmp); diff --git a/src/USER-REAXC/fix_qeq_reax.cpp b/src/USER-REAXC/fix_qeq_reax.cpp index b37c8fff83..faa0632608 100644 --- a/src/USER-REAXC/fix_qeq_reax.cpp +++ b/src/USER-REAXC/fix_qeq_reax.cpp @@ -124,7 +124,7 @@ FixQEqReax::FixQEqReax(LAMMPS *lmp, int narg, char **arg) : // register with Atom class reaxc = NULL; - reaxc = (PairReaxC *) force->pair_match("reax/c",0); + reaxc = (PairReaxC *) force->pair_match("^reax/c",0); s_hist = t_hist = NULL; grow_arrays(atom->nmax); From 5e3a705911e057e2188efca2512394e96a46cc04 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 28 Jun 2019 14:28:45 -0400 Subject: [PATCH 2/4] fix bug caused by a parameter shadowing a class variable --- src/thermo.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/thermo.cpp b/src/thermo.cpp index f4ab7b0779..bba867d195 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -406,8 +406,9 @@ void Thermo::compute(int flag) call function to compute property ------------------------------------------------------------------------- */ -void Thermo::call_vfunc(int ifield) +void Thermo::call_vfunc(int ifield_in) { + ifield = ifield_in; (this->*vfunc[ifield])(); } From 7547e1dae621f02e14e8e77bffc6ad3c6300e59e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 1 Jul 2019 17:10:21 -0400 Subject: [PATCH 3/4] make certain that the vector storage and the size_vector variable are consistent in computes --- src/ASPHERE/compute_temp_asphere.cpp | 2 +- src/BODY/compute_temp_body.cpp | 2 +- src/CORESHELL/compute_temp_cs.cpp | 2 +- src/SPIN/compute_spin.cpp | 2 +- src/USER-BOCS/compute_pressure_bocs.cpp | 6 +++--- src/USER-DRUDE/compute_temp_drude.cpp | 2 +- src/USER-EFF/compute_temp_deform_eff.cpp | 2 +- src/USER-EFF/compute_temp_region_eff.cpp | 2 +- src/USER-FEP/compute_fep.cpp | 2 +- src/USER-MISC/compute_temp_rotate.cpp | 2 +- src/compute_com.cpp | 2 +- src/compute_group_group.cpp | 2 +- src/compute_gyration.cpp | 2 +- src/compute_heat_flux.cpp | 2 +- src/compute_msd.cpp | 2 +- src/compute_pressure.cpp | 2 +- src/compute_temp.cpp | 2 +- src/compute_temp_chunk.cpp | 2 +- src/compute_temp_com.cpp | 2 +- src/compute_temp_deform.cpp | 2 +- src/compute_temp_partial.cpp | 2 +- src/compute_temp_ramp.cpp | 2 +- src/compute_temp_region.cpp | 2 +- src/compute_temp_sphere.cpp | 2 +- src/compute_vacf.cpp | 2 +- 25 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index 011d8cae80..651c228e41 100644 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -78,7 +78,7 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) : if (mode == ROTATE) extra_dof = 0; - vector = new double[6]; + vector = new double[size_vector]; } diff --git a/src/BODY/compute_temp_body.cpp b/src/BODY/compute_temp_body.cpp index 5446fb6d64..b560bdd11d 100644 --- a/src/BODY/compute_temp_body.cpp +++ b/src/BODY/compute_temp_body.cpp @@ -71,7 +71,7 @@ ComputeTempBody::ComputeTempBody(LAMMPS *lmp, int narg, char **arg) : } else error->all(FLERR,"Illegal compute temp/body command"); } - vector = new double[6]; + vector = new double[size_vector]; } diff --git a/src/CORESHELL/compute_temp_cs.cpp b/src/CORESHELL/compute_temp_cs.cpp index 03ebfa154d..dac0d60fce 100644 --- a/src/CORESHELL/compute_temp_cs.cpp +++ b/src/CORESHELL/compute_temp_cs.cpp @@ -101,7 +101,7 @@ ComputeTempCS::ComputeTempCS(LAMMPS *lmp, int narg, char **arg) : // allocate memory - vector = new double[6]; + vector = new double[size_vector]; maxatom = 0; vint = NULL; diff --git a/src/SPIN/compute_spin.cpp b/src/SPIN/compute_spin.cpp index 0a881e1de6..501b708c88 100644 --- a/src/SPIN/compute_spin.cpp +++ b/src/SPIN/compute_spin.cpp @@ -149,6 +149,6 @@ void ComputeSpin::compute_vector() void ComputeSpin::allocate() { - memory->create(vector,6,"compute/spin:vector"); + memory->create(vector,size_vector,"compute/spin:vector"); } diff --git a/src/USER-BOCS/compute_pressure_bocs.cpp b/src/USER-BOCS/compute_pressure_bocs.cpp index fc24efab4c..c43910ec6d 100644 --- a/src/USER-BOCS/compute_pressure_bocs.cpp +++ b/src/USER-BOCS/compute_pressure_bocs.cpp @@ -106,9 +106,9 @@ ComputePressureBocs::ComputePressureBocs(LAMMPS *lmp, int narg, char **arg) : if (keflag && id_temp == NULL) error->all(FLERR,"Compute pressure/bocs requires temperature ID " - "to include kinetic energy"); + "to include kinetic energy"); - vector = new double[6]; + vector = new double[size_vector]; nvirial = 0; vptr = NULL; } @@ -365,7 +365,7 @@ void ComputePressureBocs::compute_vector() if (force->kspace && kspace_virial && force->kspace->scalar_pressure_flag) error->all(FLERR,"Must use 'kspace_modify pressure/scalar no' for " - "tensor components with kspace_style msm"); + "tensor components with kspace_style msm"); // invoke temperature if it hasn't been already diff --git a/src/USER-DRUDE/compute_temp_drude.cpp b/src/USER-DRUDE/compute_temp_drude.cpp index 27b525c07d..4830e950d0 100644 --- a/src/USER-DRUDE/compute_temp_drude.cpp +++ b/src/USER-DRUDE/compute_temp_drude.cpp @@ -46,7 +46,7 @@ ComputeTempDrude::ComputeTempDrude(LAMMPS *lmp, int narg, char **arg) : extlist[2] = extlist[3] = extlist[4] = extlist[5] = 1; tempflag = 0; // because does not compute a single temperature (scalar and vector) - vector = new double[6]; + vector = new double[size_vector]; fix_drude = NULL; id_temp = NULL; temperature = NULL; diff --git a/src/USER-EFF/compute_temp_deform_eff.cpp b/src/USER-EFF/compute_temp_deform_eff.cpp index 23abb4f99d..621eff210f 100644 --- a/src/USER-EFF/compute_temp_deform_eff.cpp +++ b/src/USER-EFF/compute_temp_deform_eff.cpp @@ -54,7 +54,7 @@ ComputeTempDeformEff::ComputeTempDeformEff(LAMMPS *lmp, int narg, char **arg) : maxbias = 0; vbiasall = NULL; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-EFF/compute_temp_region_eff.cpp b/src/USER-EFF/compute_temp_region_eff.cpp index 659bdfca5e..8cab690367 100644 --- a/src/USER-EFF/compute_temp_region_eff.cpp +++ b/src/USER-EFF/compute_temp_region_eff.cpp @@ -58,7 +58,7 @@ ComputeTempRegionEff::ComputeTempRegionEff(LAMMPS *lmp, int narg, char **arg) : maxbias = 0; vbiasall = NULL; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/USER-FEP/compute_fep.cpp b/src/USER-FEP/compute_fep.cpp index 0e5f164f88..dc0b71e71b 100644 --- a/src/USER-FEP/compute_fep.cpp +++ b/src/USER-FEP/compute_fep.cpp @@ -53,7 +53,7 @@ ComputeFEP::ComputeFEP(LAMMPS *lmp, int narg, char **arg) : size_vector = 3; extvector = 0; - vector = new double[3]; + vector = new double[size_vector]; fepinitflag = 0; // avoid init to run entirely when called by write_data diff --git a/src/USER-MISC/compute_temp_rotate.cpp b/src/USER-MISC/compute_temp_rotate.cpp index 66f1b8f5f7..36093bd1e1 100644 --- a/src/USER-MISC/compute_temp_rotate.cpp +++ b/src/USER-MISC/compute_temp_rotate.cpp @@ -46,7 +46,7 @@ ComputeTempRotate::ComputeTempRotate(LAMMPS *lmp, int narg, char **arg) : maxbias = 0; vbiasall = NULL; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_com.cpp b/src/compute_com.cpp index 27606cbc6f..2496aa9446 100644 --- a/src/compute_com.cpp +++ b/src/compute_com.cpp @@ -29,7 +29,7 @@ ComputeCOM::ComputeCOM(LAMMPS *lmp, int narg, char **arg) : size_vector = 3; extvector = 0; - vector = new double[3]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_group_group.cpp b/src/compute_group_group.cpp index e55f679b2e..17e8737350 100644 --- a/src/compute_group_group.cpp +++ b/src/compute_group_group.cpp @@ -105,7 +105,7 @@ ComputeGroupGroup::ComputeGroupGroup(LAMMPS *lmp, int narg, char **arg) : } else error->all(FLERR,"Illegal compute group/group command"); } - vector = new double[3]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_gyration.cpp b/src/compute_gyration.cpp index f8d19853e0..0e29c0d667 100644 --- a/src/compute_gyration.cpp +++ b/src/compute_gyration.cpp @@ -33,7 +33,7 @@ ComputeGyration::ComputeGyration(LAMMPS *lmp, int narg, char **arg) : extscalar = 0; extvector = 0; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_heat_flux.cpp b/src/compute_heat_flux.cpp index e402da7842..0b37865034 100644 --- a/src/compute_heat_flux.cpp +++ b/src/compute_heat_flux.cpp @@ -70,7 +70,7 @@ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, "Compute heat/flux compute ID does not compute stress/atom"); - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_msd.cpp b/src/compute_msd.cpp index fc47b2609a..608d3e6b33 100644 --- a/src/compute_msd.cpp +++ b/src/compute_msd.cpp @@ -115,7 +115,7 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) : // displacement vector - vector = new double[4]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_pressure.cpp b/src/compute_pressure.cpp index dde02a5aed..978cad0cad 100644 --- a/src/compute_pressure.cpp +++ b/src/compute_pressure.cpp @@ -101,7 +101,7 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Compute pressure requires temperature ID " "to include kinetic energy"); - vector = new double[6]; + vector = new double[size_vector]; nvirial = 0; vptr = NULL; } diff --git a/src/compute_temp.cpp b/src/compute_temp.cpp index f7d3a890ec..70a7734593 100644 --- a/src/compute_temp.cpp +++ b/src/compute_temp.cpp @@ -37,7 +37,7 @@ ComputeTemp::ComputeTemp(LAMMPS *lmp, int narg, char **arg) : extvector = 1; tempflag = 1; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_temp_chunk.cpp b/src/compute_temp_chunk.cpp index 920515e05c..396492e18d 100644 --- a/src/compute_temp_chunk.cpp +++ b/src/compute_temp_chunk.cpp @@ -125,7 +125,7 @@ ComputeTempChunk::ComputeTempChunk(LAMMPS *lmp, int narg, char **arg) : // vector data - vector = new double[6]; + vector = new double[size_vector]; // chunk-based data diff --git a/src/compute_temp_com.cpp b/src/compute_temp_com.cpp index f2ad40ea43..c46a17497f 100644 --- a/src/compute_temp_com.cpp +++ b/src/compute_temp_com.cpp @@ -39,7 +39,7 @@ ComputeTempCOM::ComputeTempCOM(LAMMPS *lmp, int narg, char **arg) : tempflag = 1; tempbias = 1; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_temp_deform.cpp b/src/compute_temp_deform.cpp index 39780b5cf6..280c17dd08 100644 --- a/src/compute_temp_deform.cpp +++ b/src/compute_temp_deform.cpp @@ -48,7 +48,7 @@ ComputeTempDeform::ComputeTempDeform(LAMMPS *lmp, int narg, char **arg) : maxbias = 0; vbiasall = NULL; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_temp_partial.cpp b/src/compute_temp_partial.cpp index 4425aebdda..ee72ba3e74 100644 --- a/src/compute_temp_partial.cpp +++ b/src/compute_temp_partial.cpp @@ -49,7 +49,7 @@ ComputeTempPartial::ComputeTempPartial(LAMMPS *lmp, int narg, char **arg) : maxbias = 0; vbiasall = NULL; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_temp_ramp.cpp b/src/compute_temp_ramp.cpp index ba572645f3..36e7f51ce4 100644 --- a/src/compute_temp_ramp.cpp +++ b/src/compute_temp_ramp.cpp @@ -101,7 +101,7 @@ ComputeTempRamp::ComputeTempRamp(LAMMPS *lmp, int narg, char **arg) : maxbias = 0; vbiasall = NULL; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_temp_region.cpp b/src/compute_temp_region.cpp index 4aa4dac0a1..0c54aeb63c 100644 --- a/src/compute_temp_region.cpp +++ b/src/compute_temp_region.cpp @@ -49,7 +49,7 @@ ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) : maxbias = 0; vbiasall = NULL; - vector = new double[6]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index 651da6dee5..23e74634b5 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -72,7 +72,7 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : if (mode == ROTATE) extra_dof = 0; - vector = new double[6]; + vector = new double[size_vector]; // error checks diff --git a/src/compute_vacf.cpp b/src/compute_vacf.cpp index 3ef3acf0bf..d46b8b5fa0 100644 --- a/src/compute_vacf.cpp +++ b/src/compute_vacf.cpp @@ -75,7 +75,7 @@ ComputeVACF::ComputeVACF(LAMMPS *lmp, int narg, char **arg) : // displacement vector - vector = new double[4]; + vector = new double[size_vector]; } /* ---------------------------------------------------------------------- */ From 6fc5810bb4d4b0d0042204926bf04d29259db063 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 2 Jul 2019 01:30:11 -0400 Subject: [PATCH 4/4] with the refactored include handling we can allow include in if/then/else --- doc/src/if.txt | 3 +-- src/input.cpp | 28 ++++++++-------------------- src/input.h | 1 - 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/doc/src/if.txt b/doc/src/if.txt index 20caf1a1ef..ceec8f55db 100644 --- a/doc/src/if.txt +++ b/doc/src/if.txt @@ -57,8 +57,7 @@ Boolean expression is FALSE, then no commands are executed. The syntax for Boolean expressions is described below. Each command (t1, f1, e1, etc) can be any valid LAMMPS input script -command, except an "include"_include.html command, which is not -allowed. If the command is more than one word, it must enclosed in +command. If the command is more than one word, it must enclosed in quotes, so it will be treated as a single argument, as in the examples above. diff --git a/src/input.cpp b/src/input.cpp index 9e0ad78d9e..390ca37bf3 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -82,7 +82,6 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp) label_active = 0; labelstr = NULL; jump_skip = 0; - ifthenelse_flag = 0; if (me == 0) { nfile = maxfile = 1; @@ -962,11 +961,10 @@ void Input::ifthenelse() ncommands++; } - ifthenelse_flag = 1; - for (int i = 0; i < ncommands; i++) one(commands[i]); - ifthenelse_flag = 0; - - for (int i = 0; i < ncommands; i++) delete [] commands[i]; + for (int i = 0; i < ncommands; i++) { + one(commands[i]); + delete [] commands[i]; + } delete [] commands; return; @@ -1018,13 +1016,10 @@ void Input::ifthenelse() // execute the list of commands - ifthenelse_flag = 1; - for (int i = 0; i < ncommands; i++) one(commands[i]); - ifthenelse_flag = 0; - - // clean up - - for (int i = 0; i < ncommands; i++) delete [] commands[i]; + for (int i = 0; i < ncommands; i++) { + one(commands[i]); + delete [] commands[i]; + } delete [] commands; return; @@ -1037,13 +1032,6 @@ void Input::include() { if (narg != 1) error->all(FLERR,"Illegal include command"); - // do not allow include inside an if command - // NOTE: this check will fail if a 2nd if command was inside the if command - // and came before the include - - if (ifthenelse_flag) - error->all(FLERR,"Cannot use include command within an if command"); - if (me == 0) { if (nfile == maxfile) { maxfile++; diff --git a/src/input.h b/src/input.h index 33e83bfb06..7b6e55c2ba 100644 --- a/src/input.h +++ b/src/input.h @@ -54,7 +54,6 @@ class Input : protected Pointers { int label_active; // 0 = no label, 1 = looking for label char *labelstr; // label string being looked for int jump_skip; // 1 if skipping next jump, 0 otherwise - int ifthenelse_flag; // 1 if executing commands inside an if-then-else FILE **infiles; // list of open input files