diff --git a/src/read_data.cpp b/src/read_data.cpp index 4eb04d460f..9f20f0d777 100644 --- a/src/read_data.cpp +++ b/src/read_data.cpp @@ -714,7 +714,7 @@ void ReadData::command(int narg, char **arg) else skip_lines(nimpropertypes); } else if (strcmp(keyword,"Atom Type Labels") == 0) { - if (firstpass) atomtypelabels(); + if (firstpass) typelabels(atom->atomtypelabel,ntypes); else skip_lines(ntypes); } else error->all(FLERR,fmt::format("Unknown identifier in data file: {}", @@ -1909,24 +1909,24 @@ void ReadData::impropercoeffs(int which) /* ---------------------------------------------------------------------- */ -void ReadData::atomtypelabels() +void ReadData::typelabels(char **mytypelabel, int myntypes) { int n; char *next; - char *buf = new char[ntypes*MAXLINE]; + char *buf = new char[myntypes*MAXLINE]; - int eof = comm->read_lines_from_file(fp,ntypes,MAXLINE,buf); + int eof = comm->read_lines_from_file(fp,myntypes,MAXLINE,buf); if (eof) error->all(FLERR,"Unexpected end of data file"); char *typelabel = new char[MAXLINE]; - for (int i = 0; i < ntypes; i++) { + for (int i = 0; i < myntypes; i++) { next = strchr(buf,'\n'); *next = '\0'; sscanf(buf,"%*d %s",typelabel); n = strlen(typelabel) + 1; - delete [] atom->atomtypelabel[i]; - atom->atomtypelabel[i] = new char[n]; - strcpy(atom->atomtypelabel[i],typelabel); + delete [] mytypelabel[i]; + mytypelabel[i] = new char[n]; + strcpy(mytypelabel[i],typelabel); buf = next + 1; } delete [] typelabel; diff --git a/src/read_data.h b/src/read_data.h index c8547dbd35..91b1338f9e 100644 --- a/src/read_data.h +++ b/src/read_data.h @@ -106,7 +106,7 @@ class ReadData : protected Pointers { void anglecoeffs(int); void dihedralcoeffs(int); void impropercoeffs(int); - void atomtypelabels(); + void typelabels(char **, int); void fix(int, char *); };