DSDP
|
00001 /*$Id: ploginfo.c,v 1.22 2001/03/23 23:20:50 balay Exp $*/ 00002 /* 00003 DSDPLogInfo() is contained in a different file from the other profiling to 00004 allow it to be replaced at link time by an alternative routine. 00005 */ 00006 #include <stdarg.h> 00007 #include <sys/types.h> 00008 #include <stdlib.h> 00009 #include <malloc.h> 00010 #include "dsdpsys.h" 00011 #include "dsdpbasictypes.h" 00012 00013 #define DSDP_NULL 0 00014 #define DSDP_MAX_PATH_LEN 200 00015 00021 typedef void* DSDPObject; 00022 /* 00023 extern FILE *dsdp_history; 00024 */ 00025 static FILE *dsdp_history=0; 00026 /* 00027 The next three variables determine which, if any, DSDPLogInfo() calls are used. 00028 If DSDPLogPrintInfo is zero, no info messages are printed. 00029 If DSDPLogPrintInfoNull is zero, no info messages associated with a null object are printed. 00030 00031 If DSDPLogInfoFlags[OBJECT_COOKIE - DSDP_COOKIE] is zero, no messages related 00032 to that object are printed. OBJECT_COOKIE is, for example, MAT_COOKIE. 00033 */ 00034 static int DSDPLogPrintInfo = 0; 00035 static int DSDPLogPrintInfoNull = 0; 00036 static FILE *DSDPLogInfoFile = DSDP_NULL; 00037 static int rank=0; 00038 00039 void DSDPSetRank(int rrank){ 00040 rank=rrank; 00041 return; 00042 } 00043 00044 #undef __FUNCT__ 00045 #define __FUNCT__ "DSDPLogInfoAllow" 00046 /*@C 00047 DSDPLogInfoAllow - Causes DSDPLogInfo() messages to be printed to standard output. 00048 00049 Not Collective, each processor may call this seperately, but printing is only 00050 turned on if the lowest processor number associated with the DSDPObject associated 00051 with the call to DSDPLogInfo() has called this routine. 00052 00053 Input Parameter: 00054 + flag - DSDP_TRUE or DSDP_FALSE 00055 - filename - optional name of file to write output to (defaults to stdout) 00056 00057 Options Database Key: 00058 . -log_info [optional filename] - Activates DSDPLogInfoAllow() 00059 00060 Level: advanced 00061 00062 Concepts: debugging^detailed runtime information 00063 Concepts: dumping detailed runtime information 00064 00065 .seealso: DSDPLogInfo() 00066 @*/ 00067 int DSDPLogInfoAllow(int flag, char *filename) 00068 { 00069 char fname[DSDP_MAX_PATH_LEN], tname[5]; 00070 int prank=0; 00071 char* ierr; 00072 00073 DSDPFunctionBegin; 00074 if (flag && filename) { 00075 sprintf(tname, ".%d", prank); 00076 ierr = strcat(fname, tname); 00077 } else if (flag) { 00078 DSDPLogInfoFile = stdout; 00079 } 00080 DSDPLogPrintInfo = flag; 00081 DSDPLogPrintInfoNull = flag; 00082 DSDPFunctionReturn(0); 00083 } 00084 00085 #undef __FUNCT__ 00086 #define __FUNCT__ "DSDPLogInfo" 00087 /*@C 00088 DSDPLogInfo - Logs informative data, which is printed to standard output 00089 or a file when the option -log_info <file> is specified. 00090 00091 Collective over DSDPObject argument 00092 00093 Input Parameter: 00094 + vobj - object most closely associated with the logging statement 00095 - message - logging message, using standard "printf" format 00096 00097 Options Database Key: 00098 $ -log_info : activates printing of DSDPLogInfo() messages 00099 00100 Level: intermediate 00101 00102 Example of Usage: 00103 $ 00104 $ double alpha 00105 $ DSDPLogInfo(0,"Matrix uses parameter alpha=%g\n",alpha); 00106 $ 00107 00108 Concepts: runtime information 00109 00110 .seealso: DSDPLogInfoAllow() 00111 @*/ 00112 void DSDPLogFInfo(void *vobj, int outlevel, const char message[], ...) 00113 { 00114 va_list Argp; 00115 int urank; 00116 size_t len; 00117 char string[8*1024]; 00118 00119 DSDPFunctionBegin; 00120 DSDPLogInfoFile = stdout; 00121 if (DSDPLogPrintInfo < outlevel) return; 00122 if ((DSDPLogPrintInfoNull < outlevel) && !vobj) return; 00123 00124 urank = 0; 00125 if (rank>0) return; 00126 00127 va_start(Argp, message); 00128 sprintf(string, "[%d][%2d] DSDP: ", rank,outlevel); 00129 len = strlen(string); 00130 #if defined(DSDP_HAVE_VPRINTF_CHAR) 00131 vsprintf(string+len, message, (char *) Argp); 00132 #else 00133 vsprintf(string+len, message, Argp); 00134 #endif 00135 fprintf(DSDPLogInfoFile, "%s", string); 00136 fflush(DSDPLogInfoFile); 00137 if (dsdp_history) { 00138 #if defined(DSDP_HAVE_VPRINTF_CHAR) 00139 vfprintf(dsdp_history, message, (char *) Argp); 00140 #else 00141 vfprintf(dsdp_history, message, Argp); 00142 #endif 00143 } 00144 va_end(Argp); 00145 return; 00146 /* DSDPFunctionReturn(0); */ 00147 }