2 * postproc.c - post processing moldyn data
4 * author: Frank Zirkelbach <frank.zirkelbach@physik.uni-augsburg.de>
12 #include <sys/types.h>
19 #include "math/math.h"
24 #define DISPLACEMENT (1<<0)
25 #define VELOCITY (1<<1)
51 printf(" -i <infile> -o <outfile>\n");
52 printf(" -d/v (displacement,velocity)\n");
57 int main(int argc,char **argv) {
61 char infile[FILEMAX+1];
63 char outfile[FILEMAX+1];
71 memset(infile,0,FILEMAX+1);
72 memset(outfile,0,FILEMAX+1);
73 memset(buf,0,BUFMAX+1);
89 strncpy(infile,argv[++i],FILEMAX);
92 strncpy(outfile,argv[++i],FILEMAX);
109 if(!strcmp(infile,"")) {
110 printf("no infile specified!\n");
113 printf("infile -> %s\n",infile);
115 infd=open(infile,O_RDONLY);
123 if(!strcmp(outfile,"")) {
124 printf("no outfile specified!\n");
127 printf("outfile -> %s\n",outfile);
129 outfd=open(outfile,O_WRONLY|O_CREAT);
137 size=sizeof(t_moldyn);
140 ret+=read(infd,&md,size-ret);
141 printf("read %d bytes moldyn struct data\n",size);
143 /* allocate memory for atoms */
144 size=md.count*sizeof(t_atom);
145 md.atom=malloc(size);
151 /* read in atom data */
156 ret+=read(infd,atom,size-ret);
157 printf("read %d bytes atom data\n",size);
159 /* postprocess ... */
160 dprintf(outfd,"%d\n",md.count+8);
161 dprintf(outfd,"atoms at time %f\n",md.time);
162 for(i=0;i<md.count;i++) {
164 dprintf(outfd,"%s %f %f %f",pse[atom[i].element],
165 atom[i].r.x,atom[i].r.y,atom[i].r.z);
166 if(mode&DISPLACEMENT) {
167 v3_sub(&dist,&(atom[i].r),&(atom[i].r_0));
168 check_per_bound(&md,&dist);
169 dprintf(outfd," %f",v3_norm(&dist));
172 dprintf(outfd," %f",atom[i].ekin);
177 /* free memory & close file descriptors */