00001 #include <stdlib.h>
00002 #include <stdio.h>
00003 #include <string.h>
00004 #include <stdarg.h>
00005 #include "petsc.h"
00006 #include "anamod.h"
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 static PetscErrorCode(*anamodtrace)(void*,char *fmt,va_list) = NULL;
00024 static size_t anamodtracectx = (size_t)NULL;
00025 static PetscTruth anamodtracearrays = PETSC_FALSE;
00026
00027 #undef __FUNCT__
00028 #define __FUNCT__ "AnaModDeclareTraceFunction"
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 PetscErrorCode AnaModDeclareTraceFunction(PetscErrorCode(*fn)(void*,char*,va_list))
00057 {
00058 PetscFunctionBegin;
00059 anamodtrace = fn;
00060 PetscFunctionReturn(0);
00061 }
00062
00063 #undef __FUNCT__
00064 #define __FUNCT__ "AnaModDeclareTraceContext"
00065
00066
00067
00068
00069 PetscErrorCode AnaModDeclareTraceContext(void *ctx)
00070 {
00071 PetscFunctionBegin;
00072 anamodtracectx = (size_t)ctx;
00073 PetscFunctionReturn(0);
00074 }
00075
00076 #undef __FUNCT__
00077 #define __FUNCT__ "AnaModSetTraceArrays"
00078
00079
00080
00081
00082 PetscErrorCode AnaModSetTraceArrays(PetscTruth f)
00083 {
00084 PetscFunctionBegin;
00085 anamodtracearrays = f;
00086 PetscFunctionReturn(0);
00087 }
00088
00089 #undef __FUNCT__
00090 #define __FUNCT__ "AnaModTraceArrays"
00091
00092
00093
00094
00095 PetscErrorCode AnaModTraceArrays(PetscTruth *f)
00096 {
00097 PetscFunctionBegin;
00098 *f = anamodtracearrays;
00099 PetscFunctionReturn(0);
00100 }
00101
00102 #undef __FUNCT__
00103 #define __FUNCT__ "AnaModTraceMessage"
00104
00105
00106
00107 PetscErrorCode AnaModTraceMessage(const char *fmt,...)
00108 {
00109 va_list argp; PetscErrorCode ierr;
00110 PetscFunctionBegin;
00111 if (anamodtrace) {
00112 va_start(argp, fmt);
00113 ierr = (*anamodtrace)((void*)anamodtracectx,(char*)fmt,argp); CHKERRQ(ierr);
00114 va_end(argp);
00115 }
00116 PetscFunctionReturn(0);
00117 }
00118
00119 #undef __FUNCT__
00120 #define __FUNCT__ "AnaModHasTrace"
00121
00122
00123
00124
00125
00126
00127 PetscErrorCode AnaModHasTrace(PetscTruth *flg)
00128 {
00129 PetscFunctionBegin;
00130 if (anamodtrace)
00131 *flg = PETSC_TRUE;
00132 else
00133 *flg = PETSC_FALSE;
00134 PetscFunctionReturn(0);
00135 }
00136