1 #define PETSC_DLL 2 3 #include "petscsys.h" /*I "petscsys.h" I*/ 4 5 #if defined(PETSC_USE_DEBUG) && !defined(PETSC_USE_PTHREAD) 6 7 PetscStack *petscstack = 0; 8 9 #undef __FUNCT__ 10 #define __FUNCT__ "PetscStackPublish" 11 PetscErrorCode PetscStackPublish(void) 12 { 13 PetscFunctionBegin; 14 PetscFunctionReturn(0); 15 } 16 17 #undef __FUNCT__ 18 #define __FUNCT__ "PetscStackDepublish" 19 PetscErrorCode PetscStackDepublish(void) 20 { 21 PetscFunctionBegin; 22 PetscFunctionReturn(0); 23 } 24 25 #undef __FUNCT__ 26 #define __FUNCT__ "PetscStackCreate" 27 PetscErrorCode PetscStackCreate(void) 28 { 29 PetscErrorCode ierr; 30 31 PetscStack *petscstack_in; 32 if (petscstack) return 0; 33 34 ierr = PetscNew(PetscStack,&petscstack_in);CHKERRQ(ierr); 35 petscstack_in->currentsize = 0; 36 petscstack = petscstack_in; 37 38 return 0; 39 } 40 41 #undef __FUNCT__ 42 #define __FUNCT__ "PetscStackView" 43 PetscErrorCode PetscStackView(PetscViewer viewer) 44 { 45 PetscErrorCode ierr; 46 int i; 47 FILE *file; 48 49 if (!viewer) viewer = PETSC_VIEWER_STDOUT_SELF; 50 ierr = PetscViewerASCIIGetPointer(viewer,&file);CHKERRQ(ierr); 51 52 if (file == PETSC_STDOUT) { 53 (*PetscErrorPrintf)("Note: The EXACT line numbers in the stack are not available,\n"); 54 (*PetscErrorPrintf)(" INSTEAD the line number of the start of the function\n"); 55 (*PetscErrorPrintf)(" is given.\n"); 56 for (i=petscstack->currentsize-1; i>=0; i--) { 57 (*PetscErrorPrintf)("[%d] %s line %d %s%s\n",PetscGlobalRank, 58 petscstack->function[i], 59 petscstack->line[i], 60 petscstack->directory[i], 61 petscstack->file[i]); 62 } 63 } else { 64 fprintf(file,"Note: The EXACT line numbers in the stack are not available,\n"); 65 fprintf(file," INSTEAD the line number of the start of the function\n"); 66 fprintf(file," is given.\n"); 67 for (i=petscstack->currentsize-1; i>=0; i--) { 68 fprintf(file,"[%d] %s line %d %s%s\n",PetscGlobalRank, 69 petscstack->function[i], 70 petscstack->line[i], 71 petscstack->directory[i], 72 petscstack->file[i]); 73 } 74 } 75 return 0; 76 } 77 78 #undef __FUNCT__ 79 #define __FUNCT__ "PetscStackDestroy" 80 /* PetscFunctionBegin; so that make rule checkbadPetscFunctionBegin works */ 81 PetscErrorCode PetscStackDestroy(void) 82 { 83 PetscErrorCode ierr; 84 if (petscstack){ 85 PetscStack *petscstack_in = petscstack; 86 petscstack = 0; 87 ierr = PetscFree(petscstack_in);CHKERRQ(ierr); 88 } 89 return 0; 90 } 91 92 #undef __FUNCT__ 93 #define __FUNCT__ "PetscStackCopy" 94 /* PetscFunctionBegin; so that make rule checkbadPetscFunctionBegin works */ 95 PetscErrorCode PetscStackCopy(PetscStack* sint,PetscStack* sout) 96 { 97 int i; 98 99 if (!sint) { 100 sout->currentsize = 0; 101 } else { 102 for (i=0; i<sint->currentsize; i++) { 103 sout->function[i] = sint->function[i]; 104 sout->file[i] = sint->file[i]; 105 sout->directory[i] = sint->directory[i]; 106 sout->line[i] = sint->line[i]; 107 } 108 sout->currentsize = sint->currentsize; 109 } 110 return 0; 111 } 112 113 #undef __FUNCT__ 114 #define __FUNCT__ "PetscStackPrint" 115 /* PetscFunctionBegin; so that make rule checkbadPetscFunctionBegin works */ 116 PetscErrorCode PetscStackPrint(PetscStack* sint,FILE *fp) 117 { 118 int i; 119 120 if (!sint) return(0); 121 for (i=sint->currentsize-3; i>=0; i--) { 122 fprintf(fp," [%d] %s() line %d in %s%s\n",PetscGlobalRank,sint->function[i],sint->line[i],sint->directory[i],sint->file[i]); 123 } 124 return 0; 125 } 126 127 #else 128 #undef __FUNCT__ 129 #define __FUNCT__ "PetscStackPublish" 130 PetscErrorCode PetscStackPublish(void) 131 { 132 PetscFunctionBegin; 133 PetscFunctionReturn(0); 134 } 135 #undef __FUNCT__ 136 #define __FUNCT__ "PetscStackDepublish" 137 PetscErrorCode PetscStackDepublish(void) 138 { 139 PetscFunctionBegin; 140 PetscFunctionReturn(0); 141 } 142 #undef __FUNCT__ 143 #define __FUNCT__ "PetscStackCreate" 144 PetscErrorCode PetscStackCreate(void) 145 { 146 PetscFunctionBegin; 147 PetscFunctionReturn(0); 148 } 149 #undef __FUNCT__ 150 #define __FUNCT__ "PetscStackView" 151 PetscErrorCode PetscStackView(PetscViewer viewer) 152 { 153 PetscFunctionBegin; 154 PetscFunctionReturn(0); 155 } 156 #undef __FUNCT__ 157 #define __FUNCT__ "PetscStackDestroy" 158 PetscErrorCode PetscStackDestroy(void) 159 { 160 PetscFunctionBegin; 161 PetscFunctionReturn(0); 162 } 163 164 #endif 165 166