00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef LOG_SYSTEM
00043 #define LOG_SYSTEM
00044 #define LEVEL_MAX 10
00045
00046 EXTERN int global_level;
00047 EXTERN int global_mod;
00048 EXTERN int global_proc;
00049 EXTERN int global_proc1;
00050 EXTERN int global_proc2;
00051 EXTERN int start_dump;
00052 EXTERN int end_dump;
00053 EXTERN char my_hostname[512];
00054
00055
00056 #define MOD_MD 0x0001
00057 #define MOD_CONTINU 0x0002
00058 #define MOD_COUPLING 0x0004
00059 #define MOD_DUMPER 0x0008
00060 #define MOD_STIMULATION 0x0010
00061 #define MOD_GEOMETRY 0x0020
00062 #define MOD_FILTER 0x0040
00063 #define MOD_PARSER 0x0080
00064 #define MOD_MAIN 0xffff
00065
00066
00067
00068
00069
00070 #define MOD_ALL 0xFFFF
00071
00072 #include <iomanip>
00073
00074 #define DBG_ERROR 0
00075 #define DBG_WARNING 1
00076 #define DBG_INFO_STARTUP 2
00077 #define DBG_INFO 3
00078 #define DBG_DETAIL 4
00079 #define DBG_ALL 5
00080
00081 EXTERN std::ofstream global_out;
00082
00083 #define FORMATREAL(x) setprecision(15) << x
00084
00085 #define DUMP(x,level) DUMP##level(x)
00086 #define DUMPFILE(f,x) f << "[" << my_proc_id << "]<" << __FILE__ << "," << __LINE__ << ">" << x << endl;
00087
00088 #if LEVEL_MAX > 0
00089 #define DUMPDBG_ERROR(x) {if(global_level >= 0) PRINTOUT("ERROR : " << x)}
00090 #else
00091 #define DUMPDBG_ERROR(x) {}
00092 #endif
00093
00094 #if LEVEL_MAX > 1
00095 #define DUMPDBG_WARNING(x) {if(global_level >= 1) PRINTOUT("WARNING : " << x)}
00096 #else
00097 #define DUMPDBG_WARNING(x) {}
00098 #endif
00099
00100 #if LEVEL_MAX > 2
00101 #define DUMPDBG_INFO_STARTUP(x) {if(global_level >= 2) PRINTOUT("INFO_STARTUP : " << x)}
00102 #else
00103 #define DUMPDBG_INFO_STARTUP(x) {}
00104 #endif
00105
00106 #if LEVEL_MAX > 3
00107 #define DUMPDBG_INFO(x) {if(global_level >= 3) PRINTOUT("INFO : " << x)}
00108 #else
00109 #define DUMPDBG_INFO(x) {}
00110 #endif
00111
00112 #if LEVEL_MAX > 4
00113 #define DUMPDBG_DETAIL(x) {if(global_level >= 4) PRINTOUT("DETAIL : " << x)}
00114 #else
00115 #define DUMPDBG_DETAIL(x) {}
00116 #endif
00117
00118 #if LEVEL_MAX > 5
00119 #define DUMPDBG_ALL(x) {if(global_level >= 5) PRINTOUT(x)}
00120 #else
00121 #define DUMPDBG_ALL(x) {}
00122 #endif
00123
00124
00125
00126 #if defined(HAVE_MPI) && !defined(AIX)
00127 #define PRINTOUT(x) if((global_mod & LOCAL_MODULE) && (global_proc == -1 || global_proc == my_proc_id || global_proc1 == my_proc_id || global_proc2 == my_proc_id) && \
00128 (current_step >= start_dump && (end_dump == -1 || current_step <= end_dump))) \
00129 {cerr << "(" << current_step << ")[" << my_proc_id << "," << my_hostname << "]<" << __FILE__ << "," << __LINE__ << ">" << x << endl << std::flush;}
00130
00131
00132
00133 #else
00134 #define PRINTOUT(x) {cerr << "<" << __FILE__ << "," << __LINE__ << ">" << x << endl;}
00135 #endif // HAVE_MPI
00136
00137
00138 #define FATAL(x) {cerr << "[" << my_proc_id << "]<" << __FILE__ << "," << __LINE__ << "> FATAL : " << x << endl;global_out.close();exit(-1);}
00139
00140
00141 #if defined(TIMER)
00142 #include <map>
00143
00144 EXTERN std::map<string,int> mesT;
00145 EXTERN std::map<string,int> mesTmicro;
00146 EXTERN std::map<string,int> nmes;
00147 EXTERN int s;
00148 EXTERN int ms;
00149
00150 #include <sys/time.h>
00151 #include <fstream>
00152 EXTERN std::map<string,struct timeval> tstart;
00153 EXTERN std::map<string,struct timeval> tstop;
00154 #define STARTTIMER(x) gettimeofday(&(tstart[x]),NULL)
00155 #define STOPTIMER(x) gettimeofday(&(tstop[x]),NULL); \
00156 s = tstop[x].tv_sec - tstart[x].tv_sec; \
00157 ms = tstop[x].tv_usec - tstart[x].tv_usec; \
00158 if (ms < 0) {--s;ms+=1000000;} \
00159 if (mesTmicro[x] + ms >= 1000000){++s;ms-= 1000000;} \
00160 mesT[x]+= s;mesTmicro[x] += ms;nmes[x]++
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 #define DUMP_TIMES char fname[255]; sprintf(fname,"perf-%.5d",my_proc_id); \
00175 std::ofstream out(fname); \
00176 map<string,int>::iterator courant = mesT.begin(); \
00177 map<string,int>::iterator dernier = mesT.end(); \
00178 while(courant != dernier){ \
00179 s = (*courant).second*1000000; \
00180 ms = mesTmicro[(*courant).first]; \
00181 s /= nmes[(*courant).first];ms /= nmes[(*courant).first]; \
00182 ms+=s%1000000;s/=1000000; \
00183 out << (*courant).first << " : " << s << " secondes et " << ms << " microsecondes" << endl; \
00184 out << (*courant).first << " : " << (*courant).second << " secondes et " << mesTmicro[(*courant).first] << " microsecondes sur " << nmes[(*courant).first] << " mesures" << endl; \
00185 ++courant;}
00186 #else
00187 #define DUMP_TIMES
00188 #define STARTTIMER(x)
00189 #define STOPTIMER(x)
00190 #endif // TIMER
00191
00192 #endif // LOG_SYSTEM