Actual source code: ex42a.c


  2: static char help[] = "Sends a PETSc vector to a socket connection, receives it back, within a loop. Works with ex42.c.\n";

  4: #include <petscvec.h>

  6: int main(int argc,char **args)
  7: {
  8:   Vec            b;
  9:   PetscViewer    fd;
 10:   PetscInt       i;

 12:   PetscInitialize(&argc,&args,(char*)0,help);
 13:   /* server indicates we WAIT for someone to connect to our socket */
 14:   PetscViewerSocketOpen(PETSC_COMM_WORLD,"server",PETSC_DEFAULT,&fd);

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