I thought at some point that I maybe have the order of the arguments wrong...
The first few lines in particles_dcop_apply_petsc are: ! get ghosted versions of vectors CALL VecGhostGetLocalForm(from,xl,info) CALL VecSet(to,0.0_MK,info) ! get arrays from petsc vectors CALL VecGetArray(xl,xx,xxi,info) CALL VecGetArray(to,yy,yyi,info) CALL VecGetLocalSize(xl,xxn,info) CALL VecGetLocalSize(to,yyn,info) and its closed with: ! release petsc arrays CALL VecRestoreArray(xl,xx,xxi,info) CALL VecRestoreArray(to,yy,yyi,info) ! release local form of vectors CALL VecGhostRestoreLocalForm(from,xl,info)