15c6c1daeSBarry Smith 25c6c1daeSBarry Smith #include <petsc-private/viewerimpl.h> /*I "petscsys.h" I*/ 35c6c1daeSBarry Smith 45c6c1daeSBarry Smith #define QUEUESTRINGSIZE 1024 55c6c1daeSBarry Smith 65c6c1daeSBarry Smith typedef struct _PrintfQueue *PrintfQueue; 75c6c1daeSBarry Smith struct _PrintfQueue { 85c6c1daeSBarry Smith char string[QUEUESTRINGSIZE]; 95c6c1daeSBarry Smith PrintfQueue next; 105c6c1daeSBarry Smith }; 115c6c1daeSBarry Smith 125c6c1daeSBarry Smith typedef struct { 135c6c1daeSBarry Smith FILE *fd; 145c6c1daeSBarry Smith PetscFileMode mode; /* The mode in which to open the file */ 155c6c1daeSBarry Smith char *filename; 165c6c1daeSBarry Smith PetscBool vecSeen; /* The flag indicating whether any vector has been viewed so far */ 175c6c1daeSBarry Smith PrintfQueue queue, queueBase; 185c6c1daeSBarry Smith int queueLength; 195c6c1daeSBarry Smith } PetscViewer_VU; 205c6c1daeSBarry Smith 215c6c1daeSBarry Smith #undef __FUNCT__ 225c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerFileClose_VU" 235c6c1daeSBarry Smith static PetscErrorCode PetscViewerFileClose_VU(PetscViewer viewer) 245c6c1daeSBarry Smith { 255c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 265c6c1daeSBarry Smith PetscErrorCode ierr; 275c6c1daeSBarry Smith 285c6c1daeSBarry Smith PetscFunctionBegin; 295c6c1daeSBarry Smith if (vu->vecSeen) { 305c6c1daeSBarry Smith ierr = PetscViewerVUPrintDeferred(viewer, "};\n\n");CHKERRQ(ierr); 315c6c1daeSBarry Smith } 325c6c1daeSBarry Smith ierr = PetscViewerVUFlushDeferred(viewer);CHKERRQ(ierr); 33*ce94432eSBarry Smith ierr = PetscFClose(PetscObjectComm((PetscObject)viewer), vu->fd);CHKERRQ(ierr); 340298fd71SBarry Smith vu->fd = NULL; 355c6c1daeSBarry Smith ierr = PetscFree(vu->filename);CHKERRQ(ierr); 365c6c1daeSBarry Smith PetscFunctionReturn(0); 375c6c1daeSBarry Smith } 385c6c1daeSBarry Smith 395c6c1daeSBarry Smith #undef __FUNCT__ 405c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDestroy_VU" 415c6c1daeSBarry Smith PetscErrorCode PetscViewerDestroy_VU(PetscViewer viewer) 425c6c1daeSBarry Smith { 435c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 445c6c1daeSBarry Smith PetscErrorCode ierr; 455c6c1daeSBarry Smith 465c6c1daeSBarry Smith PetscFunctionBegin; 475c6c1daeSBarry Smith ierr = PetscViewerFileClose_VU(viewer);CHKERRQ(ierr); 485c6c1daeSBarry Smith ierr = PetscFree(vu);CHKERRQ(ierr); 495c6c1daeSBarry Smith PetscFunctionReturn(0); 505c6c1daeSBarry Smith } 515c6c1daeSBarry Smith 525c6c1daeSBarry Smith #undef __FUNCT__ 535c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerFlush_VU" 545c6c1daeSBarry Smith PetscErrorCode PetscViewerFlush_VU(PetscViewer viewer) 555c6c1daeSBarry Smith { 565c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 575c6c1daeSBarry Smith PetscMPIInt rank; 585c6c1daeSBarry Smith int err; 595c6c1daeSBarry Smith PetscErrorCode ierr; 605c6c1daeSBarry Smith 615c6c1daeSBarry Smith PetscFunctionBegin; 62*ce94432eSBarry Smith ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer), &rank);CHKERRQ(ierr); 635c6c1daeSBarry Smith if (!rank) { 645c6c1daeSBarry Smith err = fflush(vu->fd); 655c6c1daeSBarry Smith if (err) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SYS,"fflush() failed on file"); 665c6c1daeSBarry Smith } 675c6c1daeSBarry Smith PetscFunctionReturn(0); 685c6c1daeSBarry Smith } 695c6c1daeSBarry Smith 705c6c1daeSBarry Smith EXTERN_C_BEGIN 715c6c1daeSBarry Smith #undef __FUNCT__ 725c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerFileGetName_VU" 735c6c1daeSBarry Smith PetscErrorCode PetscViewerFileGetName_VU(PetscViewer viewer, const char **name) 745c6c1daeSBarry Smith { 755c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 765c6c1daeSBarry Smith 775c6c1daeSBarry Smith PetscFunctionBegin; 785c6c1daeSBarry Smith *name = vu->filename; 795c6c1daeSBarry Smith PetscFunctionReturn(0); 805c6c1daeSBarry Smith } 815c6c1daeSBarry Smith EXTERN_C_END 825c6c1daeSBarry Smith 835c6c1daeSBarry Smith EXTERN_C_BEGIN 845c6c1daeSBarry Smith #undef __FUNCT__ 855c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerFileSetName_VU" 865c6c1daeSBarry Smith PetscErrorCode PetscViewerFileSetName_VU(PetscViewer viewer, const char name[]) 875c6c1daeSBarry Smith { 885c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 895c6c1daeSBarry Smith char fname[PETSC_MAX_PATH_LEN]; 905c6c1daeSBarry Smith int rank; 915c6c1daeSBarry Smith PetscErrorCode ierr; 925c6c1daeSBarry Smith 935c6c1daeSBarry Smith PetscFunctionBegin; 945c6c1daeSBarry Smith if (!name) PetscFunctionReturn(0); 955c6c1daeSBarry Smith ierr = PetscViewerFileClose_VU(viewer);CHKERRQ(ierr); 96*ce94432eSBarry Smith ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer), &rank);CHKERRQ(ierr); 975c6c1daeSBarry Smith if (rank != 0) PetscFunctionReturn(0); 985c6c1daeSBarry Smith ierr = PetscStrallocpy(name, &vu->filename);CHKERRQ(ierr); 995c6c1daeSBarry Smith ierr = PetscFixFilename(name, fname);CHKERRQ(ierr); 1005c6c1daeSBarry Smith switch (vu->mode) { 1015c6c1daeSBarry Smith case FILE_MODE_READ: 1025c6c1daeSBarry Smith vu->fd = fopen(fname, "r"); 1035c6c1daeSBarry Smith break; 1045c6c1daeSBarry Smith case FILE_MODE_WRITE: 1055c6c1daeSBarry Smith vu->fd = fopen(fname, "w"); 1065c6c1daeSBarry Smith break; 1075c6c1daeSBarry Smith case FILE_MODE_APPEND: 1085c6c1daeSBarry Smith vu->fd = fopen(fname, "a"); 1095c6c1daeSBarry Smith break; 1105c6c1daeSBarry Smith case FILE_MODE_UPDATE: 1115c6c1daeSBarry Smith vu->fd = fopen(fname, "r+"); 112a297a907SKarl Rupp if (!vu->fd) vu->fd = fopen(fname, "w+"); 1135c6c1daeSBarry Smith break; 1145c6c1daeSBarry Smith case FILE_MODE_APPEND_UPDATE: 1155c6c1daeSBarry Smith /* I really want a file which is opened at the end for updating, 1165c6c1daeSBarry Smith not a+, which opens at the beginning, but makes writes at the end. 1175c6c1daeSBarry Smith */ 1185c6c1daeSBarry Smith vu->fd = fopen(fname, "r+"); 119a297a907SKarl Rupp if (!vu->fd) vu->fd = fopen(fname, "w+"); 120a297a907SKarl Rupp else { 1215c6c1daeSBarry Smith ierr = fseek(vu->fd, 0, SEEK_END);CHKERRQ(ierr); 1225c6c1daeSBarry Smith } 1235c6c1daeSBarry Smith break; 1245c6c1daeSBarry Smith default: 1255c6c1daeSBarry Smith SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG, "Invalid file mode %d", vu->mode); 1265c6c1daeSBarry Smith } 1275c6c1daeSBarry Smith 1285c6c1daeSBarry Smith if (!vu->fd) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN, "Cannot open PetscViewer file: %s", fname); 1295c6c1daeSBarry Smith #if defined(PETSC_USE_LOG) 1305c6c1daeSBarry Smith PetscLogObjectState((PetscObject) viewer, "File: %s", name); 1315c6c1daeSBarry Smith #endif 1325c6c1daeSBarry Smith PetscFunctionReturn(0); 1335c6c1daeSBarry Smith } 1345c6c1daeSBarry Smith EXTERN_C_END 1355c6c1daeSBarry Smith 1365c6c1daeSBarry Smith EXTERN_C_BEGIN 1375c6c1daeSBarry Smith #undef __FUNCT__ 1385c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerCreate_VU" 1395c6c1daeSBarry Smith PetscErrorCode PetscViewerCreate_VU(PetscViewer viewer) 1405c6c1daeSBarry Smith { 1415c6c1daeSBarry Smith PetscViewer_VU *vu; 1425c6c1daeSBarry Smith PetscErrorCode ierr; 1435c6c1daeSBarry Smith 1445c6c1daeSBarry Smith PetscFunctionBegin; 1455c6c1daeSBarry Smith ierr = PetscNewLog(viewer,PetscViewer_VU, &vu);CHKERRQ(ierr); 1465c6c1daeSBarry Smith viewer->data = (void*) vu; 1475c6c1daeSBarry Smith 1485c6c1daeSBarry Smith viewer->ops->destroy = PetscViewerDestroy_VU; 1495c6c1daeSBarry Smith viewer->ops->flush = PetscViewerFlush_VU; 1500298fd71SBarry Smith viewer->ops->getsingleton = NULL; 1510298fd71SBarry Smith viewer->ops->restoresingleton = NULL; 1525c6c1daeSBarry Smith viewer->format = PETSC_VIEWER_DEFAULT; 1535c6c1daeSBarry Smith viewer->iformat = 0; 1545c6c1daeSBarry Smith 1550298fd71SBarry Smith vu->fd = NULL; 1565c6c1daeSBarry Smith vu->mode = FILE_MODE_WRITE; 1570298fd71SBarry Smith vu->filename = NULL; 1585c6c1daeSBarry Smith vu->vecSeen = PETSC_FALSE; 1590298fd71SBarry Smith vu->queue = NULL; 1600298fd71SBarry Smith vu->queueBase = NULL; 1615c6c1daeSBarry Smith vu->queueLength = 0; 1625c6c1daeSBarry Smith 1635c6c1daeSBarry Smith ierr = PetscObjectComposeFunctionDynamic((PetscObject) viewer,"PetscViewerFileSetName_C", "PetscViewerFileSetName_VU", 1645c6c1daeSBarry Smith PetscViewerFileSetName_VU);CHKERRQ(ierr); 1655c6c1daeSBarry Smith ierr = PetscObjectComposeFunctionDynamic((PetscObject) viewer,"PetscViewerFileGetName_C", "PetscViewerFileGetName_VU", 1665c6c1daeSBarry Smith PetscViewerFileGetName_VU);CHKERRQ(ierr); 1675c6c1daeSBarry Smith PetscFunctionReturn(0); 1685c6c1daeSBarry Smith } 1695c6c1daeSBarry Smith EXTERN_C_END 1705c6c1daeSBarry Smith 1715c6c1daeSBarry Smith #undef __FUNCT__ 1725c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerVUGetPointer" 1735c6c1daeSBarry Smith /*@C 1745c6c1daeSBarry Smith PetscViewerVUGetPointer - Extracts the file pointer from a VU PetscViewer. 1755c6c1daeSBarry Smith 1765c6c1daeSBarry Smith Not Collective 1775c6c1daeSBarry Smith 1785c6c1daeSBarry Smith Input Parameter: 1795c6c1daeSBarry Smith . viewer - The PetscViewer 1805c6c1daeSBarry Smith 1815c6c1daeSBarry Smith Output Parameter: 1825c6c1daeSBarry Smith . fd - The file pointer 1835c6c1daeSBarry Smith 1845c6c1daeSBarry Smith Level: intermediate 1855c6c1daeSBarry Smith 1865c6c1daeSBarry Smith Concepts: PetscViewer^file pointer 1875c6c1daeSBarry Smith Concepts: file pointer^getting from PetscViewer 1885c6c1daeSBarry Smith 1895c6c1daeSBarry Smith .seealso: PetscViewerASCIIGetPointer() 1905c6c1daeSBarry Smith @*/ 1915c6c1daeSBarry Smith PetscErrorCode PetscViewerVUGetPointer(PetscViewer viewer, FILE **fd) 1925c6c1daeSBarry Smith { 1935c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 1945c6c1daeSBarry Smith 1955c6c1daeSBarry Smith PetscFunctionBegin; 1965c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 1975c6c1daeSBarry Smith PetscValidPointer(fd,2); 1985c6c1daeSBarry Smith *fd = vu->fd; 1995c6c1daeSBarry Smith PetscFunctionReturn(0); 2005c6c1daeSBarry Smith } 2015c6c1daeSBarry Smith 2025c6c1daeSBarry Smith #undef __FUNCT__ 2035c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerVUSetMode" 2045c6c1daeSBarry Smith /*@C 2055c6c1daeSBarry Smith PetscViewerVUSetMode - Sets the mode in which to open the file. 2065c6c1daeSBarry Smith 2075c6c1daeSBarry Smith Not Collective 2085c6c1daeSBarry Smith 2095c6c1daeSBarry Smith Input Parameters: 2105c6c1daeSBarry Smith + viewer - The PetscViewer 2115c6c1daeSBarry Smith - mode - The file mode 2125c6c1daeSBarry Smith 2135c6c1daeSBarry Smith Level: intermediate 2145c6c1daeSBarry Smith 2155c6c1daeSBarry Smith .keywords: Viewer, file, get, pointer 2165c6c1daeSBarry Smith .seealso: PetscViewerASCIISetMode() 2175c6c1daeSBarry Smith @*/ 2185c6c1daeSBarry Smith PetscErrorCode PetscViewerVUSetMode(PetscViewer viewer, PetscFileMode mode) 2195c6c1daeSBarry Smith { 2205c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 2215c6c1daeSBarry Smith 2225c6c1daeSBarry Smith PetscFunctionBegin; 2235c6c1daeSBarry Smith vu->mode = mode; 2245c6c1daeSBarry Smith PetscFunctionReturn(0); 2255c6c1daeSBarry Smith } 2265c6c1daeSBarry Smith 2275c6c1daeSBarry Smith #undef __FUNCT__ 2285c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerVUSetVecSeen" 2295c6c1daeSBarry Smith /*@C 2305c6c1daeSBarry Smith PetscViewerVUSetVecSeen - Sets the flag which indicates whether we have viewed 2315c6c1daeSBarry Smith a vector. This is usually called internally rather than by a user. 2325c6c1daeSBarry Smith 2335c6c1daeSBarry Smith Not Collective 2345c6c1daeSBarry Smith 2355c6c1daeSBarry Smith Input Parameters: 2365c6c1daeSBarry Smith + viewer - The PetscViewer 2375c6c1daeSBarry Smith - vecSeen - The flag which indicates whether we have viewed a vector 2385c6c1daeSBarry Smith 2395c6c1daeSBarry Smith Level: advanced 2405c6c1daeSBarry Smith 2415c6c1daeSBarry Smith .keywords: Viewer, Vec 2425c6c1daeSBarry Smith .seealso: PetscViewerVUGetVecSeen() 2435c6c1daeSBarry Smith @*/ 2445c6c1daeSBarry Smith PetscErrorCode PetscViewerVUSetVecSeen(PetscViewer viewer, PetscBool vecSeen) 2455c6c1daeSBarry Smith { 2465c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 2475c6c1daeSBarry Smith 2485c6c1daeSBarry Smith PetscFunctionBegin; 2495c6c1daeSBarry Smith vu->vecSeen = vecSeen; 2505c6c1daeSBarry Smith PetscFunctionReturn(0); 2515c6c1daeSBarry Smith } 2525c6c1daeSBarry Smith 2535c6c1daeSBarry Smith #undef __FUNCT__ 2545c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerVUGetVecSeen" 2555c6c1daeSBarry Smith /*@C 2565c6c1daeSBarry Smith PetscViewerVUGetVecSeen - Gets the flag which indicates whether we have viewed 2575c6c1daeSBarry Smith a vector. This is usually called internally rather than by a user. 2585c6c1daeSBarry Smith 2595c6c1daeSBarry Smith Not Collective 2605c6c1daeSBarry Smith 2615c6c1daeSBarry Smith Input Parameter: 2625c6c1daeSBarry Smith . viewer - The PetscViewer 2635c6c1daeSBarry Smith 2645c6c1daeSBarry Smith Output Parameter: 2655c6c1daeSBarry Smith . vecSeen - The flag which indicates whether we have viewed a vector 2665c6c1daeSBarry Smith 2675c6c1daeSBarry Smith Level: advanced 2685c6c1daeSBarry Smith 2695c6c1daeSBarry Smith .keywords: Viewer, Vec 2705c6c1daeSBarry Smith .seealso: PetscViewerVUGetVecSeen() 2715c6c1daeSBarry Smith @*/ 2725c6c1daeSBarry Smith PetscErrorCode PetscViewerVUGetVecSeen(PetscViewer viewer, PetscBool *vecSeen) 2735c6c1daeSBarry Smith { 2745c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 2755c6c1daeSBarry Smith 2765c6c1daeSBarry Smith PetscFunctionBegin; 2775c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 2785c6c1daeSBarry Smith PetscValidPointer(vecSeen,2); 2795c6c1daeSBarry Smith *vecSeen = vu->vecSeen; 2805c6c1daeSBarry Smith PetscFunctionReturn(0); 2815c6c1daeSBarry Smith } 2825c6c1daeSBarry Smith 2835c6c1daeSBarry Smith #undef __FUNCT__ 2845c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerVUPrintDeferred" 2855c6c1daeSBarry Smith /*@C 2865c6c1daeSBarry Smith PetscViewerVUPrintDeferred - Prints to the deferred write cache instead of the file. 2875c6c1daeSBarry Smith 2885c6c1daeSBarry Smith Not Collective 2895c6c1daeSBarry Smith 2905c6c1daeSBarry Smith Input Parameters: 2915c6c1daeSBarry Smith + viewer - The PetscViewer 2925c6c1daeSBarry Smith - format - The format string 2935c6c1daeSBarry Smith 2945c6c1daeSBarry Smith Level: intermediate 2955c6c1daeSBarry Smith 2965c6c1daeSBarry Smith .keywords: Viewer, print, deferred 2975c6c1daeSBarry Smith .seealso: PetscViewerVUFlushDeferred() 2985c6c1daeSBarry Smith @*/ 2995c6c1daeSBarry Smith PetscErrorCode PetscViewerVUPrintDeferred(PetscViewer viewer, const char format[], ...) 3005c6c1daeSBarry Smith { 3015c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 3025c6c1daeSBarry Smith va_list Argp; 3035c6c1daeSBarry Smith size_t fullLength; 3045c6c1daeSBarry Smith PrintfQueue next; 3055c6c1daeSBarry Smith PetscErrorCode ierr; 3065c6c1daeSBarry Smith 3075c6c1daeSBarry Smith PetscFunctionBegin; 3085c6c1daeSBarry Smith ierr = PetscNew(struct _PrintfQueue, &next);CHKERRQ(ierr); 3095c6c1daeSBarry Smith if (vu->queue) { 3105c6c1daeSBarry Smith vu->queue->next = next; 3115c6c1daeSBarry Smith vu->queue = next; 3120298fd71SBarry Smith vu->queue->next = NULL; 3135c6c1daeSBarry Smith } else { 3145c6c1daeSBarry Smith vu->queueBase = vu->queue = next; 3155c6c1daeSBarry Smith } 3165c6c1daeSBarry Smith vu->queueLength++; 3175c6c1daeSBarry Smith 3185c6c1daeSBarry Smith va_start(Argp, format); 3195c6c1daeSBarry Smith ierr = PetscMemzero(next->string,QUEUESTRINGSIZE);CHKERRQ(ierr); 3205c6c1daeSBarry Smith ierr = PetscVSNPrintf(next->string, QUEUESTRINGSIZE,format,&fullLength, Argp);CHKERRQ(ierr); 3215c6c1daeSBarry Smith va_end(Argp); 3225c6c1daeSBarry Smith PetscFunctionReturn(0); 3235c6c1daeSBarry Smith } 3245c6c1daeSBarry Smith 3255c6c1daeSBarry Smith #undef __FUNCT__ 3265c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerVUFlushDeferred" 3275c6c1daeSBarry Smith /*@C 3285c6c1daeSBarry Smith PetscViewerVUFlushDeferred - Flushes the deferred write cache to the file. 3295c6c1daeSBarry Smith 3305c6c1daeSBarry Smith Not Collective 3315c6c1daeSBarry Smith 3325c6c1daeSBarry Smith Input Parameter: 3335c6c1daeSBarry Smith + viewer - The PetscViewer 3345c6c1daeSBarry Smith 3355c6c1daeSBarry Smith Level: intermediate 3365c6c1daeSBarry Smith 3375c6c1daeSBarry Smith .keywords: Viewer, flush, deferred 3385c6c1daeSBarry Smith .seealso: PetscViewerVUPrintDeferred() 3395c6c1daeSBarry Smith @*/ 3405c6c1daeSBarry Smith PetscErrorCode PetscViewerVUFlushDeferred(PetscViewer viewer) 3415c6c1daeSBarry Smith { 3425c6c1daeSBarry Smith PetscViewer_VU *vu = (PetscViewer_VU*) viewer->data; 3435c6c1daeSBarry Smith PrintfQueue next = vu->queueBase; 3445c6c1daeSBarry Smith PrintfQueue previous; 3455c6c1daeSBarry Smith int i; 3465c6c1daeSBarry Smith PetscErrorCode ierr; 3475c6c1daeSBarry Smith 3485c6c1daeSBarry Smith PetscFunctionBegin; 3495c6c1daeSBarry Smith for (i = 0; i < vu->queueLength; i++) { 350*ce94432eSBarry Smith PetscFPrintf(PetscObjectComm((PetscObject)viewer), vu->fd, "%s", next->string); 3515c6c1daeSBarry Smith previous = next; 3525c6c1daeSBarry Smith next = next->next; 3535c6c1daeSBarry Smith ierr = PetscFree(previous);CHKERRQ(ierr); 3545c6c1daeSBarry Smith } 3550298fd71SBarry Smith vu->queue = NULL; 3565c6c1daeSBarry Smith vu->queueLength = 0; 3575c6c1daeSBarry Smith PetscFunctionReturn(0); 3585c6c1daeSBarry Smith } 359