doc: Add serial to list of ci file reserved words
[charm.git] / examples / pose / LBSim / statcoll.c
1 #include<stdio.h>
2
3 FILE *fp;
4 long int i,j;
5 long int objId;
6 long int workStartTime;
7 int workFinishTime;
8
9 char line[80];
10
11 int main(int argc, char **argv)
12 {
13  if(argc!=5)
14    printf("Usage: ./fparse inputfilename outputfilename maxObjects endTime\n");
15  else{
16    long int noObjects=atoi(argv[3]);
17    long int endTime=atoi(argv[4]);
18    long int noBuckets=endTime/100;
19    int arr[noObjects][noBuckets];
20    for(i=0;i<noObjects;i++)
21            for(j=0;j<noBuckets;j++)
22                    arr[i][j]=0;
23    
24    fp = fopen (argv[1], "rt");  /* open the file for reading */
25    while(fgets(line, 80, fp) != NULL)
26    {
27          /* get a line, up to 80 chars from fp done if NULL */
28          sscanf (line, "%d %d %d", &objId, &workStartTime, &workFinishTime);
29          if(workStartTime/100!=workFinishTime/100) {
30          arr[objId][workStartTime/100]+=(workStartTime/100+1)*100-workStartTime;
31                  arr[objId][workFinishTime/100]+=workFinishTime%100;
32          }
33          else
34          arr[objId][workStartTime/100]+=(workFinishTime-workStartTime);
35    
36          //printf("%ld %lf\n",data,value);      
37      
38    }
39    fclose(fp);
40    
41    fp = fopen (argv[2], "w");
42
43    for(i=0;i<noObjects;i++)
44            for(j=0;j<noBuckets;j++)
45                    fprintf(fp,"%ld %ld %ld\n",i,j,arr[i][j]);
46    fclose(fp);
47  }
48 }        
49