source: vmg_particles/vmg_particles.cpp@ 4e8206

Last change on this file since 4e8206 was 379700, checked in by Julian Iseringhausen <isering@…>, 14 years ago

vmg: Use MPI error handler only when compiled with --enable-debug.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1768 5161e1c8-67bf-11de-9fd5-51895aff932f

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#ifdef HAVE_CONFIG_H
2#include <config.h>
3#endif
4
5#ifdef HAVE_MPI
6#include <mpi.h>
7#ifdef HAVE_MARMOT
8#include <enhancempicalls.h>
9#include <sourceinfompicalls.h>
10#endif
11#include "comm/mpi/error_handler.hpp"
12#endif
13
14#include <cstdio>
15
16#include "comm/comm.hpp"
17#include "mg.hpp"
18
19using namespace VMG;
20
21int main(int argc, char* argv[])
22{
23#ifdef HAVE_MPI
24 int rank;
25
26 MPI_Init(&argc, &argv);
27
28#ifdef DEBUG
29 MPI_Errhandler mpiErrorHandler;
30 MPI_Comm_create_errhandler(VMG::MPI::ConvertToException, &mpiErrorHandler);
31 MPI_Comm_set_errhandler(MPI_COMM_WORLD, mpiErrorHandler);
32#endif
33
34 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
35 double start = MPI_Wtime();
36#endif
37
38 if (argc < 2) {
39#ifdef HAVE_MPI
40 if (rank == 0)
41#endif
42 std::printf("Wrong number of arguments specified.\nUsage: vmg_particles <config_filename>");
43 }
44
45 MG::InitializeFromParticleConfigFile(argv[1]);
46
47 if (!MG::IsInitialized()) {
48#ifdef HAVE_MPI
49 std::printf("%d: VMG is not properly initialized. Please check your config file.\n", rank);
50 MPI_Abort(MPI_COMM_WORLD, MPI_ERR_OTHER);
51#else
52 std::printf("VMG is not properly initialized. Please check your config file.\n", rank);
53#endif
54 return -1;
55 }
56
57 MG::Solve();
58
59#ifdef HAVE_MPI
60 double end = MPI_Wtime();
61 MG::GetComm()->PrintStringOnce("Running time: %e\n", end-start);
62#endif
63
64 MG::Destroy();
65
66#ifdef HAVE_MPI
67 MPI_Finalize();
68#endif
69
70 return 0;
71}
Note: See TracBrowser for help on using the repository browser.