1
# ifndef _RHEO_DIS_MACRO_H
2
# define _RHEO_DIS_MACRO_H
4
/// This file is part of Rheolef.
6
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
8
/// Rheolef is free software; you can redistribute it and/or modify
9
/// it under the terms of the GNU General Public License as published by
10
/// the Free Software Foundation; either version 2 of the License, or
11
/// (at your option) any later version.
13
/// Rheolef is distributed in the hope that it will be useful,
14
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
/// GNU General Public License for more details.
18
/// You should have received a copy of the GNU General Public License
19
/// along with Rheolef; if not, write to the Free Software
20
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
/// =========================================================================
24
#include "rheolef/diststream.h"
25
#include "rheolef/distributed.h"
28
# ifdef _RHEOLEF_HAVE_MPI
30
# define fatal_macro(message) \
32
if (mpi::environment::initialized() && !mpi::environment::finalized()) { \
33
std::cerr << "fatal{" << mpi::communicator().rank() << "}(" \
34
<< __FILE__ << "," << __LINE__ << "): " \
35
<< message << std::endl << std::flush; \
36
mpi::environment::abort (1); \
38
std::cerr << "fatal(" \
39
<< __FILE__ << "," << __LINE__ << "): " \
40
<< message << std::endl << std::flush; \
46
# define error_macro(message) \
50
# define warning_macro(message) \
52
if (mpi::environment::initialized() && !mpi::environment::finalized()) { \
53
std::cerr << "warning{"<< mpi::communicator().rank() << "}(" \
54
<< __FILE__ << "," << __LINE__ << "): " \
55
<< message << std::endl << std::flush; \
57
std::cerr << "warning(" \
58
<< __FILE__ << "," << __LINE__ << "): " \
59
<< message << std::endl << std::flush; \
63
# define dis_warning_macro(message) \
65
if (mpi::environment::initialized() && !mpi::environment::finalized()) { \
66
mpi::communicator().barrier(); \
67
dcerr << "warning(" << __FILE__ << "," << __LINE__ \
68
<< "): " << message << std::endl << std::flush; \
69
mpi::communicator().barrier(); \
71
std::cerr << "warning(" \
72
<< __FILE__ << "," << __LINE__ << "): " \
73
<< message << std::endl << std::flush; \
79
# ifdef _RHEOLEF_PARANO
80
# define trace_macro(message) \
82
if (mpi::environment::initialized() && !mpi::environment::finalized()) { \
83
std::cerr << "trace{"<< mpi::communicator().rank() << "}(" \
84
<< __FILE__ << "," << __LINE__ << "): " \
85
<< message << std::endl << std::flush; \
87
std::cerr << "trace(" \
88
<< __FILE__ << "," << __LINE__ << "): " \
89
<< message << std::endl << std::flush; \
92
# define dis_trace_macro(message) \
94
if (mpi::environment::initialized() && !mpi::environment::finalized()) { \
95
mpi::communicator().barrier(); \
96
dcerr << "trace(" << __FILE__ << "," << __LINE__ \
97
<< "): " << message << std::endl << std::flush; \
98
mpi::communicator().barrier(); \
100
std::cerr << "trace(" \
101
<< __FILE__ << "," << __LINE__ << "): " \
102
<< message << std::endl << std::flush; \
105
# define assert_macro(ok_condition, message) \
106
{ if (!(ok_condition)) fatal_macro(message); }
107
# else // _RHEOLEF_PARANO
108
# define trace_macro(message)
109
# define dis_trace_macro(message)
110
# define assert_macro(ok_condition, message)
111
# endif // _RHEOLEF_PARANO
115
# endif // _RHEOLEF_HAVE_MPI
116
} // namespace rheolef
117
# endif // _RHEO_DIS_MACRO_H