-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·59 lines (49 loc) · 1.2 KB
/
main.cpp
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
#include <stdio.h>
#include "global.h"
#include "MSimulationData.h"
#include "MSimulationInit.h"
#include "MSolution.h"
#include "MOutput.h"
#include <mpi.h>
int main(int argc, char **argv)
{
MSimulationData &simdata = *MSimulationData::Instance();
MOutput &output = *MOutput::Instance(&simdata);
MSolution &solution = *MSolution::Instance(&simdata, &output);
MSimulationInit &init = *MSimulationInit::Instance(&simdata, &solution, &output);
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &simdata.numprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &simdata.my_id);
bool newproblem;
// Startup procedure
if ( simdata.Startup(argc, argv, newproblem) != OK )
{
simdata.Shutdown(ERROR);
return ERROR;
}
// Get input from file
if ( simdata.GetInput() != OK )
{
simdata.Shutdown(ERROR);
return ERROR;
}
// Initialize everything in order to start simulation
if ( init.Initialize() != OK )
{
simdata.Shutdown(ERROR);
return ERROR;
}
// Simulation itself
if ( solution.Solution()!=OK )
{
simdata.Shutdown(ERROR);
return ERROR;
}
simdata.Shutdown(OK);
init.DestroyInstance();
solution.DestroyInstance();
output.DestroyInstance();
simdata.DestroyInstance();
MPI_Finalize();
return OK;
}