git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12504 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2014-09-12 14:13:43 +00:00
parent 40da763955
commit 89c7a5df32
4 changed files with 28 additions and 12 deletions

View File

@ -1,6 +1,12 @@
Axel Kohlmeyer is the current maintainer of the msi2lmp tool.
Please send any inquiries about msi2lmp to the lammps-users mailing list.
11 Sep 2014 Axel Kohlmeyer <akohlmey@gmail.com>
Refactored ReadMdfFile.c so it more consistently honors
the MAX_NAME and MAX_STRING string length defines and
potentially handles inputs with long names better.
27 May 2014 Axel Kohlmeyer <akohlmey@gmail.com>
Added TopoTools style type hints as comments to all Mass, PairCoeff,

View File

@ -112,16 +112,16 @@ void ReadMdfFile(void)
in starting and ending atom positions for each residue
*/
temp_string = (char *)calloc(16,sizeof(char));
temp_string = (char *)calloc(MAX_STRING,sizeof(char));
for (n=0; n < no_molecules; n++) {
molecule[n].no_residues = 1;
strncpy(temp_string,atoms[molecule[n].start].residue_string,16);
strncpy(temp_string,atoms[molecule[n].start].residue_string,MAX_NAME);
for (i=molecule[n].start+1; i < molecule[n].end; i++) {
if (strncmp(temp_string,atoms[i].residue_string,16) != 0) {
if (strncmp(temp_string,atoms[i].residue_string,MAX_NAME) != 0) {
molecule[n].no_residues++;
strncpy(temp_string,atoms[i].residue_string,16);
strncpy(temp_string,atoms[i].residue_string,MAX_NAME);
}
}
@ -136,16 +136,16 @@ void ReadMdfFile(void)
for (n=0; n < no_molecules; n++) {
j = 0;
strncpy(molecule[n].residue[j].name,
atoms[molecule[n].start].residue_string,16);
atoms[molecule[n].start].residue_string,MAX_NAME);
molecule[n].residue[j].start = molecule[n].start;
for (i=molecule[n].start+1; i < molecule[n].end; i++) {
if (strncmp(molecule[n].residue[j].name,
atoms[i].residue_string,16) != 0) {
atoms[i].residue_string,MAX_NAME) != 0) {
molecule[n].residue[j].end = i;
molecule[n].residue[++j].start = i;
strncpy(molecule[n].residue[j].name,atoms[i].residue_string,16);
strncpy(molecule[n].residue[j].name,atoms[i].residue_string,MAX_NAME);
}
}
molecule[n].residue[j].end = molecule[n].end;
@ -171,7 +171,7 @@ void ReadMdfFile(void)
for (i=molecule[n].residue[j].start; i < molecule[n].residue[j].end;
i++) {
for (l=0; l < atoms[i].no_connect; l++) {
strncpy(temp_string,atoms[i].connections[l],16);
strncpy(temp_string,atoms[i].connections[l],MAX_STRING);
temp_residue = strtok(temp_string,":");
temp_atom_name = strtok(NULL,"%");
@ -334,7 +334,7 @@ void MakeConnectFullForm(int *counter) {
int i; /* Counter for character array */
int j; /* loop counter */
char tempname[MAX_STRING]; /* name of connection */
char tempname[2*MAX_STRING]; /* name of connection */
char tempcell[10]; /* Values from connectivity record */
char tempsym[5]; /* " " */
char tempbo[6]; /* " " */
@ -347,6 +347,8 @@ void MakeConnectFullForm(int *counter) {
strcat(tempname,":");
strcat(tempname,
atoms[*counter].connections[j]);
/* truncate at capacity of target storage */
tempname[MAX_STRING-1] = '\0';
sscanf(tempname, "%s",
atoms[*counter].connections[j]);
} else sscanf(atoms[*counter].connections[j], "%s", tempname);
@ -396,7 +398,12 @@ void MakeConnectFullForm(int *counter) {
strcat( tempname, tempsym);
strcat( tempname, "/");
strcat( tempname, tempbo);
if (strlen(tempname) > 25) printf("tempname overrun %s\n",tempname);
if (strlen(tempname) >= MAX_STRING) {
printf("tempname overrun %s. truncating to ",tempname);
/* truncate at capacity of target storage */
tempname[MAX_STRING-1] = '\0';
puts(tempname);
}
sscanf(tempname, "%s", atoms[*counter].connections[j]);
}/*End for loop*/
}/* End function MakeNameLong

View File

@ -2,6 +2,9 @@
*
* msi2lmp.exe
*
* v3.9.6 AK- Refactoring of MDF file parser with more consistent
* handling of compile time constants MAX_NAME and MAX_STRING
*
* v3.9.5 AK- Add TopoTools style force field parameter type hints
*
* v3.9.4 AK- Make force field style hints optional with a flag

View File

@ -36,7 +36,7 @@
# include <stdio.h>
#define MSI2LMP_VERSION "v3.9.5 / 27 May 2014"
#define MSI2LMP_VERSION "v3.9.6 / 11 Sep 2014"
#define PI_180 0.01745329251994329576