fix issues in AtomVec refactoring detected by compiler warnings

This commit is contained in:
Axel Kohlmeyer
2020-05-10 14:05:32 -04:00
parent b799e44e5c
commit 987bff27d4
3 changed files with 9 additions and 14 deletions

View File

@ -604,10 +604,13 @@ void Atom::add_peratom(const char *name, void *address,
void Atom::add_peratom_change_columns(const char *name, int cols) void Atom::add_peratom_change_columns(const char *name, int cols)
{ {
int i; int i;
for (int i = 0; i < nperatom; i++) for (i = 0; i < nperatom; i++) {
if (strcmp(name,peratom[i].name) == 0) peratom[i].cols = cols; if (strcmp(name,peratom[i].name) == 0) {
if (i == nperatom) peratom[i].cols = cols;
error->all(FLERR,"Could not find name of peratom array for column change"); return;
}
}
error->all(FLERR,"Could not find name of peratom array for column change");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -192,7 +192,7 @@ int AtomVec::grow_nmax_bonus(int nmax_bonus)
void AtomVec::grow(int n) void AtomVec::grow(int n)
{ {
int datatype,cols,maxcols; int datatype,cols,maxcols;
void *pdata,*plength; void *pdata;
if (n == 0) grow_nmax(); if (n == 0) grow_nmax();
else nmax = n; else nmax = n;
@ -1775,7 +1775,7 @@ void AtomVec::pack_data(double **buf)
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
// if needed, change values before packing // if needed, change values before packing
@ -1841,33 +1841,26 @@ void AtomVec::write_data(FILE *fp, int n, double **buf)
j = 1; j = 1;
for (nn = 1; nn < ndata_atom; nn++) { for (nn = 1; nn < ndata_atom; nn++) {
pdata = mdata_atom.pdata[nn];
datatype = mdata_atom.datatype[nn]; datatype = mdata_atom.datatype[nn];
cols = mdata_atom.cols[nn]; cols = mdata_atom.cols[nn];
if (datatype == DOUBLE) { if (datatype == DOUBLE) {
if (cols == 0) { if (cols == 0) {
double *vec = *((double **) pdata);
fprintf(fp," %-1.16e",buf[i][j++]); fprintf(fp," %-1.16e",buf[i][j++]);
} else { } else {
double **array = *((double ***) pdata);
for (m = 0; m < cols; m++) for (m = 0; m < cols; m++)
fprintf(fp," %-1.16e",buf[i][j++]); fprintf(fp," %-1.16e",buf[i][j++]);
} }
} else if (datatype == INT) { } else if (datatype == INT) {
if (cols == 0) { if (cols == 0) {
int *vec = *((int **) pdata);
fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); fprintf(fp," %d",(int) ubuf(buf[i][j++]).i);
} else { } else {
int **array = *((int ***) pdata);
for (m = 0; m < cols; m++) for (m = 0; m < cols; m++)
fprintf(fp," %d",(int) ubuf(buf[i][j++]).i); fprintf(fp," %d",(int) ubuf(buf[i][j++]).i);
} }
} else if (datatype == BIGINT) { } else if (datatype == BIGINT) {
if (cols == 0) { if (cols == 0) {
bigint *vec = *((bigint **) pdata);
fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i);
} else { } else {
bigint **array = *((bigint ***) pdata);
for (m = 0; m < cols; m++) for (m = 0; m < cols; m++)
fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i); fprintf(fp," " BIGINT_FORMAT,(bigint) ubuf(buf[i][j++]).i);
} }

View File

@ -192,7 +192,6 @@ void AtomVecEllipsoid::unpack_comm_bonus(int n, int first, double *buf)
int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf) int AtomVecEllipsoid::pack_border_bonus(int n, int *list, double *buf)
{ {
int i,j,m; int i,j,m;
double dx,dy,dz;
double *shape,*quat; double *shape,*quat;
m = 0; m = 0;