[petsc-users] bug in fortran interface KSPBuildSolution

Barry Smith bsmith at mcs.anl.gov
Wed Feb 17 14:18:19 CST 2010


      Thanks for reporting that problem. Unfortunately for handling  
null objects from Fortran we need to manually write the Fortran stubs  
and we had never written them for this function. I have updated petsc- 
dev to handle this properly by providing the manually written stub.

    Thanks again,


On Feb 17, 2010, at 11:55 AM, Stephan Kramer wrote:

> 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