On Jan 2, 2011, at 9:32 PM, Peter Wang wrote:
> I added VecView() in the ex2f.F to check the three vectors (u,b, and x) in
> the code.
>
> -----The vectors of u and b are same. BUt, the value of vector x is
> different with different processes. For example,
>
> with only 1 process, the vector x is:
>
> Process [0]
> 2.72322e-07
> 3.81437e-07
> 1.58922e-07
> 3.81437e-07
> 2.38878e-07
> -6.65645e-07
> 1.58922e-07
> -6.65645e-07
> -2.51219e-07
>
> with 2 processes, the vector is:
>
> Process [0]
> -1.11022e-16
> 0
> 2.22045e-16
> 2.22045e-16
> 0
>
> Process [1]
> 2.22045e-16
> 2.22045e-16
> 0
> 2.22045e-16
void PETSC_STDCALL kspbuildsolution_(KSP *ksp,Vec *v,Vec *V, int *ierr )
{
Vec vp = 0;
CHKFORTRANNULLOBJECT(v);
CHKFORTRANNULLOBJECT(V);
if (v) vp = *v;
*ierr = KSPBuildSolution(*ksp,vp,V);
}
void PETSC_STDCALL kspbuildresidual_(KSP *ksp,Vec *t,Vec *v,Vec *V, int *ierr
)
{
Vec tp = 0,vp = 0;
CHKFORTRANNULLOBJECT(t);
CHKFORTRANNULLOBJECT(v);
CHKFORTRANNULLOBJECT(V);
if (t) tp = *t;
if (v) vp = *v;
*ierr = KSPBuildResidual(*ksp,tp,vp,V);
}
Barry
x is computed in the code as the difference between the "exact" solution and
the "computed" solution. Since this example uses iterative solvers, which by
default do not compute the solution to full accuracy, the "error" will be
different for different number of processes. It is just a fluke that the error
is smaller with two processes instead of one.
>
> The example is supposed to get a vector x similar to u. Why the result is
> different with differnt number of processes used?
>
> ----Also, if the runtime option -my_ksp_monitor is used, there is a error
> showing:
>
> [0]PETSC ERROR:
> ------------------------------------------------------------------------
> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation,
> probably memory access out of range
>
> It seems there is something wrong with calling 'call
> KSPBuildSolution(ksp,PETSC_NULL_OBJECT,x,ierr)' in user defined function
> MyKSPMonitor().
>
> Any hints for this error? Thanks a lots.
Bug in our Fortran Interface for KSPBuildSolution() fortran interface in
that case. If you replace the two functions in
src/ksp/ksp/interface/ftn-custom/zitclf.c with the ones below and run make in
that directory this monitor routine will work.
>
>
>
>
>
>
>