diff --git a/tools/msi2lmp/README b/tools/msi2lmp/README index d6d48b3874..a20f6e893f 100644 --- a/tools/msi2lmp/README +++ b/tools/msi2lmp/README @@ -1,13 +1,18 @@ Axel Kohlmeyer is the current maintainer of the msi2lmp tool. Please send any inquiries about msi2lmp to the lammps-users mailing list. +06 Oct 2016 Axel Kohlmeyer + +Improved whitespace handling in parsing topology and force field +files to avoid bogus warnings about type name truncation. + 24 Oct 2015 Axel Kohlmeyer Added check to make certain that force field files are consistent with the notation of non-bonded parameters that the msi2lmp code expects. For Class 1 and OPLS-AA the A-B notation with geometric mixing is expected and for -Class 2 the r-eps notation with sixthpower mixing.( +Class 2 the r-eps notation with sixthpower mixing. 11 Sep 2014 Axel Kohlmeyer diff --git a/tools/msi2lmp/src/ReadMdfFile.c b/tools/msi2lmp/src/ReadMdfFile.c index 9bc820f37e..0a0c240cf4 100644 --- a/tools/msi2lmp/src/ReadMdfFile.c +++ b/tools/msi2lmp/src/ReadMdfFile.c @@ -74,9 +74,9 @@ void ReadMdfFile(void) at_end = 1; } else if (strncmp(line,"@column",7) == 0) { - temp_string = strtok(line," "); - col_no = strtok(NULL," "); - col_name = strtok(NULL," "); + temp_string = strtok(line,WHITESPACE); + col_no = strtok(NULL,WHITESPACE); + col_name = strtok(NULL,WHITESPACE); if (strncmp(col_name,"charge",6) == 0) { if (strlen(col_name) < 8) { q_col_no = atoi(col_no); @@ -285,7 +285,7 @@ int get_molecule(char *line, int connect_col_no, int q_col_no, /* Get atom name */ cur_field = strtok(line,":"); sscanf(cur_field, "%s", atoms[*counter].residue_string); - cur_field = strtok(NULL," "); + cur_field = strtok(NULL,WHITESPACE); /* Compare atom name with that in .car file */ if (strcmp(atoms[*counter].name, cur_field)) { printf("Names %s from .car file and %s from .mdf file do not match\n", @@ -297,18 +297,18 @@ int get_molecule(char *line, int connect_col_no, int q_col_no, /* Skip unwanted fields until charge column, then update charge */ - for (i=1; i < q_col_no; i++) strtok(NULL," "); - cur_field = strtok(NULL, " "); + for (i=1; i < q_col_no; i++) strtok(NULL,WHITESPACE); + cur_field = strtok(NULL, WHITESPACE); atoms[*counter].q = atof(cur_field); /* Continue skipping unwanted fields until connectivity records begin */ - for ( i = (q_col_no + 1); i < connect_col_no; i++) strtok(NULL," "); + for ( i = (q_col_no + 1); i < connect_col_no; i++) strtok(NULL,WHITESPACE); /* Process connections */ connect_no = 0; /* reset connections counter */ - while ((cur_field = strtok(NULL," ")) && (connect_no < MAX_CONNECTIONS)) { + while ((cur_field = strtok(NULL,WHITESPACE)) && (connect_no < MAX_CONNECTIONS)) { sscanf(cur_field, "%s", atoms[*counter].connections[connect_no++]); } atoms[*counter].no_connect = connect_no; diff --git a/tools/msi2lmp/src/SearchAndFill.c b/tools/msi2lmp/src/SearchAndFill.c index a779dbcf31..1a85ee111f 100644 --- a/tools/msi2lmp/src/SearchAndFill.c +++ b/tools/msi2lmp/src/SearchAndFill.c @@ -45,9 +45,9 @@ const char *SearchAndCheck(const char *keyword) exit(1); } if (line[0] == '@') { - if (string_match(strtok(line+1," '\t\n'("),keyword)) { + if (string_match(strtok(line+1," '\t\n\r\f("),keyword)) { got_it = 1; - status = strtok(NULL," '\t\n("); + status = strtok(NULL," '\t\n\r\f("); if (status != NULL) return strdup(status); } @@ -79,7 +79,7 @@ void SearchAndFill(struct FrcFieldItem *item) exit(1); } if (line[0] == '#') { - if (string_match(strtok(line," '\t'("),item->keyword)) got_it = 1; + if (string_match(strtok(line," '\t\r\n("),item->keyword)) got_it = 1; } /* if (strncmp(line, item->keyword,strlen(item->keyword))==0) got_it = 1; */ } @@ -132,13 +132,13 @@ void SearchAndFill(struct FrcFieldItem *item) /* version number and reference number */ - version = atof(strtok(line, " ")); - reference = atoi(strtok(NULL, " ")); + version = atof(strtok(line, WHITESPACE)); + reference = atoi(strtok(NULL, WHITESPACE)); /* equivalences */ for(i = 0; i < item->number_of_members; i++ ) { - charptr = strtok(NULL, " "); + charptr = strtok(NULL, WHITESPACE); if (strlen(charptr) > 4) { fprintf(stderr,"Warning: type name overflow for '%s'. " "Truncating to 4 characters.\n",charptr); @@ -150,7 +150,7 @@ void SearchAndFill(struct FrcFieldItem *item) endbontor have to be treated carefully */ for( i = 0; i < item->number_of_parameters; i++ ) { - charptr = strtok(NULL, " "); + charptr = strtok(NULL, WHITESPACE); if(charptr == NULL) { for ( j = i; j < item->number_of_parameters; j++ ) parameters[j] = parameters[j-i]; diff --git a/tools/msi2lmp/src/msi2lmp.c b/tools/msi2lmp/src/msi2lmp.c index 4dc7464e1b..c94d4b4d73 100644 --- a/tools/msi2lmp/src/msi2lmp.c +++ b/tools/msi2lmp/src/msi2lmp.c @@ -2,6 +2,9 @@ * * msi2lmp.exe * +* v3.9.8 AK- Improved whitespace handling in parsing topology and force +* field files to avoid bogus warnings about type name truncation +* * v3.9.7 AK- Add check to enforce that Class1/OPLS-AA use A-B parameter * conventions in force field file and Class2 us r-eps conventions * diff --git a/tools/msi2lmp/src/msi2lmp.h b/tools/msi2lmp/src/msi2lmp.h index 9ef221a348..e07a4486db 100644 --- a/tools/msi2lmp/src/msi2lmp.h +++ b/tools/msi2lmp/src/msi2lmp.h @@ -36,7 +36,7 @@ # include -#define MSI2LMP_VERSION "v3.9.7 / 24 Oct 2015" +#define MSI2LMP_VERSION "v3.9.8 / 06 Oct 2016" #define PI_180 0.01745329251994329576 @@ -45,6 +45,8 @@ #define MAX_STRING 64 #define MAX_NAME 16 +#define WHITESPACE " \t\r\n\f" + #define MAX_ATOM_TYPES 100 #define MAX_BOND_TYPES 200 #define MAX_ANGLE_TYPES 300