Actual source code: ex42.c

      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 */
      9:   PetscInt    i;

     11:   PetscFunctionBeginUser;
     12:   PetscCall(PetscInitialize(&argc, &args, NULL, help));
     13:   fd = PETSC_VIEWER_SOCKET_WORLD;

     15:   for (i = 0; i < 1000; i++) {
     16:     PetscCall(VecCreate(PETSC_COMM_WORLD, &b));
     17:     PetscCall(VecLoad(b, fd));
     18:     PetscCall(VecView(b, fd));
     19:     PetscCall(VecDestroy(&b));
     20:   }
     21:   PetscCall(PetscFinalize());
     22:   return 0;
     23: }