-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
77 lines (63 loc) · 1.87 KB
/
Main.cpp
File metadata and controls
77 lines (63 loc) · 1.87 KB
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
#include <cstdlib>
#include <iostream>
#include <mpi.h>
#include "Work.h"
#include "ReadVariables.h"
/**
Updates:
25/08/2011
- Incorporated MPI, if used.
02/10/2011
- Made all outputs to vector output_content critical so they are one at a time
- A much better way to do this would be to open multiple file streams, and pass those around to be written too directly BUT
I can't be bothered setting that out as it doesn't change the effectiveness of the algorithm. Whoever inherits this might
want to sort that...
06/10/2011
- Also the run time is twice as long having changed to using vector-lists, so definitely not useful for big runs.
Fortunately overall runtime is still short.
24/10/2011
- Moved MPI_INIT and MPI_FINALISE outside brackets
**/
using namespace std;
void correctInputs()
{
cout << "Inputs required:" << endl << endl;
cout << "./zContrast input.file" << endl << endl;
}
int main(int argc, char *argv[])
// Here is our new program
// This class purely checks the input and decides what to do from there using the work class
// However it does return all the errors if inputs are incorrect
{
// MPI Initiate
MPI_Init(&argc, &argv);
// CHECK INPUTS //
if (argc != 2)
{
correctInputs();
// return EXIT_FAILURE;
}
//////////////////
ReadVariables red;
bool check = red.openFile(argv[1]);
if (check == EXIT_SUCCESS)
{
Work work;
// Pass all variables to program
work.setVariables(red);
// MPI Initiate
// MPI_Init(&argc, &argv);
// Run program as needed now settings are all configured
work.run();
// MPI Finialise (Stupid American spelling!)
// MPI_Finalize();
}
else
{
cout << "Error in input file. Exiting..." << endl;
// return EXIT_FAILURE;
}
// MPI Finialise (Stupid American spelling!)
MPI_Finalize();
// return EXIT_SUCCESS;
}