forked from ComputationalRadiationPhysics/parataxis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cu
63 lines (58 loc) · 2 KB
/
main.cu
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
/**
* Copyright 2015-2016 Alexander Grund
*
* This file is part of ParaTAXIS.
*
* ParaTAXIS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ParaTAXIS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ParaTAXIS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mallocMCConfig.hpp"
#include <mpi.h>
#include "parataxisTypes.hpp"
int main( int argc, char **argv )
{
MPI_CHECK(MPI_Init(&argc, &argv));
int errorCode;
try{
/* Use nested region to make sure all simulation classes are
* freed before we call MPI_Finalize
*/
parataxis::SimStarter starter;
parataxis::ArgsErrorCode parserCode = starter.parseConfigs(argc, argv);
switch(parserCode)
{
case parataxis::ArgsErrorCode::ERROR:
errorCode = 1;
break;
case parataxis::ArgsErrorCode::SUCCESS:
starter.load();
starter.start();
starter.unload();
errorCode = 0;
break;
case parataxis::ArgsErrorCode::SUCCESS_EXIT:
errorCode = 0;
break;
default:
std::cerr << "Unhandled parser code: " << int(parserCode) << std::endl;
errorCode = 99;
};
}catch(std::exception& e)
{
std::cerr << "Unhandled exception occurred: " << e.what() << std::endl;
std::cout << "Unhandled exception occurred: " << e.what() << std::endl;
errorCode = 2;
}
MPI_CHECK(MPI_Finalize());
return errorCode;
}