From f9a9e27f5a9a06ede78c0a9a3173a522396668c4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 26 Oct 2016 16:01:40 -0400 Subject: [PATCH] add error location propagation to atom->set_mass() and atom->check_mass() --- src/GPU/pair_eam_alloy_gpu.cpp | 2 +- src/GPU/pair_eam_fs_gpu.cpp | 2 +- src/KOKKOS/pair_eam_alloy_kokkos.cpp | 2 +- src/KOKKOS/pair_eam_fs_kokkos.cpp | 2 +- src/MANYBODY/pair_adp.cpp | 2 +- src/MANYBODY/pair_eam.cpp | 2 +- src/MANYBODY/pair_eam_alloy.cpp | 2 +- src/MANYBODY/pair_eam_fs.cpp | 2 +- src/MANYBODY/pair_eim.cpp | 2 +- src/MEAM/pair_meam.cpp | 2 +- src/REPLICA/prd.cpp | 2 +- src/RIGID/fix_shake.cpp | 2 +- src/USER-MGPT/pair_mgpt.cpp | 2 +- src/USER-MISC/fix_addtorque.cpp | 2 +- src/USER-OMP/pair_eam_alloy_omp.cpp | 2 +- src/USER-OMP/pair_eam_fs_omp.cpp | 2 +- src/atom.cpp | 34 ++++++++++++++-------------- src/atom.h | 8 +++---- src/input.cpp | 2 +- src/molecule.cpp | 6 ++--- src/read_data.cpp | 2 +- src/variable.cpp | 14 ++++++------ src/velocity.cpp | 2 +- 23 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index 4ba784da28..ab0f499a98 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -336,7 +336,7 @@ void PairEAMAlloyGPU::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,setfl->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); count++; } } diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index c64a7d7e91..a2b339db9a 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -336,7 +336,7 @@ void PairEAMFSGPU::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,fs->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]); count++; } } diff --git a/src/KOKKOS/pair_eam_alloy_kokkos.cpp b/src/KOKKOS/pair_eam_alloy_kokkos.cpp index 88b16d1d19..151d89d2b0 100644 --- a/src/KOKKOS/pair_eam_alloy_kokkos.cpp +++ b/src/KOKKOS/pair_eam_alloy_kokkos.cpp @@ -936,7 +936,7 @@ void PairEAMAlloyKokkos::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,setfl->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); count++; } } diff --git a/src/KOKKOS/pair_eam_fs_kokkos.cpp b/src/KOKKOS/pair_eam_fs_kokkos.cpp index 83b65e8fdc..b503d1e83a 100644 --- a/src/KOKKOS/pair_eam_fs_kokkos.cpp +++ b/src/KOKKOS/pair_eam_fs_kokkos.cpp @@ -941,7 +941,7 @@ void PairEAMFSKokkos::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,fs->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]); count++; } } diff --git a/src/MANYBODY/pair_adp.cpp b/src/MANYBODY/pair_adp.cpp index ce1c382da9..579675c4a0 100644 --- a/src/MANYBODY/pair_adp.cpp +++ b/src/MANYBODY/pair_adp.cpp @@ -493,7 +493,7 @@ void PairADP::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,setfl->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); count++; } } diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index 880b8f62fc..a610ca1bf1 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -395,7 +395,7 @@ void PairEAM::coeff(int narg, char **arg) if (i == j) { setflag[i][i] = 1; map[i] = ifuncfl; - atom->set_mass(i,funcfl[ifuncfl].mass); + atom->set_mass(FLERR,i,funcfl[ifuncfl].mass); count++; } scale[i][j] = 1.0; diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp index 899526f338..d3ed404a0b 100644 --- a/src/MANYBODY/pair_eam_alloy.cpp +++ b/src/MANYBODY/pair_eam_alloy.cpp @@ -99,7 +99,7 @@ void PairEAMAlloy::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,setfl->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); count++; } scale[i][j] = 1.0; diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index 8b4c86703f..f0f1814dc2 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -99,7 +99,7 @@ void PairEAMFS::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,fs->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]); count++; } scale[i][j] = 1.0; diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index a2807eb78c..e2d8a88aee 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -415,7 +415,7 @@ void PairEIM::coeff(int narg, char **arg) for (j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,setfl->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); count++; } diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index cc2102c2b0..46c3792f7c 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -397,7 +397,7 @@ void PairMEAM::coeff(int narg, char **arg) for (int j = i; j <= n; j++) if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,mass[map[i]]); count++; } diff --git a/src/REPLICA/prd.cpp b/src/REPLICA/prd.cpp index 91f7425fe4..cc1d93a9ae 100644 --- a/src/REPLICA/prd.cpp +++ b/src/REPLICA/prd.cpp @@ -165,7 +165,7 @@ void PRD::command(int narg, char **arg) // create Velocity class for velocity creation in dephasing // pass it temperature compute, loop_setting, dist_setting settings - atom->check_mass(); + atom->check_mass(FLERR); velocity = new Velocity(lmp); velocity->init_external("all"); diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index c71fefc63b..fe9116e446 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -112,7 +112,7 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[next],"t") == 0) mode = 't'; else if (strcmp(arg[next],"m") == 0) { mode = 'm'; - atom->check_mass(); + atom->check_mass(FLERR); // break if keyword that is not b,a,t,m diff --git a/src/USER-MGPT/pair_mgpt.cpp b/src/USER-MGPT/pair_mgpt.cpp index 83524107c8..97c5c16e70 100644 --- a/src/USER-MGPT/pair_mgpt.cpp +++ b/src/USER-MGPT/pair_mgpt.cpp @@ -1983,7 +1983,7 @@ void PairMGPT::coeff(int narg, char **arg) // Set atomic mass. for(int i = 1; i <= atom->ntypes; i++) - atom->set_mass(i, splinepot.mass); + atom->set_mass(FLERR,i, splinepot.mass); // Initialize linear algebra routines. linalg = mgpt_linalg(lmax,single_precision); diff --git a/src/USER-MISC/fix_addtorque.cpp b/src/USER-MISC/fix_addtorque.cpp index ed5d8875f7..d9cc892e7c 100644 --- a/src/USER-MISC/fix_addtorque.cpp +++ b/src/USER-MISC/fix_addtorque.cpp @@ -195,7 +195,7 @@ void FixAddTorque::post_force(int vflag) modify->addstep_compute(update->ntimestep + 1); } - atom->check_mass(); + atom->check_mass(FLERR); double masstotal = group->mass(igroup); group->xcm(igroup,masstotal,xcm); group->inertia(igroup,xcm,inertia); diff --git a/src/USER-OMP/pair_eam_alloy_omp.cpp b/src/USER-OMP/pair_eam_alloy_omp.cpp index 3baebfc874..eea7383eac 100644 --- a/src/USER-OMP/pair_eam_alloy_omp.cpp +++ b/src/USER-OMP/pair_eam_alloy_omp.cpp @@ -98,7 +98,7 @@ void PairEAMAlloyOMP::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,setfl->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); count++; } scale[i][j] = 1.0; diff --git a/src/USER-OMP/pair_eam_fs_omp.cpp b/src/USER-OMP/pair_eam_fs_omp.cpp index 39f43590ca..c646632224 100644 --- a/src/USER-OMP/pair_eam_fs_omp.cpp +++ b/src/USER-OMP/pair_eam_fs_omp.cpp @@ -98,7 +98,7 @@ void PairEAMFSOMP::coeff(int narg, char **arg) for (j = i; j <= n; j++) { if (map[i] >= 0 && map[j] >= 0) { setflag[i][j] = 1; - if (i == j) atom->set_mass(i,fs->mass[map[i]]); + if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]); count++; } scale[i][j] = 1.0; diff --git a/src/atom.cpp b/src/atom.cpp index 8e48611284..762341e002 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -503,7 +503,7 @@ void Atom::init() // check arrays that are atom type in length - check_mass(); + check_mass(FLERR); // setup of firstgroup @@ -1408,23 +1408,23 @@ void Atom::allocate_type_arrays() type_offset may be used when reading multiple data files ------------------------------------------------------------------------- */ -void Atom::set_mass(const char *str, int type_offset) +void Atom::set_mass(const char *file, int line, const char *str, int type_offset) { - if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); + if (mass == NULL) error->all(file,line,"Cannot set mass for this atom style"); int itype; double mass_one; int n = sscanf(str,"%d %lg",&itype,&mass_one); - if (n != 2) error->all(FLERR,"Invalid mass line in data file"); + if (n != 2) error->all(file,line,"Invalid mass line in data file"); itype += type_offset; if (itype < 1 || itype > ntypes) - error->all(FLERR,"Invalid type for mass set"); + error->all(file,line,"Invalid type for mass set"); mass[itype] = mass_one; mass_setflag[itype] = 1; - if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); + if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value"); } /* ---------------------------------------------------------------------- @@ -1432,16 +1432,16 @@ void Atom::set_mass(const char *str, int type_offset) called from EAM pair routine ------------------------------------------------------------------------- */ -void Atom::set_mass(int itype, double value) +void Atom::set_mass(const char *file, int line, int itype, double value) { - if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); + if (mass == NULL) error->all(file,line,"Cannot set mass for this atom style"); if (itype < 1 || itype > ntypes) - error->all(FLERR,"Invalid type for mass set"); + error->all(file,line,"Invalid type for mass set"); mass[itype] = value; mass_setflag[itype] = 1; - if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); + if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value"); } /* ---------------------------------------------------------------------- @@ -1449,19 +1449,19 @@ void Atom::set_mass(int itype, double value) called from reading of input script ------------------------------------------------------------------------- */ -void Atom::set_mass(int narg, char **arg) +void Atom::set_mass(const char *file, int line, int narg, char **arg) { - if (mass == NULL) error->all(FLERR,"Cannot set mass for this atom style"); + if (mass == NULL) error->all(file,line,"Cannot set mass for this atom style"); int lo,hi; - force->bounds(arg[0],ntypes,lo,hi); - if (lo < 1 || hi > ntypes) error->all(FLERR,"Invalid type for mass set"); + force->bounds(file,line,arg[0],ntypes,lo,hi); + if (lo < 1 || hi > ntypes) error->all(file,line,"Invalid type for mass set"); for (int itype = lo; itype <= hi; itype++) { mass[itype] = atof(arg[1]); mass_setflag[itype] = 1; - if (mass[itype] <= 0.0) error->all(FLERR,"Invalid mass value"); + if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value"); } } @@ -1481,12 +1481,12 @@ void Atom::set_mass(double *values) check that all masses have been set ------------------------------------------------------------------------- */ -void Atom::check_mass() +void Atom::check_mass(const char *file, int line) { if (mass == NULL) return; for (int itype = 1; itype <= ntypes; itype++) if (mass_setflag[itype] == 0) - error->all(FLERR,"Not all per-type masses are set"); + error->all(file,line,"Not all per-type masses are set"); } /* ---------------------------------------------------------------------- diff --git a/src/atom.h b/src/atom.h index 61cd9673bf..00149c5dae 100644 --- a/src/atom.h +++ b/src/atom.h @@ -235,11 +235,11 @@ class Atom : protected Pointers { void data_bodies(int, char *, class AtomVecBody *, tagint); virtual void allocate_type_arrays(); - void set_mass(const char *, int); - void set_mass(int, double); - void set_mass(int, char **); + void set_mass(const char *, int, const char *, int); + void set_mass(const char *, int, int, double); + void set_mass(const char *, int, int, char **); void set_mass(double *); - void check_mass(); + void check_mass(const char *, int); int radius_consistency(int, double &); int shape_consistency(int, double &, double &, double &); diff --git a/src/input.cpp b/src/input.cpp index d1343ee38d..7a46929445 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1622,7 +1622,7 @@ void Input::mass() if (narg != 2) error->all(FLERR,"Illegal mass command"); if (domain->box_exist == 0) error->all(FLERR,"Mass command before simulation box is defined"); - atom->set_mass(narg,arg); + atom->set_mass(FLERR,narg,arg); } /* ---------------------------------------------------------------------- */ diff --git a/src/molecule.cpp b/src/molecule.cpp index 0febb784c8..fb7e5a3b50 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -210,7 +210,7 @@ void Molecule::compute_mass() if (massflag) return; massflag = 1; - if (!rmassflag) atom->check_mass(); + if (!rmassflag) atom->check_mass(FLERR); masstotal = 0.0; for (int i = 0; i < natoms; i++) { @@ -234,7 +234,7 @@ void Molecule::compute_com() if (!comflag) { comflag = 1; - if (!rmassflag) atom->check_mass(); + if (!rmassflag) atom->check_mass(FLERR); double onemass; com[0] = com[1] = com[2] = 0.0; @@ -299,7 +299,7 @@ void Molecule::compute_inertia() if (!inertiaflag) { inertiaflag = 1; - if (!rmassflag) atom->check_mass(); + if (!rmassflag) atom->check_mass(FLERR); double onemass,dx,dy,dz; for (int i = 0; i < 6; i++) itensor[i] = 0.0; diff --git a/src/read_data.cpp b/src/read_data.cpp index e170d909cf..7759b9b03d 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -1645,7 +1645,7 @@ void ReadData::mass() for (int i = 0; i < ntypes; i++) { next = strchr(buf,'\n'); *next = '\0'; - atom->set_mass(buf,toffset); + atom->set_mass(FLERR,buf,toffset); buf = next + 1; } delete [] original; diff --git a/src/variable.cpp b/src/variable.cpp index be09ebe69f..2f985a7c8e 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -3675,7 +3675,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, else error->all(FLERR,"Invalid group function in variable formula"); } else if (strcmp(word,"xcm") == 0) { - atom->check_mass(); + atom->check_mass(FLERR); double xcm[3]; if (narg == 2) { double masstotal = group->mass(igroup); @@ -3691,7 +3691,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, else error->all(FLERR,"Invalid group function in variable formula"); } else if (strcmp(word,"vcm") == 0) { - atom->check_mass(); + atom->check_mass(FLERR); double vcm[3]; if (narg == 2) { double masstotal = group->mass(igroup); @@ -3730,7 +3730,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, else error->all(FLERR,"Invalid group function in variable formula"); } else if (strcmp(word,"gyration") == 0) { - atom->check_mass(); + atom->check_mass(FLERR); double xcm[3]; if (narg == 1) { double masstotal = group->mass(igroup); @@ -3749,7 +3749,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, else error->all(FLERR,"Invalid group function in variable formula"); } else if (strcmp(word,"angmom") == 0) { - atom->check_mass(); + atom->check_mass(FLERR); double xcm[3],lmom[3]; if (narg == 2) { double masstotal = group->mass(igroup); @@ -3767,7 +3767,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, else error->all(FLERR,"Invalid group function in variable formula"); } else if (strcmp(word,"torque") == 0) { - atom->check_mass(); + atom->check_mass(FLERR); double xcm[3],tq[3]; if (narg == 2) { double masstotal = group->mass(igroup); @@ -3785,7 +3785,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, else error->all(FLERR,"Invalid group function in variable formula"); } else if (strcmp(word,"inertia") == 0) { - atom->check_mass(); + atom->check_mass(FLERR); double xcm[3],inertia[3][3]; if (narg == 2) { double masstotal = group->mass(igroup); @@ -3806,7 +3806,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, else error->all(FLERR,"Invalid group function in variable formula"); } else if (strcmp(word,"omega") == 0) { - atom->check_mass(); + atom->check_mass(FLERR); double xcm[3],angmom[3],inertia[3][3],omega[3]; if (narg == 2) { double masstotal = group->mass(igroup); diff --git a/src/velocity.cpp b/src/velocity.cpp index 0e964a27bc..82b6efbe1b 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -60,7 +60,7 @@ void Velocity::command(int narg, char **arg) // atom masses must all be set - atom->check_mass(); + atom->check_mass(FLERR); // identify group