In one of my PETSc programs, I need a processor to access values from another processor.
So in the PETSc FAQ's this issue has been briefly addressed here. To create a local vector, I tried this
Vec local;
ierr = VecCreateSeq(PETSC_COMM_WORLD,10,&local);CHKERRQ(ierr);
where 10 is the size of the local vector I wish to create. But running with 2 processors gives me an error
[0]PETSC ERROR: --------------------- Error Message ------------------------------------
[0]PETSC ERROR: Invalid argument!
[0]PETSC ERROR: Cannot create VECSEQ on more than one process!
[0]PETSC ERROR: ------------------------------------------------------------------------
So to be more precise,
I would like to write a toy code where I want to add all elements from a big vector v
which is spread across n processors.
I would like to do this
by gathering all elements from v
onto a vector local to Process 0
and add them all up.
Also more generally how would Process 0 get elements from any specific processor
say processor i