Actual source code: ex1.c
petsc-3.12.4 2020-02-04
Report Typos and Errors

      2: static char help[] = "Tests repeated VecSetType().\n\n";

      4:  #include <petscvec.h>

      6: int main(int argc,char **argv)
      7: {
      9:   PetscInt       n   = 5;
     10:   PetscScalar    one = 1.0,two = 2.0;
     11:   Vec            x,y;

     13:   PetscInitialize(&argc,&argv,(char*)0,help);if (ierr) return ierr;

     15:   /* create vector */
     16:   VecCreate(PETSC_COMM_SELF,&x);
     17:   VecSetSizes(x,n,PETSC_DECIDE);
     18:   VecSetType(x,"mpi");
     19:   VecSetType(x,"seq");
     20:   VecDuplicate(x,&y);
     21:   VecSetType(x,"mpi");

     23:   VecSet(x,one);
     24:   VecSet(y,two);

     26:   VecDestroy(&x);
     27:   VecDestroy(&y);

     29:   PetscFinalize();
     30:   return ierr;
     31: }

     33: /*TEST

     35:      test:
     36:        suffix: 1

     38:      test:
     39:        suffix: 2
     40:        nsize: 2

     42: TEST*/