-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
79 lines (66 loc) · 2.15 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***************************************************************************
*
* File : main.c
* Student Id : <INSERT STUDENT ID HERE>
* Name : <INSERT STUDENT NAME HERE>
*
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/time.h>
#include <string.h>
#include "tasks.h"
#define DEBUG_MAIN 1
int main(int argc, char *argv[]) {
/* TODO: Parse Command Line Arguments */
char* flow_file = NULL;
int resolution = 0;
flow_file = argv[1];
resolution = atoi(argv[2]);
struct timeval start;
struct timeval stop;
//Check for correct input arguments
if (argc != 3){
printf("usage: %s <data file> <resolution>", argv[0]);
return 0;
}
if(DEBUG_MAIN){
printf("Data File: %s\nGrid Resolution: %d\n",flow_file,resolution);
}
printf("\n");
/* Task 1: Find the maximum velocity difference */
gettimeofday(&start, NULL);
maxveldiff(flow_file);
gettimeofday(&stop, NULL);
double elapsed_ms = (stop.tv_sec - start.tv_sec) * 1000.0;
elapsed_ms += (stop.tv_usec - start.tv_usec) / 1000.0;
printf("TASK 1: %.2f milliseconds\n", elapsed_ms);
printf("\n");
/* Task 2: Coarser Grid */
gettimeofday(&start, NULL);
coarsegrid(flow_file, resolution);
gettimeofday(&stop, NULL);
elapsed_ms = (stop.tv_sec - start.tv_sec) * 1000.0;
elapsed_ms += (stop.tv_usec - start.tv_usec) / 1000.0;
printf("TASK 2: %.2f milliseconds\n", elapsed_ms);
printf("\n");
/* Task 3: Searching */
// gettimeofday(&start, NULL);
// searching(flow_file);
// gettimeofday(&stop, NULL);
// elapsed_ms = (stop.tv_sec - start.tv_sec) * 1000.0;
// elapsed_ms += (stop.tv_usec - start.tv_usec) / 1000.0;
// printf("TASK 3: %.2f milliseconds\n", elapsed_ms);
// printf("\n");
//
// /* Task 4: Statistics */
// gettimeofday(&start, NULL);
// vortcalc(flow_file);
// gettimeofday(&stop, NULL);
// elapsed_ms = (stop.tv_sec - start.tv_sec) * 1000.0;
// elapsed_ms += (stop.tv_usec - start.tv_usec) / 1000.0;
// printf("TASK 4: %.2f milliseconds\n", elapsed_ms);
printf("All Tasks Successful\n");
return (EXIT_SUCCESS);
}