10 #ifndef MIN_DEBUG_LEVEL
11 #define MIN_DEBUG_LEVEL 0
13 #ifndef MAX_DEBUG_LEVEL
14 #define MAX_DEBUG_LEVEL 10
18 #define STDERR_LEVEL 5
43 #define DebugM(level,format) \
45 if ((level >= MIN_DEBUG_LEVEL) && (level <= MAX_DEBUG_LEVEL)) \
48 if (level >= STDERR_LEVEL) Dout << "[ERROR " << level << "] "; \
49 else if (level > 0) Dout << "[Debug " << level << "] "; \
50 Dout << iPE << ' ' << iFILE; \
51 Dout << format << endi; \
63 #ifdef PROCTRACE_DEBUG
72 inline static DebugFileTrace *Instance(
char *fn){
73 if(CkpvAccess(DebugFileTrace_instance)==0){
74 CkpvAccess(DebugFileTrace_instance) =
new DebugFileTrace(fn);
76 return CkpvAccess(DebugFileTrace_instance);
78 inline static DebugFileTrace *Object(){
79 return CkpvAccess(DebugFileTrace_instance);
81 DebugFileTrace(
char *fn){
88 memset(tmp, 0, 128*
sizeof(
char));
89 sprintf(tmp,
"%s.%d", fn, CkMyPe());
90 fname =
new char[strlen(tmp)+1];
91 memcpy(fname, tmp, strlen(tmp)+1);
92 fp = fopen(fname,
"w");
99 inline void writeTrace(
const char *msg, ...){
101 va_start(argList, msg);
102 vfprintf(fp, msg, argList);
105 inline int openTrace(){
106 if(fname==NULL)
return 0;
107 fp = fopen(fname,
"a");
113 inline int closeTrace(){
114 if(fname==NULL)
return 0;
117 inline int flushTrace(){
134 fprintf(stderr, "DEBUG: %s:%d: %s\n", __FILE__, __LINE__, t)
136 fprintf(stderr, "DEBUG: %s:%d: %s=\"%s\"\n", __FILE__, __LINE__, #t, t)
138 fprintf(stderr, "DEBUG: %s:%d: %s=%d\n", __FILE__, __LINE__, #n, n)
140 fprintf(stderr, "DEBUG: %s:%d: %s=%g\n", __FILE__, __LINE__, #r, double(r))
142 fprintf(stderr, "DEBUG: %s:%d: %s=%e\n", __FILE__, __LINE__, #r, double(r))
144 fprintf(stderr, "DEBUG: %s:%d: %s=%g %g %g\n", __FILE__, __LINE__, \
145 #v, double(v.x), double(v.y), double(v.z))