00001
00002
00003
00004
00041 #ifndef __SKELETON_H__
00042 #define __SKELETON_H__
00043
00044 #include <string>
00045 #include <cstdio>
00046 #include <iostream>
00047 #include <fstream>
00048 #include <cstdarg>
00049 #include <vector>
00050 #include <utility>
00051 #include <mpi.h>
00052 #include "compose.h"
00053 #include "produce.h"
00054 #include "resolve.h"
00055 #include "exceptions.h"
00056
00057 namespace skeleton {
00058 extern int rank;
00059 extern int procs;
00060
00061 void init(int &argc, char **&argv);
00062 void finalize();
00063
00064 bool is_master( );
00065 void mprintf( const char* format, ... );
00066 template< class A >
00067 inline void safe_delete( A *a )
00068 {
00069 if ( a ) delete a;
00070 }
00071
00072 template< class A >
00073 inline void safe_delete_array( A *a )
00074 {
00075 if ( a ) delete[] a;
00076 }
00077
00078 namespace time
00079 {
00080 void initialize( );
00081 void set_time( const char* name, bool barrier = true );
00082 void print( FILE *fp = stdout );
00083 };
00084 class sketoOstream : public std::ofstream {
00085 public:
00086
00087 #if __GNUC__ > 2
00088 sketoOstream&
00089 operator<<(__ostream_type& (*__pf)(__ostream_type&)){
00090 if(rank==0) std::cout << __pf;
00091 return *this;
00092 }
00093 sketoOstream&
00094 operator<<(__ios_type& (*__pf)(__ios_type&)){
00095 if(rank==0) std::cout << __pf;
00096 return *this;
00097 }
00098 sketoOstream&
00099 operator<<(ios_base& (*__pf) (ios_base&)){
00100 if(rank==0) std::cout << __pf;
00101 return *this;
00102 }
00103 #else
00104 sketoOstream&
00105 operator<<(ios& (*__pf) (ios&)){
00106 if(rank==0) std::cout << __pf;
00107 return *this;
00108 }
00109 #endif
00110
00111 template <typename C>
00112 sketoOstream& operator<<(const C&v){
00113 if(rank==0) std::cout << v;
00114 return *this;
00115 }
00116 };
00117 extern sketoOstream cout;
00118 };
00119
00120
00121
00122
00123
00124 int SketoMain( int argc, char **argv );
00125
00126 #endif // __SKELETON_H__