Merge branch 'master' into symbolic-atom-constants

This commit is contained in:
Axel Kohlmeyer
2020-09-15 17:44:31 -04:00
1186 changed files with 8448 additions and 8360 deletions

View File

@ -62,7 +62,7 @@ enum{NONE,APPEND,VALUE,MERGE};
const char *suffixes[] = {"/cuda","/gpu","/opt","/omp","/kk",
"/coul/cut","/coul/long","/coul/msm",
"/coul/dsf","/coul/debye","/coul/charmm",
NULL};
nullptr};
/* ---------------------------------------------------------------------- */
@ -74,8 +74,8 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp)
style = new char[MAXLINE];
buffer = new char[CHUNK*MAXLINE];
narg = maxarg = 0;
arg = NULL;
fp = NULL;
arg = nullptr;
fp = nullptr;
// customize for new sections
// pointers to atom styles that store bonus info
@ -132,9 +132,9 @@ void ReadData::command(int narg, char **arg)
groupbit = 0;
nfix = 0;
fix_index = NULL;
fix_header = NULL;
fix_section = NULL;
fix_index = nullptr;
fix_header = nullptr;
fix_section = nullptr;
int iarg = 1;
while (iarg < narg) {
@ -277,7 +277,7 @@ void ReadData::command(int narg, char **arg)
fix_index[nfix] = modify->find_fix(arg[iarg+1]);
if (fix_index[nfix] < 0)
error->all(FLERR,"Fix ID for read_data does not exist");
if (strcmp(arg[iarg+2],"NULL") == 0) fix_header[nfix] = NULL;
if (strcmp(arg[iarg+2],"NULL") == 0) fix_header[nfix] = nullptr;
else {
int n = strlen(arg[iarg+2]) + 1;
fix_header[nfix] = new char[n];
@ -337,12 +337,12 @@ void ReadData::command(int narg, char **arg)
// set up pointer to hold original styles while we replace them with "zero"
Pair *saved_pair = NULL;
Bond *saved_bond = NULL;
Angle *saved_angle = NULL;
Dihedral *saved_dihedral = NULL;
Improper *saved_improper = NULL;
KSpace *saved_kspace = NULL;
Pair *saved_pair = nullptr;
Bond *saved_bond = nullptr;
Angle *saved_angle = nullptr;
Dihedral *saved_dihedral = nullptr;
Improper *saved_improper = nullptr;
KSpace *saved_kspace = nullptr;
if (coeffflag == 0) {
char *coeffs[2];
@ -350,33 +350,33 @@ void ReadData::command(int narg, char **arg)
coeffs[1] = (char *) "nocoeff";
saved_pair = force->pair;
force->pair = NULL;
force->pair = nullptr;
force->create_pair("zero",0);
if (force->pair) force->pair->settings(2,coeffs);
coeffs[0] = coeffs[1];
saved_bond = force->bond;
force->bond = NULL;
force->bond = nullptr;
force->create_bond("zero",0);
if (force->bond) force->bond->settings(1,coeffs);
saved_angle = force->angle;
force->angle = NULL;
force->angle = nullptr;
force->create_angle("zero",0);
if (force->angle) force->angle->settings(1,coeffs);
saved_dihedral = force->dihedral;
force->dihedral = NULL;
force->dihedral = nullptr;
force->create_dihedral("zero",0);
if (force->dihedral) force->dihedral->settings(1,coeffs);
saved_improper = force->improper;
force->improper = NULL;
force->improper = nullptr;
force->create_improper("zero",0);
if (force->improper) force->improper->settings(1,coeffs);
saved_kspace = force->kspace;
force->kspace = NULL;
force->kspace = nullptr;
}
// -----------------------------------------------------------------
@ -417,7 +417,7 @@ void ReadData::command(int narg, char **arg)
if (me == 0) {
if (firstpass) utils::logmesg(lmp,"Reading data file ...\n");
open(arg[0]);
} else fp = NULL;
} else fp = nullptr;
// read header info
@ -581,7 +581,7 @@ void ReadData::command(int narg, char **arg)
if (firstpass) mass();
else skip_lines(ntypes);
} else if (strcmp(keyword,"Pair Coeffs") == 0) {
if (force->pair == NULL)
if (force->pair == nullptr)
error->all(FLERR,"Must define pair_style before Pair Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->pair_style))
@ -590,7 +590,7 @@ void ReadData::command(int narg, char **arg)
paircoeffs();
} else skip_lines(ntypes);
} else if (strcmp(keyword,"PairIJ Coeffs") == 0) {
if (force->pair == NULL)
if (force->pair == nullptr)
error->all(FLERR,"Must define pair_style before PairIJ Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->pair_style))
@ -601,7 +601,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"Bond Coeffs") == 0) {
if (atom->avec->bonds_allow == 0)
error->all(FLERR,"Invalid data file section: Bond Coeffs");
if (force->bond == NULL)
if (force->bond == nullptr)
error->all(FLERR,"Must define bond_style before Bond Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->bond_style))
@ -612,7 +612,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"Angle Coeffs") == 0) {
if (atom->avec->angles_allow == 0)
error->all(FLERR,"Invalid data file section: Angle Coeffs");
if (force->angle == NULL)
if (force->angle == nullptr)
error->all(FLERR,"Must define angle_style before Angle Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->angle_style))
@ -623,7 +623,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"Dihedral Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0)
error->all(FLERR,"Invalid data file section: Dihedral Coeffs");
if (force->dihedral == NULL)
if (force->dihedral == nullptr)
error->all(FLERR,"Must define dihedral_style before Dihedral Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->dihedral_style))
@ -634,7 +634,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"Improper Coeffs") == 0) {
if (atom->avec->impropers_allow == 0)
error->all(FLERR,"Invalid data file section: Improper Coeffs");
if (force->improper == NULL)
if (force->improper == nullptr)
error->all(FLERR,"Must define improper_style before Improper Coeffs");
if (firstpass) {
if (me == 0 && !style_match(style,force->improper_style))
@ -646,14 +646,14 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"BondBond Coeffs") == 0) {
if (atom->avec->angles_allow == 0)
error->all(FLERR,"Invalid data file section: BondBond Coeffs");
if (force->angle == NULL)
if (force->angle == nullptr)
error->all(FLERR,"Must define angle_style before BondBond Coeffs");
if (firstpass) anglecoeffs(1);
else skip_lines(nangletypes);
} else if (strcmp(keyword,"BondAngle Coeffs") == 0) {
if (atom->avec->angles_allow == 0)
error->all(FLERR,"Invalid data file section: BondAngle Coeffs");
if (force->angle == NULL)
if (force->angle == nullptr)
error->all(FLERR,"Must define angle_style before BondAngle Coeffs");
if (firstpass) anglecoeffs(2);
else skip_lines(nangletypes);
@ -662,7 +662,7 @@ void ReadData::command(int narg, char **arg)
if (atom->avec->dihedrals_allow == 0)
error->all(FLERR,
"Invalid data file section: MiddleBondTorsion Coeffs");
if (force->dihedral == NULL)
if (force->dihedral == nullptr)
error->all(FLERR,
"Must define dihedral_style before "
"MiddleBondTorsion Coeffs");
@ -671,7 +671,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"EndBondTorsion Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0)
error->all(FLERR,"Invalid data file section: EndBondTorsion Coeffs");
if (force->dihedral == NULL)
if (force->dihedral == nullptr)
error->all(FLERR,
"Must define dihedral_style before EndBondTorsion Coeffs");
if (firstpass) dihedralcoeffs(2);
@ -679,7 +679,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"AngleTorsion Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0)
error->all(FLERR,"Invalid data file section: AngleTorsion Coeffs");
if (force->dihedral == NULL)
if (force->dihedral == nullptr)
error->all(FLERR,
"Must define dihedral_style before AngleTorsion Coeffs");
if (firstpass) dihedralcoeffs(3);
@ -688,7 +688,7 @@ void ReadData::command(int narg, char **arg)
if (atom->avec->dihedrals_allow == 0)
error->all(FLERR,
"Invalid data file section: AngleAngleTorsion Coeffs");
if (force->dihedral == NULL)
if (force->dihedral == nullptr)
error->all(FLERR,
"Must define dihedral_style before "
"AngleAngleTorsion Coeffs");
@ -697,7 +697,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"BondBond13 Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0)
error->all(FLERR,"Invalid data file section: BondBond13 Coeffs");
if (force->dihedral == NULL)
if (force->dihedral == nullptr)
error->all(FLERR,
"Must define dihedral_style before BondBond13 Coeffs");
if (firstpass) dihedralcoeffs(5);
@ -706,7 +706,7 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"AngleAngle Coeffs") == 0) {
if (atom->avec->impropers_allow == 0)
error->all(FLERR,"Invalid data file section: AngleAngle Coeffs");
if (force->improper == NULL)
if (force->improper == nullptr)
error->all(FLERR,
"Must define improper_style before AngleAngle Coeffs");
if (firstpass) impropercoeffs(1);
@ -728,7 +728,7 @@ void ReadData::command(int narg, char **arg)
if (me == 0) {
if (compressed) pclose(fp);
else fclose(fp);
fp = NULL;
fp = nullptr;
}
// done if this was 2nd pass
@ -932,7 +932,7 @@ void ReadData::header(int firstpass)
if (me == 0) {
char *eof = fgets(line,MAXLINE,fp);
if (eof == NULL) error->one(FLERR,"Unexpected end of data file");
if (eof == nullptr) error->one(FLERR,"Unexpected end of data file");
}
while (1) {
@ -940,7 +940,7 @@ void ReadData::header(int firstpass)
// read a line and bcast length
if (me == 0) {
if (fgets(line,MAXLINE,fp) == NULL) n = 0;
if (fgets(line,MAXLINE,fp) == nullptr) n = 0;
else n = strlen(line) + 1;
}
MPI_Bcast(&n,1,MPI_INT,0,world);
@ -1292,7 +1292,7 @@ void ReadData::bonds(int firstpass)
// allocate count if firstpass
int nlocal = atom->nlocal;
int *count = NULL;
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
@ -1366,7 +1366,7 @@ void ReadData::angles(int firstpass)
// allocate count if firstpass
int nlocal = atom->nlocal;
int *count = NULL;
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
@ -1440,7 +1440,7 @@ void ReadData::dihedrals(int firstpass)
// allocate count if firstpass
int nlocal = atom->nlocal;
int *count = NULL;
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
@ -1514,7 +1514,7 @@ void ReadData::impropers(int firstpass)
// allocate count if firstpass
int nlocal = atom->nlocal;
int *count = NULL;
int *count = nullptr;
if (firstpass) {
memory->create(count,nlocal,"read_data:count");
memset(count,0,nlocal*sizeof(int));
@ -1644,7 +1644,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr)
while (nchunk < nmax && nline <= CHUNK-MAXBODY) {
eof = fgets(&buffer[m],MAXLINE,fp);
if (eof == NULL) error->one(FLERR,"Unexpected end of data file");
if (eof == nullptr) error->one(FLERR,"Unexpected end of data file");
rv = sscanf(&buffer[m],"%d %d %d",&tmp,&ninteger,&ndouble);
if (rv != 3)
error->one(FLERR,"Incorrect format in Bodies section of data file");
@ -1658,7 +1658,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr)
nword = 0;
while (nword < ninteger) {
eof = fgets(&buffer[m],MAXLINE,fp);
if (eof == NULL) error->one(FLERR,"Unexpected end of data file");
if (eof == nullptr) error->one(FLERR,"Unexpected end of data file");
ncount = utils::trim_and_count_words(&buffer[m]);
if (ncount == 0)
error->one(FLERR,"Too few values in body lines in data file");
@ -1672,7 +1672,7 @@ void ReadData::bodies(int firstpass, AtomVec *ptr)
nword = 0;
while (nword < ndouble) {
eof = fgets(&buffer[m],MAXLINE,fp);
if (eof == NULL) error->one(FLERR,"Unexpected end of data file");
if (eof == nullptr) error->one(FLERR,"Unexpected end of data file");
ncount = utils::trim_and_count_words(&buffer[m]);
if (ncount == 0)
error->one(FLERR,"Too few values in body lines in data file");
@ -1746,7 +1746,7 @@ void ReadData::paircoeffs()
for (int i = 0; i < ntypes; i++) {
next = strchr(buf,'\n');
*next = '\0';
parse_coeffs(buf,NULL,1,2,toffset);
parse_coeffs(buf,nullptr,1,2,toffset);
if (narg == 0)
error->all(FLERR,"Unexpected empty line in PairCoeffs section");
force->pair->coeff(narg,arg);
@ -1773,7 +1773,7 @@ void ReadData::pairIJcoeffs()
for (j = i; j < ntypes; j++) {
next = strchr(buf,'\n');
*next = '\0';
parse_coeffs(buf,NULL,0,2,toffset);
parse_coeffs(buf,nullptr,0,2,toffset);
if (narg == 0)
error->all(FLERR,"Unexpected empty line in PairCoeffs section");
force->pair->coeff(narg,arg);
@ -1798,7 +1798,7 @@ void ReadData::bondcoeffs()
for (int i = 0; i < nbondtypes; i++) {
next = strchr(buf,'\n');
*next = '\0';
parse_coeffs(buf,NULL,0,1,boffset);
parse_coeffs(buf,nullptr,0,1,boffset);
if (narg == 0)
error->all(FLERR,"Unexpected empty line in BondCoeffs section");
force->bond->coeff(narg,arg);
@ -1823,7 +1823,7 @@ void ReadData::anglecoeffs(int which)
for (int i = 0; i < nangletypes; i++) {
next = strchr(buf,'\n');
*next = '\0';
if (which == 0) parse_coeffs(buf,NULL,0,1,aoffset);
if (which == 0) parse_coeffs(buf,nullptr,0,1,aoffset);
else if (which == 1) parse_coeffs(buf,"bb",0,1,aoffset);
else if (which == 2) parse_coeffs(buf,"ba",0,1,aoffset);
if (narg == 0) error->all(FLERR,"Unexpected empty line in AngleCoeffs section");
@ -1849,7 +1849,7 @@ void ReadData::dihedralcoeffs(int which)
for (int i = 0; i < ndihedraltypes; i++) {
next = strchr(buf,'\n');
*next = '\0';
if (which == 0) parse_coeffs(buf,NULL,0,1,doffset);
if (which == 0) parse_coeffs(buf,nullptr,0,1,doffset);
else if (which == 1) parse_coeffs(buf,"mbt",0,1,doffset);
else if (which == 2) parse_coeffs(buf,"ebt",0,1,doffset);
else if (which == 3) parse_coeffs(buf,"at",0,1,doffset);
@ -1879,7 +1879,7 @@ void ReadData::impropercoeffs(int which)
for (int i = 0; i < nimpropertypes; i++) {
next = strchr(buf,'\n');
*next = '\0';
if (which == 0) parse_coeffs(buf,NULL,0,1,ioffset);
if (which == 0) parse_coeffs(buf,nullptr,0,1,ioffset);
else if (which == 1) parse_coeffs(buf,"aa",0,1,ioffset);
if (narg == 0) error->all(FLERR,"Unexpected empty line in ImproperCoeffs section");
force->improper->coeff(narg,arg);
@ -1948,7 +1948,7 @@ void ReadData::open(char *file)
#endif
}
if (fp == NULL)
if (fp == nullptr)
error->one(FLERR,fmt::format("Cannot open file {}: {}",
file, utils::getsyserror()));
}
@ -1973,15 +1973,15 @@ void ReadData::parse_keyword(int first)
if (me == 0) {
if (!first) {
if (fgets(line,MAXLINE,fp) == NULL) eof = 1;
if (fgets(line,MAXLINE,fp) == nullptr) eof = 1;
}
while (eof == 0 && done == 0) {
int blank = strspn(line," \t\n\r");
if ((blank == (int)strlen(line)) || (line[blank] == '#')) {
if (fgets(line,MAXLINE,fp) == NULL) eof = 1;
if (fgets(line,MAXLINE,fp) == nullptr) eof = 1;
} else done = 1;
}
if (fgets(buffer,MAXLINE,fp) == NULL) {
if (fgets(buffer,MAXLINE,fp) == nullptr) {
eof = 1;
buffer[0] = '\0';
}
@ -2034,16 +2034,16 @@ void ReadData::skip_lines(bigint n)
{
if (me) return;
if (n <= 0) return;
char *eof = NULL;
char *eof = nullptr;
for (bigint i = 0; i < n; i++) eof = fgets(line,MAXLINE,fp);
if (eof == NULL) error->one(FLERR,"Unexpected end of data file");
if (eof == nullptr) error->one(FLERR,"Unexpected end of data file");
}
/* ----------------------------------------------------------------------
parse a line of coeffs into words, storing them in narg,arg
trim anything from '#' onward
word strings remain in line, are not copied
if addstr != NULL, add addstr as extra arg for class2 angle/dihedral/improper
if addstr != nullptr, add addstr as extra arg for class2 angle/dihedral/improper
if 2nd word starts with letter, then is hybrid style, add addstr after it
else add addstr before 2nd word
if dupflag, duplicate 1st word, so pair_coeff "2" becomes "2 2"
@ -2068,7 +2068,7 @@ void ReadData::parse_coeffs(char *line, const char *addstr,
arg[narg++] = word;
if (addstr && narg == 2 && islower(word[0])) arg[narg++] = (char *) addstr;
if (dupflag && narg == 1) arg[narg++] = word;
word = strtok(NULL," \t\n\r\f");
word = strtok(nullptr," \t\n\r\f");
}
// to avoid segfaults on empty lines
@ -2097,12 +2097,12 @@ int ReadData::style_match(const char *one, const char *two)
{
int i,delta,len,len1,len2;
if ((one == NULL) || (two == NULL)) return 1;
if ((one == nullptr) || (two == nullptr)) return 1;
len1 = strlen(one);
len2 = strlen(two);
for (i = 0; suffixes[i] != NULL; i++) {
for (i = 0; suffixes[i] != nullptr; i++) {
len = strlen(suffixes[i]);
if ((delta = len1 - len) > 0)
if (strcmp(one+delta,suffixes[i]) == 0) len1 = delta;