[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Vector containing one number



Hi,

In one of the input/output routines, I want to write one number to a viewer. I 
created a vector with global size one, wrote the number to the vector, and 
then viewed the vector. In the latest version of Petsc, this does not seem to 
work anymore. What do you suggest as a work around? Hereby an example code 
which crashes on more than 1 processor:

static char help[] = "Just a simple test";
#undef __FUNCT__
#define __FUNCT__ "main"
int main(int argc,char **args)
{
  Vec            Onevec;
  PetscInt       size,ierr;
  PetscScalar    var = 3.0;

  PetscInitialize(&argc,&args,(char *)0,help);
  ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
  ierr = VecCreateMPI(PETSC_COMM_WORLD, PETSC_DECIDE, 1, 
&Onevec);CHKERRQ(ierr);
  ierr = VecSetValue(Onevec, 0, var, INSERT_VALUES);
  CHKERRQ(ierr);
  ierr = VecAssemblyBegin(Onevec);
  CHKERRQ(ierr);
  ierr = VecAssemblyEnd(Onevec);
  CHKERRQ(ierr);

  VecDestroy(Onevec);
  ierr = PetscFinalize();CHKERRQ(ierr);
  return 0;
}

Thanks,

Berend.