<p>Look at the man page for VecView, it needs a PetscViewer argument.</p>
<div class="gmail_quote">On Apr 22, 2012 2:19 PM, &quot;TAY wee-beng&quot; &lt;<a href="mailto:zonexo@gmail.com">zonexo@gmail.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <br>
    I have attached the ex22f.F file. The changes I added are given in
    bold:<br>
    <br>
    ...<br>
    <br>
    PetscErrorCode   ierr<br>
          DM               da<br>
          KSP              ksp<br>
         <b> Vec              x,b</b><br>
          external         ComputeRHS,ComputeMatrix<br>
    <br>
    ....<br>
    <br>
    call KSPSetUp(ksp,ierr)<br>
          call KSPSolve(ksp,PETSC_NULL_OBJECT,PETSC_NULL_OBJECT,ierr)<br>
          <b>call KSPGetSolution(ksp,x,ierr)<br>
            call VecView(x,ierr)</b><br>
          call KSPDestroy(ksp,ierr)<br>
          call DMDestroy(da,ierr)<br>
    <br>
    The error is:<br>
    <br>
    [0]PETSC ERROR:
    ------------------------------------------------------------------------<br>
    [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation
    Violation, probably memory access out of range<br>
    [0]PETSC ERROR: Try option -start_in_debugger or
    -on_error_attach_debugger<br>
    [0]PETSC ERROR: or see
    <a href="http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind</a>[0]PETSC
    ERROR: or try <a href="http://valgrind.org" target="_blank">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to
    find memory corruption errors<br>
    [0]PETSC ERROR: likely location of problem given in stack below<br>
    [0]PETSC ERROR: ---------------------  Stack Frames
    ------------------------------------<br>
    [0]PETSC ERROR: Note: The EXACT line numbers in the stack are not
    available,<br>
    [0]PETSC ERROR:       INSTEAD the line number of the start of the
    function<br>
    [0]PETSC ERROR:       is given.<br>
    [0]PETSC ERROR: [0] VecView line 735
    /home/wtay/Codes/petsc-3.2-p5/src/vec/vec/interface/vector.c<br>
    [0]PETSC ERROR: --------------------- Error Message
    ------------------------------------<br>
    [0]PETSC ERROR: Signal received!<br>
    [0]PETSC ERROR:
    ------------------------------------------------------------------------<br>
    [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat Oct 29
    13:45:54 CDT 2011 <br>
    [0]PETSC ERROR: See docs/changes/index.html for recent updates.<br>
    [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.<br>
    [0]PETSC ERROR: See docs/index.html for manual pages.<br>
    [0]PETSC ERROR:
    ------------------------------------------------------------------------<br>
    [0]PETSC ERROR: ./ex22f on a arch-linu named hpc12 by wtay Sun Apr
    22 21:11:39 2012<br>
    [0]PETSC ERROR: Libraries linked from
    /home/wtay/Lib/petsc-3.2-p5_mumps_debug/lib<br>
    [0]PETSC ERROR: Configure run at Sun Nov 27 15:39:26 2011<br>
    [0]PETSC ERROR: Configure options --with-mpi-dir=/opt/openmpi-1.5.3/
    --with-blas-lapack-dir=/opt/intel_xe_2011/mkl/lib/intel64/
    --with-debugging=1 --download-hypre=1
    --prefix=/home/wtay/Lib/petsc-3.2-p5_mumps_debug COPTFLAGS=-O0
    FOPTFLAGS=-O0 --download-mumps=1 --download-parmetis=1
    --download-scalapack=1 --download-blacs=1<br>
    [0]PETSC ERROR:
    ------------------------------------------------------------------------<br>
    [0]PETSC ERROR: User provided function() line 0 in unknown directory
    unknown file<br>
--------------------------------------------------------------------------<br>
    MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD <br>
    with errorcode 59.<br>
    <br>
    NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.<br>
    You may or may not see output from other processes, depending on<br>
    exactly when Open MPI kills them.<br>
    <br>
    <pre cols="72">Yours sincerely,

TAY wee-beng</pre>
    <br>
    On 22/4/2012 9:06 PM, Jed Brown wrote:
    <blockquote type="cite">
      <p>Run in a debugger and/or use --with-debugging=1 so that the
        error trace has more information. You could also show us the
        exact code that you used.</p>
      <div class="gmail_quote">On Apr 22, 2012 2:03 PM, &quot;TAY wee-beng&quot;
        &lt;<a href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>&gt;
        wrote:<br type="attribution">
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000"> Hi,<br>
            <br>
            I added &quot;Vec x,b&quot; after &quot;KSP ksp&quot;<br>
            and then &quot;call KSPGetSolution(ksp, x, ierr)&quot;<br>
            <br>
            I wanted to see the output so I added &quot;call VecView(x,ierr)&quot;
            but I got this error:<br>
            <br>
            [0]PETSC ERROR:
            ------------------------------------------------------------------------<br>
            [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation
            Violation, probably memory access out of range<br>
            [0]PETSC ERROR: Try option -start_in_debugger or
            -on_error_attach_debugger<br>
            [0]PETSC ERROR: or see <a href="http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind" target="_blank">http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#valgrind</a>[0]PETSC

            ERROR: or try <a href="http://valgrind.org" target="_blank">http://valgrind.org</a>
            on GNU/linux and Apple Mac OS X to find memory corruption
            errors<br>
            [0]PETSC ERROR: configure using --with-debugging=yes,
            recompile, link, and run <br>
            [0]PETSC ERROR: to get more information on the crash.<br>
            [0]PETSC ERROR: --------------------- Error Message
            ------------------------------------<br>
            [0]PETSC ERROR: Signal received!<br>
            [0]PETSC ERROR:
            ------------------------------------------------------------------------<br>
            [0]PETSC ERROR: Petsc Release Version 3.2.0, Patch 5, Sat
            Oct 29 13:45:54 CDT 2011 <br>
            [0]PETSC ERROR: See docs/changes/index.html for recent
            updates.<br>
            [0]PETSC ERROR: See docs/faq.html for hints about trouble
            shooting.<br>
            [0]PETSC ERROR: See docs/index.html for manual pages.<br>
            [0]PETSC ERROR:
            ------------------------------------------------------------------------<br>
            [0]PETSC ERROR: ./ex22f on a arch-linu named hpc12 by wtay
            Sun Apr 22 21:02:14 2012<br>
            [0]PETSC ERROR: Libraries linked from
            /home/wtay/Lib/petsc-3.2-p5_mumps_rel/lib<br>
            [0]PETSC ERROR: Configure run at Sun Nov 27 15:18:15 2011<br>
            [0]PETSC ERROR: Configure options
            --with-mpi-dir=/opt/openmpi-1.5.3/
            --with-blas-lapack-dir=/opt/intel_xe_2011/mkl/lib/intel64/
            --with-debugging=0 --download-hypre=1
            --prefix=/home/wtay/Lib/petsc-3.2-p5_mumps_rel COPTFLAGS=-O3
            FOPTFLAGS=-O3 --download-mumps=1 --download-parmetis=1
            --download-scalapack=1 --download-blacs=1<br>
            [0]PETSC ERROR:
            ------------------------------------------------------------------------<br>
            [0]PETSC ERROR: User provided function() line 0 in unknown
            directory unknown file<br>
--------------------------------------------------------------------------<br>
            MPI_ABORT was invoked on rank 0 in communicator
            MPI_COMM_WORLD <br>
            with errorcode 59.<br>
            <br>
            <br>
            <pre cols="72">Yours sincerely,

TAY wee-beng</pre>
            <br>
            On 22/4/2012 2:53 PM, Matthew Knepley wrote:
            <blockquote type="cite">On Sun, Apr 22, 2012 at 3:31 AM, TAY
              wee-beng <span dir="ltr">&lt;<a href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>&gt;</span>
              wrote:<br>
              <div class="gmail_quote">
                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div bgcolor="#FFFFFF" text="#000000"> Hi,<br>
                    <br>
                    I am using petsc-dev 2012-04-20.<br>
                    <br>
                    Btw, I&#39;m referring to :<br>
                    <br>
                    <a href="http://www.mcs.anl.gov/petsc/petsc-dev/src/ksp/ksp/examples/tutorials/ex22f.F.html" target="_blank">http://www.mcs.anl.gov/petsc/petsc-dev/src/ksp/ksp/examples/tutorials/ex22f.F.html</a><br>
                    <br>
                    Part of the code is :<br>
                    <br>
                    <pre>call KSPSetFromOptions(ksp,ierr)
      call KSPSetUp(ksp,ierr)
      call KSPSolve(ksp,PETSC_NULL_OBJECT,PETSC_NULL_OBJECT,ierr)
      call KSPDestroy(ksp,ierr)
      call DMDestroy(da,ierr)
      call PetscFinalize(ierr)</pre>
                    <br>
                    <br>
                    Unlike other codes like ex29c or ex45c, there isn&#39;t
                    a &quot;call KSPGetSolution(ksp,x,ierr)&quot;<br>
                  </div>
                </blockquote>
                <div><br>
                </div>
                <div>You need to declare &quot;Vec x&quot;, and then you can call
                  KSPGetSolution(ksp, x, ierr)</div>
                <div><br>
                </div>
                <div>   Matt</div>
                <div> </div>
                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  <div bgcolor="#FFFFFF" text="#000000"> Also I want to
                    add &quot;call VecView(x,ierr)&quot; to print out the results,
                    which is usally added after the above.<br>
                    <br>
                    Thank you<br>
                    <pre cols="72">Yours sincerely,

TAY wee-beng</pre>
                    <br>
                    On 22/4/2012 1:14 AM, Matthew Knepley wrote:
                    <blockquote type="cite">On Sat, Apr 21, 2012 at 6:31
                      PM, TAY wee-beng <span dir="ltr">&lt;<a href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>&gt;</span>
                      wrote:<br>
                      <div class="gmail_quote">
                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Hi,<br>
                          <br>
                          May I know if ex22f is complete? I can&#39;t find
                          :<br>
                          <br>
                          call KSPGetSolution(ksp,x,ierr)<br>
                          <br>
                          If I entered it, it says x not found.<br>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>This is correct in petsc-dev. What version
                          are you using?</div>
                        <div><br>
                        </div>
                        <div>  Thanks,</div>
                        <div><br>
                        </div>
                        <div>    Matt</div>
                        <div> </div>
                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> Thank you!<span><font color="#888888"><span><font color="#888888"><br>
                                  <br>
                                  -- <br>
                                  Yours sincerely,<br>
                                  <br>
                                  TAY wee-beng<br>
                                  <br>
                                </font></span></font></span></blockquote>
                        <span><font color="#888888"> </font></span></div>
                      <span><font color="#888888"> <br>
                          <br clear="all">
                          <div><br>
                          </div>
                          -- <br>
                          What most experimenters take for granted
                          before they begin their experiments is
                          infinitely more interesting than any results
                          to which their experiments lead.<br>
                          -- Norbert Wiener<br>
                        </font></span></blockquote>
                  </div>
                </blockquote>
              </div>
              <br>
              <br clear="all">
              <div><br>
              </div>
              -- <br>
              What most experimenters take for granted before they begin
              their experiments is infinitely more interesting than any
              results to which their experiments lead.<br>
              -- Norbert Wiener<br>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </div>

</blockquote></div>