Vector containing one number
Matthew Knepley
knepley at gmail.com
Thu Jan 18 17:12:04 CST 2007
Runs fine for me:
knepley at knepley-laptop:/PETSc3/petsc/petsc-dev/src/vec/vec/examples/tutorials$
$MPIRUN -np 4 ./ex1001 -vec_view
Process [0]
3
Process [1]
Process [2]
Process [3]
Matt
On 1/18/07, Berend van Wachem <berend at chalmers.se> wrote:
> 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.
>
>
--
One trouble is that despite this system, anyone who reads journals widely
and critically is forced to realize that there are scarcely any bars to eventual
publication. There seems to be no study too fragmented, no hypothesis too
trivial, no literature citation too biased or too egotistical, no design too
warped, no methodology too bungled, no presentation of results too
inaccurate, too obscure, and too contradictory, no analysis too self-serving,
no argument too circular, no conclusions too trifling or too unjustified, and
no grammar and syntax too offensive for a paper to end up in print. --
Drummond Rennie
More information about the petsc-users
mailing list