Actual source code: ex42a.c

petsc-3.5.0 2014-06-30
Report Typos and Errors
  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>

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

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

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