[petsc-users] bug in fortran interface KSPBuildSolution

Stephan Kramer s.kramer at imperial.ac.uk
Wed Feb 17 11:55:51 CST 2010


Hi all,

Just a small bug I came across in calling KSPBuildSolution from fortran. I was calling it in the following way:

call KSPBuildSolution(ksp, x, PETSC_NULL_OBJECT, ierr)

i.e. I'm asking it to copy it in my vector x. However as the *V argument (the second vector) gets passed on unchecked in kspbuildsolution_() in itfuncf.c to kspbuildsolution(),
it gets passed the address of PETSC_NULL_OBJECT (somewhere in the fortran common block) and thinks I've passed it a proper pointer to a vector,
and copies the address of x also into PETSC_NULL_OBJECT, i.e. it clobbers PETSC_NULL_OBJECT in fortran. Obvious solution for me was to provide it an arbitrary second vector y instead of 
PETSC_NULL_OBJECT, but it took me a while before realizing my crash later on was due to my PETSC_NULL_OBJECT no longer being zero.

Cheers
Stephan


More information about the petsc-users mailing list