[petsc-dev] Avoid use of static in PETSc functions
Barry Smith
bsmith at mcs.anl.gov
Thu Nov 15 18:56:10 CST 2012
PetscInitialize() and PetscFinalize() are reentrant. These means that one can call them several times in the same program (one must call MPI_Int() and MPI_Finalize() explicitly outside of these calls.
This means that PetscFinalize() should leave the data in the code in an equivalent state as before the first PetscInitialize() is called.
I just spent a couple hours banging my head against the wall due to two static variables in a function placed there on the assumption that PETSc was not reentrant.
Please use static inside PETSc functions very carefully (if ever) and make sure they don't destroy the reentrancy.
Thanks
Barry
More information about the petsc-dev
mailing list