more robust detection of PetscInt and PetscScalar types