1: 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";
3: #include <petscvec.h>
5: int main(int argc, char **args)
6: {
7: Vec b;
8: PetscViewer fd; /* viewer */
10: PetscFunctionBeginUser;
11: PetscCall(PetscInitialize(&argc, &args, NULL, help));
12: fd = PETSC_VIEWER_SOCKET_WORLD;
14: for (PetscInt i = 0; i < 1000; i++) {
15: PetscCall(VecCreate(PETSC_COMM_WORLD, &b));
16: PetscCall(VecLoad(b, fd));
17: PetscCall(VecView(b, fd));
18: PetscCall(VecDestroy(&b));
19: }
20: PetscCall(PetscFinalize());
21: return 0;
22: }