********> bugfix.28 Author: Bill Ross Date: 6/28/95 Programs: Carnal Severity: Moderate Problem: Coordinate files are misread when there is no space (or '-') between numbers. Affects: Such files could result from solute drift in vacuum or a periodic system with a dimension > 999.999 Angstroms. Results would reflect a truncation of most of such numbers to only the decimal portion. E.g. 1090.239 below would be read as .239. | 160.3661090.239-282.405 339.502 834.935 ^^^^^^^^ The fix also adds better reporting if a file that is truncated or has a format problem (e.g. *'s due to format overflow) is encountered. Fix: Make the following change to util.c - rather than give a huge diff, a complete substitution is provided for the routine scanfmt(): ------------------------------------------------------------------ /*********************************************************************** SCANCRD() ************************************************************************/ static char scanbuf[100]; int scancrd(file, x) FILE *file; _REAL *x; { int c; c = fgetc(file); if (c == '\n') c = fgetc(file); if (c == EOF) return(-1); scanbuf[0] = c; c = fscanf(file,"%7c", &scanbuf[1]); scanbuf[8] = '\0'; if (c != 1) return(-1); #ifdef DOUBLE if (sscanf(scanbuf,"%8lf", x) != 1) return(-2); #else if (sscanf(scanbuf,"%8f", x) != 1) return(-2); #endif return(0); } /*********************************************************************** SCANRST() ************************************************************************/ int scanrst(file, xyz) FILE *file; _REAL xyz[]; { int c; c = fgetc(file); if (c == '\n') c = fgetc(file); if (c == EOF) return(-1); scanbuf[0] = c; c = fscanf(file,"%35c", &scanbuf[1]); scanbuf[36] = '\0'; if (c != 1) return(-1); #ifdef DOUBLE if (sscanf(scanbuf,"%12lf", &xyz[0]) != 1) return(-2); if (sscanf(scanbuf+12, "%12lf", &xyz[1]) != 1) return(-2); if (sscanf(scanbuf+24, "%12lf", &xyz[2]) != 1) return(-2); #else if (sscanf(scanbuf,"%12f", &xyz[0]) != 1) return(-2); if (sscanf(scanbuf+12, "%12f", &xyz[1]) != 1) return(-2); if (sscanf(scanbuf+24, "%12f", &xyz[2]) != 1) return(-2); #endif return(0); } /*********************************************************************** SCANPDB() ************************************************************************/ int scanpdb(file, xyz) FILE *file; _REAL xyz[]; { int c; if (fscanf(file, "%80c", scanbuf) != 1) return(-1); scanbuf[78] = '\0'; #ifdef DOUBLE if (sscanf(scanbuf+29, "%12lf", &xyz[0]) != 1) return(-2); if (sscanf(scanbuf+38, "%12lf", &xyz[1]) != 1) return(-2); if (sscanf(scanbuf+46, "%12lf", &xyz[2]) != 1) return(-2); #else if (sscanf(scanbuf+29, "%12f", &xyz[0]) != 1) return(-2); if (sscanf(scanbuf+38, "%12f", &xyz[1]) != 1) return(-2); if (sscanf(scanbuf+46, "%12f", &xyz[2]) != 1) return(-2); #endif while (1) { /* skip to eoln */ c = getc(file); if ( c == 10 || c == EOF) break; } return(0); } /*********************************************************************** SCANFMT() ************************************************************************/ /* * scanfmt() - read xyz for 1 atom from pdb or other format file */ int scanfmt(ifmt, file, fname, xyz) int ifmt; FILE *file; char *fname; _REAL xyz[]; { int i, rc; switch (ifmt) { case CRD: for (i=0; i<3; i++) { rc = scancrd(file, &xyz[i]); if (rc) break; } break; case RST: rc = scanrst(file, xyz); break; case PDB: rc = scanpdb(file, xyz); break; default: fprintf(stderr, "programming error, format %d\n", ifmt); exit(1); } switch (rc) { case 0: break; case -1: printf("(EOF reached on %s)\n", fname); break; case -2: printf("* Format problem in %s:\n [%s]\n", fname, scanbuf); printf("* Could be bad format, or truncated file\n"); break; default: fprintf(stderr, "programming error, rc %d\n", rc); exit(1); } return(rc); } ------------------------------------------------------------------ Temporary workarounds: Rerun vacuum simulations that drift using translational & rotational motion removal. Routines affected: All.