use of VecPlaceArray in parallel with fortran
Wienand Drenth
w.drenth at gmail.com
Tue Nov 10 03:21:48 CST 2009
> We are having some difficulty understanding your question and what
> exactly you want to do?
Hello Barry,
Apologies I am a bit unclear. I am relatively new to PetSc and the
proper terminology, so thank you for your time and help.
Currently we have a two Fortran arrays B and X, being the
righthandside and solution vector. There are no special considerations
to have this array on just one processor. So, if I am not mistaken,
when I run the program on multiple processors, each processor will
have the entire Fortran array and not just part of it.
In order to solve the system iteratively, we make calls
VecPlaceArray(M_X, X, ierr)
to place the Fortran array into the PetSc Vector M_X.
Then we call KSPSolve.
After the solve, we don't care for the PetSc vectors anymore, but
continue with the Fortran arrays (X and B) in our further
calculations.
Right know, when running in the above setting it will not function
correctly when run on multiple processors. Henceforth my question on
how to tackle this and adapt the code to run it in parallel.
Would the following procedure lead to a correct and working solution:
Suppose I have a Fortran array X, and I create on processor zero a
sequential PetSc vector MS_X and place the array X into MS_X using
VecPlaceArray. With VecScatterCreaterToZero, and SCATTER_REVERSE as
scatter mode I can spread it onto the global (parallel) vector M_X.
After my calculations, I can do the same to scatter the parallel
solution onto my sequential vector MS_X (now with SCATTER_FORWARD),
and continue afterwards with X.
Regards,
Wienand
--
Wienand Drenth PhD
Eindhoven, the Netherlands
More information about the petsc-users
mailing list