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