~ubuntu-branches/ubuntu/raring/rheolef/raring-proposed

« back to all changes in this revision

Viewing changes to skit/plib2/dis_macros.h

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Saramito
  • Date: 2011-03-23 11:14:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110323111426-cjvhey7lxt6077ty
Tags: 5.93-1
* New upstream release (minor changes):
  - some extra warning message deleted in heap_allocator
  - graphic output with mayavi2 fixed
  - add doc refman in .info and .pdf format

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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/distributed.h"
 
26
namespace rheolef {
 
27
 
 
28
# ifdef _RHEOLEF_HAVE_MPI
 
29
# undef fatal_macro
 
30
# define fatal_macro(message)                                           \
 
31
        {                                                               \
 
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);                                \
 
37
          } else {                                                       \
 
38
            std::cerr << "fatal("                                        \
 
39
               << __FILE__ << "," << __LINE__ << "): "                   \
 
40
               << message << std::endl << std::flush;                    \
 
41
            exit(1);                                                    \
 
42
          }                                                             \
 
43
        }
 
44
 
 
45
# undef  error_macro
 
46
# define error_macro(message) \
 
47
        fatal_macro(message)
 
48
 
 
49
# undef  warning_macro
 
50
# define warning_macro(message)                                          \
 
51
        {                                                                \
 
52
          if (mpi::environment::initialized() && !mpi::environment::finalized()) { \
 
53
            std::cerr << "warning{"<< mpi::communicator().rank() << "}(" \
 
54
               << __FILE__ << "," << __LINE__ << "): "                   \
 
55
               << message << std::endl << std::flush;                    \
 
56
          } else {                                                       \
 
57
            std::cerr << "warning("                                      \
 
58
               << __FILE__ << "," << __LINE__ << "): "                   \
 
59
               << message << std::endl << std::flush;                    \
 
60
          }                                                              \
 
61
        }
 
62
 
 
63
# define dis_warning_macro(message)                                     \
 
64
        {                                                               \
 
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();                              \
 
70
          } else {                                                       \
 
71
            std::cerr << "warning("                                      \
 
72
               << __FILE__ << "," << __LINE__ << "): "                   \
 
73
               << message << std::endl << std::flush;                    \
 
74
          }                                                              \
 
75
        }
 
76
 
 
77
# undef assert_macro
 
78
# undef trace_macro
 
79
# ifdef _RHEOLEF_PARANO
 
80
#  define trace_macro(message) \
 
81
        {                                                                \
 
82
          if (mpi::environment::initialized() && !mpi::environment::finalized()) { \
 
83
            std::cerr << "trace{"<< mpi::communicator().rank() << "}(" \
 
84
               << __FILE__ << "," << __LINE__ << "): "                   \
 
85
               << message << std::endl << std::flush;                    \
 
86
          } else {                                                       \
 
87
            std::cerr << "trace("                                        \
 
88
               << __FILE__ << "," << __LINE__ << "): "                   \
 
89
               << message << std::endl << std::flush;                    \
 
90
          }                                                              \
 
91
        }
 
92
#  define dis_trace_macro(message) \
 
93
        {                                                               \
 
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();                              \
 
99
          } else {                                                       \
 
100
            std::cerr << "trace("                                        \
 
101
               << __FILE__ << "," << __LINE__ << "): "                   \
 
102
               << message << std::endl << std::flush;                    \
 
103
          }                                                              \
 
104
        }
 
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
 
112
#ifdef TODO
 
113
#endif // TODO
 
114
 
 
115
# endif // _RHEOLEF_HAVE_MPI
 
116
} // namespace rheolef
 
117
# endif // _RHEO_DIS_MACRO_H