Again, I don't know the details here, but you specify the return type as ```PetscScalar``` and then return a double. If this might be a problem, pls fix it.