Date: 2021-03-03T22:25:59+00:00

Actual source code: ex42a.c
petsc-3.14.5 2021-03-03
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>

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

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

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