/****************************** ProcessDumpFile.c *************************** * * Created 8/98 by John Carpenter * Based on routines ReadLMPDump and CreateArcFile written by * Mike Peachey during summer 1997 * * This function reads the output from LAMMPS dumpfile * and then writes it back out to an ACCELRYS arcfile using * info from ReadCarfile. * */ #include "lmp2.h" void ProcessPosFile05(int num_posfiles,char *posnames[],struct Sys *sysinfo,FILE *ArcFile) { struct Boundary cell; struct NewAtomCoordinates *coord; FILE *PosFile; char line[MAX_LINE_LENGTH]; int i,iax,itag,itype; int nxx,nyy,nzz,matoms; int frame, mskip,timestep; int ifile; float xx,yy,zz; /* Function prototype declarations */ extern void unwrap_molecules(struct NewAtomCoordinates *,struct Sys *); extern void WriteArcFrame(FILE *,int,int,struct Sys *); /* Begin execution */ coord = calloc(sysinfo->natoms, sizeof(struct NewAtomCoordinates)); if ( coord == NULL ) { fprintf(stderr,"Memory Allocation Problem(coord), exiting program"); exit(3); } /* process data */ fprintf(stderr,"\n Processing Timesteps for LAMMPS 2005 dump file\n\n"); frame = 0; mskip = 0; for (ifile=0; ifile < num_posfiles; ifile++) { if ( (PosFile = fopen(posnames[ifile],"r")) == NULL ) { fprintf(stderr,"Cannot open %s\n",posnames[ifile]); exit(2); } while (fgets(line,MAX_LINE_LENGTH, PosFile) != NULL) { if (strstr(line,"NUMBER OF ATOMS")) { fgets(line,MAX_LINE_LENGTH, PosFile); matoms = atoi(line); if (matoms != sysinfo->natoms) { fprintf(stderr,"Number of atoms in car and dump files do not match\n"); exit(1); } } else if (strstr(line,"BOX BOUNDS")) { /* fprintf(stderr,"HERE 1\n"); */ for (iax=0; iax < 3; iax++) { fgets(line, MAX_LINE_LENGTH, PosFile); cell.low[iax] = atof(strtok(line, " ")); cell.hi[iax] = atof(strtok(NULL, " \0\n")); cell.size[iax] = cell.hi[iax] - cell.low[iax]; sysinfo->celldim[iax] = cell.size[iax]; } } else if (strstr(line,"TIMESTEP")) { fscanf(PosFile,"%d",×tep); } else if (strstr(line,"ATOMS")) { if (trueflag) { for (i=0; iatoms[i].xyz[0] = cell.size[0]*coord[i].fract[0]; sysinfo->atoms[i].xyz[1] = cell.size[1]*coord[i].fract[1]; sysinfo->atoms[i].xyz[2] = cell.size[2]*coord[i].fract[2]; } /* Ready to write arc file entry */ if ((mskip >= nskip) || (frame == 0)) { WriteArcFrame(ArcFile,frame,timestep,sysinfo); frame++; mskip = 0; if (frame%20 == 0) fprintf(stderr," %d",frame); if (frame%400 == 0) fprintf(stderr,"\n"); } else mskip++; } /* end if on ITEM */ } /* end while over LINES*/ close(PosFile); } /* end for loop over POS FILES */ fprintf(stderr,"\n\n %d frames were written to the ArcFile\n",frame); }