Vector containing one number
Berend van Wachem
berend at chalmers.se
Thu Jan 18 15:28:44 CST 2007
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.
More information about the petsc-users
mailing list