COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
debug.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 
8 #ifndef cf3_common_PE_debug_HPP
9 #define cf3_common_PE_debug_HPP
10 
12 
13 #include <iostream> // should be avoided but this is a debug header which usually is not included
14 
15 #include <boost/thread/thread.hpp>
16 
18 
20 
28 
30 namespace cf3 {
31  namespace common {
32  namespace PE {
33 
35 
36 #define PERank "["<<::cf3::common::PE::Comm::instance().rank() << "] "
37 
43 #define PEProcessSortedExecute(irank,expression) { \
44  if (irank<0){ \
45  int _process_sorted_execute_i_; \
46  int _process_sorted_execute_n_=(int)(::cf3::common::PE::Comm::instance().size()); \
47  int _process_sorted_execute_r_=(int)(::cf3::common::PE::Comm::instance().rank()); \
48  ::cf3::common::PE::Comm::instance().barrier(); \
49  std::cout << std::flush; \
50  ::cf3::common::PE::Comm::instance().barrier(); \
51  for(_process_sorted_execute_i_=0; _process_sorted_execute_i_<_process_sorted_execute_n_; _process_sorted_execute_i_++){ \
52  ::cf3::common::PE::Comm::instance().barrier(); \
53  if(_process_sorted_execute_i_ == _process_sorted_execute_r_){ \
54  expression; \
55  std::cout << std::flush; \
56  ::cf3::common::PE::Comm::instance().barrier(); \
57  } \
58  } \
59  ::cf3::common::PE::Comm::instance().barrier(); \
60  std::cout << std::flush; \
61  ::cf3::common::PE::Comm::instance().barrier(); \
62  } else if (irank==(int)(::cf3::common::PE::Comm::instance().rank())){ \
63  expression; \
64  } \
65 }
66 
68 
75 #define PECheckPoint(msec,msg) { \
76 ::cf3::common::PE::Comm::instance().barrier(); \
77 std::cout << std::flush; \
78 boost::this_thread::sleep(boost::posix_time::milliseconds(msec)); \
79 ::cf3::common::PE::Comm::instance().barrier(); \
80 PEProcessSortedExecute(-1, \
81  std::cout << std::flush; \
82  std::cout << "["<<::cf3::common::PE::Comm::instance().rank() << ":" << __FILE__ << ":" << __LINE__ << "] " << msg << "\n"; \
83  std::cout << std::flush; \
84 ); \
85 ::cf3::common::PE::Comm::instance().barrier(); \
86 std::cout << std::flush; \
87 boost::this_thread::sleep(boost::posix_time::milliseconds(msec)); \
88 ::cf3::common::PE::Comm::instance().barrier(); \
89 }
90 
92 
93 #define PECheckArrivePoint(msec,msg) { \
94 std::cout << std::flush; \
95 std::cout << "["<<::cf3::common::PE::Comm::instance().rank() << "] " << msg << "\n"; \
96 std::cout << std::flush; \
97 ::cf3::common::PE::Comm::instance().barrier(); \
98 boost::this_thread::sleep(boost::posix_time::milliseconds(msec)); \
99 }
100 
101 
103 
107 #define PEDebugVector(v,length) { \
108  std::cout << ::cf3::common::PE::Comm::instance().rank() << "/" << ::cf3::common::PE::Comm::instance().size() << ": " << #v << " " << length << " ( " << std::flush; \
109  for(int _tmp_i_=0; _tmp_i_<length; _tmp_i_++) std::cout << v[_tmp_i_] << " "; \
110  std::cout << " )\n" << std::flush; \
111 }
112 
114 
119 #define PEDebugVectorMember(v,length,member) { \
120  std::cout << ::cf3::common::PE::Comm::instance().rank() << "/" << ::cf3::common::PE::Comm::instance().size() << ": " << #v#member << " " << length << " ( " << std::flush; \
121  for(int _tmp_i_=0; _tmp_i_<length; _tmp_i_++) std::cout << v[_tmp_i_]member << " "; \
122  std::cout << " )\n" << std::flush; \
123 }
124 
126 
130 void wait_for_debugger(const int rank = -1);
131 
133 
134  } // end namespace PE
135  } // end namespace common
136 } // end namespace cf3
137 
139 
140 #endif // cf3_common_PE_debug_HPP
Top-level namespace for coolfluid.
Definition: Action.cpp:18
void wait_for_debugger(const int rank)
Definition: debug.cpp:23
Send comments to:
COOLFluiD Web Admin