Rheolef  7.2
an efficient C++ finite element environment
dis_macros.h
Go to the documentation of this file.
1 # ifndef _RHEO_DIS_MACRO_H
2 # define _RHEO_DIS_MACRO_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7 //
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.
12 //
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.
17 //
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
21 //
22 // =========================================================================
23 
24 #include "rheolef/diststream.h"
25 #include "rheolef/communicator.h"
26 namespace rheolef {
27 
28 # ifndef _RHEOLEF_HAVE_MPI
29 # define dis_warning_macro(message) warning_macro(message)
30 # define dis_trace_macro(message) trace_macro(message)
31 # else // _RHEOLEF_HAVE_MPI
32 # undef fatal_macro
33 # define fatal_macro(message) \
34  { \
35  if (boost::mpi::environment::initialized() && !boost::mpi::environment::finalized()) { \
36  std::cerr << "fatal{" << boost::mpi::communicator().rank() << "}(" \
37  << __FILE__ << "," << __LINE__ << "): " \
38  << message << std::endl << std::flush; \
39  boost::mpi::environment::abort (1); \
40  } else { \
41  std::cerr << "fatal(" \
42  << __FILE__ << "," << __LINE__ << "): " \
43  << message << std::endl << std::flush; \
44  exit(1); \
45  } \
46  }
47 
48 # undef error_macro
49 # define error_macro(message) \
50  fatal_macro(message)
51 
52 # undef warning_macro
53 # define warning_macro(message) \
54  { \
55  if (boost::mpi::environment::initialized() && !boost::mpi::environment::finalized()) { \
56  std::cerr << "warning{"<< boost::mpi::communicator().rank() << "}(" \
57  << __FILE__ << "," << __LINE__ << "): " \
58  << message << std::endl << std::flush; \
59  } else { \
60  std::cerr << "warning(" \
61  << __FILE__ << "," << __LINE__ << "): " \
62  << message << std::endl << std::flush; \
63  } \
64  }
65 
66 # define dis_warning_macro(message) \
67  { \
68  if (boost::mpi::environment::initialized() && !boost::mpi::environment::finalized()) { \
69  boost::mpi::communicator().barrier(); \
70  derr << "warning(" << __FILE__ << "," << __LINE__ \
71  << "): " << message << std::endl << std::flush; \
72  boost::mpi::communicator().barrier(); \
73  } else { \
74  std::cerr << "warning(" \
75  << __FILE__ << "," << __LINE__ << "): " \
76  << message << std::endl << std::flush; \
77  } \
78  }
79 
80 # undef assert_macro
81 # undef trace_macro
82 # ifdef _RHEOLEF_PARANO
83 # define trace_macro(message) \
84  { \
85  if (boost::mpi::environment::initialized() && !boost::mpi::environment::finalized()) { \
86  std::cerr << "trace{"<< boost::mpi::communicator().rank() << "}(" \
87  << __FILE__ << "," << __LINE__ << "): " \
88  << message << std::endl << std::flush; \
89  } else { \
90  std::cerr << "trace(" \
91  << __FILE__ << "," << __LINE__ << "): " \
92  << message << std::endl << std::flush; \
93  } \
94  }
95 # define dis_trace_macro(message) \
96  { \
97  if (boost::mpi::environment::initialized() && !boost::mpi::environment::finalized()) { \
98  boost::mpi::communicator().barrier(); \
99  derr << "trace(" << __FILE__ << "," << __LINE__ \
100  << "): " << message << std::endl << std::flush; \
101  boost::mpi::communicator().barrier(); \
102  } else { \
103  std::cerr << "trace(" \
104  << __FILE__ << "," << __LINE__ << "): " \
105  << message << std::endl << std::flush; \
106  } \
107  }
108 # define assert_macro(ok_condition, message) \
109  { if (!(ok_condition)) fatal_macro(message); }
110 # else // _RHEOLEF_PARANO
111 # define trace_macro(message)
112 # define dis_trace_macro(message)
113 # define assert_macro(ok_condition, message)
114 # endif // _RHEOLEF_PARANO
115 #ifdef TODO
116 #endif // TODO
117 
118 # endif // _RHEOLEF_HAVE_MPI
119 } // namespace rheolef
120 # endif // _RHEO_DIS_MACRO_H
This file is part of Rheolef.