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,79 +166,81 @@ 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 (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 (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 (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 (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");
}
}
// Initialize some variables
if (force->kspace) {
if (!numflag && (comm->me == 0))
error->all(FLERR, "KSpace contribution not supported by compute born/matrix");
}
values_local = values_global = vector = nullptr;
// Initialize some variables
// this fix produces a global vector
values_local = values_global = vector = nullptr;
memory->create(vector, nvalues, "born_matrix:vector");
memory->create(values_global, nvalues, "born_matrix:values_global");
size_vector = nvalues;
// this fix produces a global vector
vector_flag = 1;
extvector = 0;
maxatom = 0;
memory->create(vector, nvalues, "born_matrix:vector");
memory->create(values_global, nvalues, "born_matrix:values_global");
size_vector = nvalues;
if (!numflag) {
vector_flag = 1;
extvector = 0;
maxatom = 0;
if (!numflag) {
memory->create(values_local, nvalues, "born_matrix:values_local");
} else {
} else {
reallocate();
@ -271,7 +265,7 @@ if (!numflag) {
dirlist[4][1] = 2;
dirlist[5][0] = 0;
dirlist[5][1] = 1;
}
}
}
/* ---------------------------------------------------------------------- */