2: static char help[] = "Reads a PETSc vector from a socket connection, then sends it back within a loop 1000 times. Works with ex42.m or ex42a.c\n"; 4: #include <petscvec.h> 6: int main(int argc, char **args) 7: { 8: Vec b; 9: PetscViewer fd; /* viewer */ 10: PetscInt i; 12: PetscFunctionBeginUser; 13: PetscCall(PetscInitialize(&argc, &args, (char *)0, help)); 14: fd = PETSC_VIEWER_SOCKET_WORLD; 16: for (i = 0; i < 1000; i++) { 17: PetscCall(VecCreate(PETSC_COMM_WORLD, &b)); 18: PetscCall(VecLoad(b, fd)); 19: PetscCall(VecView(b, fd)); 20: PetscCall(VecDestroy(&b)); 21: } 22: PetscCall(PetscFinalize()); 23: return 0; 24: }