turn some warnings into errors and produce better error messages

This commit is contained in:
Axel Kohlmeyer
2022-02-20 06:07:39 -05:00
parent 60a6747c0e
commit c1dfd944af

View File

@ -126,17 +126,9 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
numflag = 0;
numdelta = 0.0;
pairflag = 0;
bondflag = 0;
angleflag = 0;
dihedflag = 0;
impflag = 0;
pairflag = bondflag = angleflag = dihedflag = impflag = 0;
if (narg == 3) {
pairflag = 1;
bondflag = 1;
angleflag = 1;
dihedflag = 1;
impflag = 1;
pairflag = bondflag = angleflag = dihedflag = impflag = 1;
} else {
int iarg = 3;
while (iarg < narg) {
@ -174,60 +166,62 @@ ComputeBornMatrix::ComputeBornMatrix(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->pair) {
if (force->pair->born_matrix_enable == 0)
if (comm->me == 0) error->warning(FLERR, "Pair style does not support compute born/matrix");
}
error->all(FLERR, "Pair style {} does not support compute born/matrix", force->pair_style);
} else {
pairflag = 0;
}
}
if (bondflag) {
if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->bond) {
if (force->bond->born_matrix_enable == 0) {
if (comm->me == 0) error->warning(FLERR, "Bond style does not support compute born/matrix");
}
if (force->bond->born_matrix_enable == 0)
error->all(FLERR, "Bond style {} does not support compute born/matrix", force->bond_style);
} else {
bondflag = 0;
}
}
if (angleflag) {
if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->angle) {
if (force->angle->born_matrix_enable == 0) {
if (comm->me == 0) error->warning(FLERR, "Angle style does not support compute born/matrix");
}
if (force->angle->born_matrix_enable == 0)
error->all(FLERR, "Angle style {} does not support compute born/matrix",
force->angle_style);
} else {
angleflag = 0;
}
}
if (dihedflag) {
if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->dihedral) {
if (force->dihedral->born_matrix_enable == 0) {
if (comm->me == 0)
error->warning(FLERR, "Dihedral style does not support compute born/matrix");
}
if (force->dihedral->born_matrix_enable == 0)
error->all(FLERR, "Dihedral style {} does not support compute born/matrix",
force->dihedral_style);
} else {
dihedflag = 0;
}
}
if (impflag) {
if (numflag)
error->all(FLERR, "Illegal compute born/matrix command: cannot mix numflag and other flags");
if (force->improper) {
if (force->improper->born_matrix_enable == 0) {
if (comm->me == 0)
error->warning(FLERR, "Improper style does not support compute born/matrix");
}
if (force->improper->born_matrix_enable == 0)
error->all(FLERR, "Improper style {} does not support compute born/matrix",
force->improper_style);
} else {
impflag = 0;
}
}
if (force->kspace) {
if (!numflag) error->warning(FLERR, "KSPACE contribution not supported by compute born/matrix");
if (!numflag && (comm->me == 0))
error->all(FLERR, "KSpace contribution not supported by compute born/matrix");
}
// Initialize some variables