Hi Michael, If you are trying to get all the values on the 0th processor, you can find that here:
https://urldefense.us/v3/__https://petsc.org/release/faq/*how-do-i-collect-to-a-single-processor-all-the-values-from-a-parallel-petsc-vec__;Iw!!G_uCfscf7eWS!YE1AKcuJN7bNqZse7mgrlZ2TiBVr-GkWaxPCs0X2sP7m8St0Fv3UcHfECEU62p_dEn1yhnnYvSA_xCw9OUgbw4iNOw$ Randy > On Jan 2, 2026, at 11:42 AM, Michael Whitten via petsc-users > <[email protected]> wrote: > > Hi PETSc mailing list users, > > I have managed to install PETSc and run some PETSc examples and little test > codes of my own in Fortran. I am now trying to make PETSc work with my > existing Fortran code. I have tried to build little test examples of the > functionality that I can then incorporate into my larger code base. However, > I am having trouble just passing vectors back and forth between PETSc and > Fortran. > > I have attached a minimum semi-working example that can be compiled with the > standard 'Makefile.user'. It throws an error when I try to copy the PETSc > vector back to a Fortran vector using VecGetValues(). I get that it can only > access values of the array on the local process but how do I fix this? Is > this even the right approach? > > In the final implementation I want to be able to assemble my matrix and > vector, convert them to PETSc data structures, use PETSc to solve, and then > convert the solution vector back to Fortran and return. I want to be able to > do this with both the linear and nonlinear solvers. It seems like this is > what PETSc is, in part, built to do. Is this a reasonable expectation to > achieve? Is this a reasonable use case for PETSc? > > Thanks in advance for any help you can offer. > > best, > Michael > <test.F90>
