<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <br>
    I have modified the C version of the ex29 example in ksp to Fortran.
    I have attached it. Feel free to include it in the distribution of
    PETSc.<br>
    <br>
    The DMDAVecGetArrayF90 and DMDAVecRestoreArrayF90 are not working in
    linux with ifort, so VecSetValues was used. Worked in VS2008 though.<br>
    <br>
    Btw, I need to solve the Poisson equation multiple times using
    different RHS vector. <br>
    <br>
    Which subroutines do I need to call only once?<br>
    <br>
    Can I also add :<br>
    <br>
    call MatSetOption(jac,MAT_STRUCTURALLY_SYMMETRIC,PETSC_TRUE,ierr)<br>
    <br>
    call MatSetOption(jac,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE,ierr)<br>
    <br>
    call MatSetOption(jac,MAT_NEW_NONZERO_LOCATIONS,PETSC_FALSE,ierr)<br>
      <br>
    call KSPSetOperators(ksp,A_mat,A_mat,SAME_NONZERO_PATTERN,ierr)<br>
    <pre class="moz-signature" cols="72">Yours sincerely,

TAY wee-beng</pre>
    <br>
    On 11/5/2012 4:04 PM, John Mousel wrote:
    <blockquote
cite="mid:CA+zegpm5Ca=6rKMBEjQ3vJZM0hCvMyor1BF2Re27Hb_vHwCRRg@mail.gmail.com"
      type="cite">Include both header files. <br>
      <br>
      #include <finclude/petscdmda.h><br>
      #include <finclude/petscdmda.h90><br>
      <br>
      The h90 header only includes the interface definitions for
      Fortran.<br>
      <br>
      John<br>
      <br>
      <div class="gmail_quote">On Fri, May 11, 2012 at 8:51 AM, TAY
        wee-beng <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor="#FFFFFF" text="#000000">
            <div class="im"> <br>
              <br>
              On 11/5/2012 3:30 PM, Matthew Knepley wrote:
              <blockquote type="cite">On Fri, May 11, 2012 at 9:24 AM,
                TAY wee-beng <span dir="ltr"><<a
                    moz-do-not-send="true"
                    href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></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 have been using the GUI environment to do
                      debugging so I am a bit reluctant to learn
                      Valgrind as its outputs seems a bit daunting. 
                      But I guess John is right. I've been spending
                      these few days learning bit by bit.<br>
                      <br>
                      I realised that the error occurs in computerhs,
                      at:<br>
                    </div>
                  </blockquote>
                  <div><br>
                  </div>
                  <div>I bet this is a beautiful Fortranism. Do you
                    include the F90 header file with the interface
                    definition?</div>
                  <div>If not, Fortran just craps out like this. I can't
                    stress enough how much time would be saved by</div>
                  <div>switching languages to something with at least a
                    modicum of error checking.</div>
                </div>
              </blockquote>
              <br>
            </div>
            I initially used:<br>
            <br>
            #include "finclude/petsc.h90"<br>
            <br>
            Compilation and linking was fine in Linux and vs2008.<br>
            <br>
            Now I changed it to what ex22.F was using :<br>
            <br>
            #include <finclude/petscsys.h><br>
            #include <finclude/petscvec.h><br>
            #include <finclude/petscmat.h><br>
            #include <finclude/petscpc.h><br>
            #include <finclude/petscksp.h><br>
            #include <finclude/petscdmda.h><br>
            <br>
            Compiling was ok but linking failed in Linux and VS2008: <br>
            <br>
            undefined reference to `dmdavecgetarrayf90_'<br>
            <br>
            I tried changing #include <finclude/petscdmda.h> to
            #include <finclude/petscdmda.h90> and everything was
            ok in VS2008 again, giving the right answers.<br>
            <br>
            However, in Linux, I got the following error:<br>
            <br>
            [wtay@hpc12:tutorials]$ /opt/openmpi-1.5.3/bin/mpif90 -c 
            -fPIC -g  
            -I/home/wtay/Lib/petsc-3.2-dev_shared_debug/include
            -I/home/wtay/Lib/petsc-3.2-dev_shared_debug/include
            -I/opt/openmpi-1.5.3/include    -o ex29f.o ex29f.F90<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(25):




            error #5082: Syntax error, found '::' when expecting one of:
            ( % : . = =><br>
                    DMDABoundaryType :: pt<br>
            -------------------------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(26):




            error #5082: Syntax error, found '::' when expecting one of:
            ( % : . = =><br>
                    DMDAStencilType  :: st<br>
            -------------------------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(25):




            error #6590: This statement is not permitted as a statement
            within a derived-type-def<br>
                    DMDABoundaryType :: pt<br>
            --------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(26):




            error #6590: This statement is not permitted as a statement
            within a derived-type-def<br>
                    DMDAStencilType  :: st<br>
            --------^<br>
            ex29f.F90(68): error #6404: This name does not have a type,
            and must have an explicit type.   [DMDA_BOUNDARY_NONE]<br>
            call
DMDACreate2d(PETSC_COMM_WORLD,DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,i3,i3,PETSC_DECIDE,PETSC_DECIDE,i1,i1,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da,ierr)<br>
            -----------------------------------^<br>
            ex29f.F90(68): error #6404: This name does not have a type,
            and must have an explicit type.   [DMDA_STENCIL_STAR]<br>
            call
DMDACreate2d(PETSC_COMM_WORLD,DMDA_BOUNDARY_NONE,DMDA_BOUNDARY_NONE,DMDA_STENCIL_STAR,i3,i3,PETSC_DECIDE,PETSC_DECIDE,i1,i1,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da,ierr)<br>
-------------------------------------------------------------------------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(25):




            error #5082: Syntax error, found '::' when expecting one of:
            ( % : . = =><br>
                    DMDABoundaryType :: pt<br>
            -------------------------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(26):




            error #5082: Syntax error, found '::' when expecting one of:
            ( % : . = =><br>
                    DMDAStencilType  :: st<br>
            -------------------------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(25):




            error #6590: This statement is not permitted as a statement
            within a derived-type-def<br>
                    DMDABoundaryType :: pt<br>
            --------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(26):




            error #6590: This statement is not permitted as a statement
            within a derived-type-def<br>
                    DMDAStencilType  :: st<br>
            --------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(25):




            error #5082: Syntax error, found '::' when expecting one of:
            ( % : . = =><br>
                    DMDABoundaryType :: pt<br>
            -------------------------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(26):




            error #5082: Syntax error, found '::' when expecting one of:
            ( % : . = =><br>
                    DMDAStencilType  :: st<br>
            -------------------------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(25):




            error #6590: This statement is not permitted as a statement
            within a derived-type-def<br>
                    DMDABoundaryType :: pt<br>
            --------^<br>
            /home/wtay/Lib/petsc-3.2-dev_shared_debug/include/finclude/ftn-custom/petscdmda.h90(26):




            error #6590: This statement is not permitted as a statement
            within a derived-type-def<br>
                    DMDAStencilType  :: st<br>
            <br>
            Is there some errors in petscdmda.h90?
            <div>
              <div class="h5"><br>
                <br>
                <br>
                <blockquote type="cite">
                  <div class="gmail_quote">
                    <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"> <b>call
                          DMDAVecRestoreArrayF90(da,b,array,ierr)</b><br>
                        <br>
                        ==27464== Invalid write of size 8<br>
                        ==27464==    at 0x402835: computerhs_
                        (ex29f.F90:119)<br>
                        ==27464==  Address 0xfffffffffffffef0 is not
                        stack'd, malloc'd or (recently) free'd<br>
                        ==27464== <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
                          moz-do-not-send="true"
                          href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind"
                          target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind</a>[0]PETSC





                        ERROR: or try <a moz-do-not-send="true"
                          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] DM user function line 0
                        unknownunknown<br>
                        [0]PETSC ERROR: [0] DMComputeFunction line 2085
                        /home/wtay/Codes/petsc-dev/src/dm/interface/dm.c<br>
                        [0]PETSC ERROR: [0] KSPSetUp line 182
                        /home/wtay/Codes/petsc-dev/src/ksp/ksp/interface/itfunc.c<br>
                        [0]PETSC ERROR: --------------------- Error
                        Message ------------------------------------<br>
                        [0]PETSC ERROR: Signal received!<br>
                        <br>
                        I have checked that "array" 's values are
                        correct. This statement executed without
                        problems in VS2008. If I replace the above with
                        something like:<br>
                        <br>
                        <b>call VecSet(b,Hy,ierr)</b><br>
                        <br>
                        Everything is fine in Linux.<br>
                        <br>
                        Is there something wrong with <b>DMDAVecRestoreArrayF90</b>?<br>
                        <br>
                        My code in the area is:<br>
                        <br>
                        call
DMDAGetCorners(da,xs,ys,PETSC_NULL_INTEGER,xm,ym,PETSC_NULL_INTEGER,ierr)<br>
                        <br>
                        call DMDAVecGetArrayF90(da,b,array,ierr)<br>
                        <br>
                        do j = ys,ys+ym-1<br>
                        <br>
                            do i = xs,xs+xm-1<br>
                        <br>
                                array(i,j) =
                        exp(-(i*Hx)*(i*Hx)/nu)*exp(-(j*Hy)*(j*Hy)/nu)*Hx*Hy<br>
                        <br>
                            end do<br>
                        <br>
                        end do<br>
                        <br>
                        call DMDAVecRestoreArrayF90(da,b,array,ierr)<br>
                        <br>
                        call VecAssemblyBegin(b,ierr)<br>
                        <br>
                        call VecAssemblyEnd(b,ierr)<br>
                        <br>
                        <br>
                        <pre cols="72">Yours sincerely,

TAY wee-beng</pre>
                        <br>
                        On 8/5/2012 9:41 PM, John Mousel wrote:
                        <blockquote type="cite">TAY wee-bing,<br>
                          <br>
                          If you want to be a programmer that writes
                          interesting and reliable code, you need to be
                          willing to use the tools of the trade. I can't
                          think of a bigger time-saver than Valgrind. I
                          would suggest that you learn to use it and use
                          it a lot. I bet it will lead you to the root
                          of your problem pretty quickly.<br>
                          <br>
                          John<br>
                          <br>
                          <div class="gmail_quote">On Tue, May 8, 2012
                            at 2:17 PM, TAY wee-beng <span dir="ltr"><<a
                                moz-do-not-send="true"
                                href="mailto:zonexo@gmail.com"
                                target="_blank">zonexo@gmail.com</a>></span>
                            wrote:<br>
                            <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 compiled and run my code under visual
                                studio 2008 with intel fortran.
                                Everything works ok.<br>
                                <br>
                                However, when I tried to run the code in
                                linux, I got the error as below. The
                                error happens when KSPSetUp(ksp,ierr) is
                                called.<br>
                                <br>
                                However, I am not able to print VecView
                                or MatView to view if there's any
                                errors. Is there any recommendation for
                                debugging? I hope I do not need to
                                valgrind if possible.<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
                                  moz-do-not-send="true"
                                  href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind"
                                  target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind</a>[0]PETSC






                                ERROR: or try <a moz-do-not-send="true"
                                  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] DM user function
                                line 0 unknownunknown<br>
                                [0]PETSC ERROR: [0] DMComputeFunction
                                line 2085
                                /home/wtay/Codes/petsc-dev/src/dm/interface/dm.c<br>
                                [0]PETSC ERROR: [0] KSPSetUp line 182
                                /home/wtay/Codes/petsc-dev/src/ksp/ksp/interface/itfunc.c<br>
                                [0]PETSC ERROR: ---------------------
                                Error Message
                                ------------------------------------<br>
                                [0]PETSC ERROR: Signal received!<br>
                                [0]PETSC ERROR:
                                ------------------------------------------------------------------------<br>
                                [0]PETSC ERROR: Petsc Development HG
                                revision:
                                7ecdd63ec420b1659b960e65d96e822c5ac1a968 
                                HG Date: Mon May 07 21:42:26 2012 -0500<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: ./ex29f on a petsc-3.2
                                named hpc12 by wtay Tue May  8 20:45:42
                                2012<br>
                                [0]PETSC ERROR: Libraries linked from
                                /home/wtay/Lib/petsc-3.2-dev_shared_debug/lib<br>
                                [0]PETSC ERROR: Configure run at Tue
                                May  8 10:47:59 2012<br>
                                [0]PETSC ERROR: Configure options
                                --with-mpi-dir=/opt/openmpi-1.5.3/
                                --with-blas-lapack-dir=/opt/intelcpro-11.1.059/mkl/lib/em64t/
                                --with-debugging=1 --download-hypre=1
                                --prefix=/home/wtay/Lib/petsc-3.2-dev_shared_debug
                                --known-mpi-shared=1
                                --with-shared-libraries<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 5/5/2012 1:43 AM, Matthew Knepley
                                wrote:
                                <blockquote type="cite">
                                  <div class="gmail_extra">On Fri, May
                                    4, 2012 at 5:42 PM, TAY wee-beng <span
                                      dir="ltr"><<a
                                        moz-do-not-send="true"
                                        href="mailto:zonexo@gmail.com"
                                        target="_blank">zonexo@gmail.com</a>></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 wonder if you people are
                                          interested to include my ex29
                                          fortran version in the petsc
                                          examples, which can help
                                          people who are using fortran.<br>
                                        </div>
                                      </blockquote>
                                      <div><br>
                                      </div>
                                      <div>Yes, we will definitely
                                        include it. Please send the
                                        source, and a representative
                                        output with run options.</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">
                                        <div bgcolor="#FFFFFF"
                                          text="#000000"> Thanks.<br>
                                          <pre cols="72">Yours sincerely,

TAY wee-beng</pre>
                                          <br>
                                          On 4/5/2012 9:28 PM, Matthew
                                          Knepley wrote:
                                          <blockquote type="cite">
                                            <div class="gmail_extra">On
                                              Fri, May 4, 2012 at 3:24
                                              PM, TAY wee-beng <span
                                                dir="ltr"><<a
                                                  moz-do-not-send="true"
href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></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">
                                                  <br>
                                                  On 4/5/2012 9:16 PM,
                                                  Barry Smith wrote:<br>
                                                  <blockquote
                                                    class="gmail_quote"
                                                    style="margin:0 0 0
                                                    .8ex;border-left:1px
                                                    #ccc
                                                    solid;padding-left:1ex">
                                                       Do an hg pull
                                                    and then run make in
src/mat/interface/ftn-custom/<br>
                                                    <br>
                                                        Then it should
                                                    link.<br>
                                                    <br>
                                                       Barry<br>
                                                    <br>
                                                       There was a E
                                                    missing from the all
                                                    caps name of the
                                                    function.<br>
                                                  </blockquote>
                                                  After hg pull, I did:<br>
                                                  <br>
                                                  cd
                                                  src//mat/interface/ftn-custom/<br>
                                                  <br>
                                                  User@User-PC
                                                  /cygdrive/c/temp/petsc-dev/src/mat/interface/ftn-custom<br>
                                                  $ make<br>
                                                  make[1]: Warning: File
                                                  `/cygdrive/c/temp/petsc-dev/petsc-3.2-dev_win32_vs2008/lib/libpetsc.lib(zmatregf.o)'







                                                  has modification time
                                                  787 s in the future<br>
                                                  make[1]: Nothing to be
                                                  done for `libc'.<br>
                                                  make[1]: warning:
                                                   Clock skew detected.
                                                   Your build may be
                                                  incomplete.<br>
                                                  <br>
                                                  But it still can't
                                                  work.<br>
                                                </blockquote>
                                                <div><br>
                                                </div>
                                                <div>Something is messed
                                                  up with the clock on
                                                  this machine.</div>
                                                <div><br>
                                                </div>
                                                <div>HOWEVER,
                                                  development requires
                                                  certain basic skills
                                                  in order to debug your
                                                  work. We</div>
                                                <div>cannot be the ones
                                                  debugging your code.
                                                  Now</div>
                                                <div><br>
                                                </div>
                                                <div>  nm
                                                  $PETSC_ARCH/lib/libpetsc.a
                                                  | grep -i
                                                  MatNullSpaceRemove</div>
                                                <div><br>
                                                </div>
                                                <div> will look for the
                                                  symbol.</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">
                                                  <blockquote
                                                    class="gmail_quote"
                                                    style="margin:0 0 0
                                                    .8ex;border-left:1px
                                                    #ccc
                                                    solid;padding-left:1ex">
                                                    <br>
                                                    <br>
                                                    On May 4, 2012, at
                                                    2:11 PM, Matthew
                                                    Knepley wrote:<br>
                                                    <br>
                                                    <blockquote
                                                      class="gmail_quote"
                                                      style="margin:0 0
                                                      0
                                                      .8ex;border-left:1px
                                                      #ccc
                                                      solid;padding-left:1ex">
                                                      On Fri, May 4,
                                                      2012 at 3:01 PM,
                                                      TAY wee-beng<<a
moz-do-not-send="true" href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>>






                                                       wrote:<br>
                                                      <br>
                                                      On 4/5/2012 5:17
                                                      PM, Matthew
                                                      Knepley wrote:<br>
                                                      <blockquote
                                                        class="gmail_quote"
                                                        style="margin:0
                                                        0 0
                                                        .8ex;border-left:1px
                                                        #ccc
                                                        solid;padding-left:1ex">
                                                        On Fri, May 4,
                                                        2012 at 11:05
                                                        AM, TAY
                                                        wee-beng<<a
                                                          moz-do-not-send="true"
href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>>
                                                         wrote:<br>
                                                        <br>
                                                        On 4/5/2012 3:05
                                                        PM, Matthew
                                                        Knepley wrote:<br>
                                                        <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0



                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">
                                                          On Fri, May 4,
                                                          2012 at 8:59
                                                          AM, TAY
                                                          wee-beng<<a
moz-do-not-send="true" href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>>






                                                           wrote:<br>
                                                          <br>
                                                          Hi,<br>
                                                          <br>
                                                          Is there
                                                          anything else
                                                          I can try to
                                                          get it working
                                                          right?<br>
                                                          <br>
                                                          The
                                                          MatGetNullSpaceRemove()
                                                          is missing.<br>
                                                        </blockquote>
                                                        Where should I
                                                        add
                                                        MatGetNullSpaceRemove
                                                        and what are its
                                                        syntax? I
                                                        googled but
                                                        there's no
                                                        results.<br>
                                                        <br>
                                                        Fixed in
                                                        p;etsc-dev:<br>
                                                        <br>
                                                          <a
                                                          moz-do-not-send="true"
href="http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatNullSpaceRemove.html"
target="_blank">http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatNullSpaceRemove.html</a><br>
                                                      </blockquote>
                                                      I just compiled
                                                      the updated
                                                      petsc-dev but I
                                                      got the same error
                                                      msg when I use:<br>
                                                      <br>
                                                      call
                                                      MatNullSpaceRemove(nullspace,b,PETSC_NULL,ierr)<br>
                                                      <br>
                                                      error LNK2019:
                                                      unresolved
                                                      external symbol
                                                      MATNULLSPACEREMOVE
                                                      referenced in
                                                      function
                                                      COMPUTERHS<br>
                                                      1>c:\obj_tmp\ex29f\Debug\ex29f.exe





                                                      : fatal error
                                                      LNK1120: 1
                                                      unresolved
                                                      externals<br>
                                                      <br>
                                                      That function is
                                                      in:<br>
                                                      <br>
                                                       
                                                      src/mat/interface/ftn-custom/zmatrixf.c<br>
                                                      <br>
                                                      Did that compile?
                                                      Can you see the
                                                      symbol in
                                                      libpetsc.a?<br>
                                                      <br>
                                                          Matt<br>
                                                      <br>
                                                      <blockquote
                                                        class="gmail_quote"
                                                        style="margin:0
                                                        0 0
                                                        .8ex;border-left:1px
                                                        #ccc
                                                        solid;padding-left:1ex">
                                                             Matt<br>
                                                        <br>
                                                        Thanks.<br>
                                                        <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0



                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">
                                                             Matt<br>
                                                          <br>
                                                          Thanks!<br>
                                                          <br>
                                                          <br>
                                                          On 2/5/2012
                                                          10:11 PM,
                                                          Matthew
                                                          Knepley wrote:<br>
                                                          <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0



                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">
                                                          On Wed, May 2,
                                                          2012 at 1:55
                                                          PM, TAY
                                                          wee-beng<<a
moz-do-not-send="true" href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>>




                                                           wrote:<br>
                                                          Hi,<br>
                                                          <br>
                                                          I did a
                                                          MatView and
                                                          VecView on
                                                          both C and
                                                          Fortran, right
                                                          after Mat and
                                                          Vec assembly.
                                                          I have
                                                          attached the
                                                          printout
                                                          below. They
                                                          are exactly
                                                          the same, but
                                                          yet the result
                                                          is different
                                                          in Neumann
                                                          condition.
                                                          However, the
                                                          dirichlet
                                                          condition
                                                          gives the
                                                          correct ans.
                                                          Is there
                                                          anything else
                                                          that could be
                                                          wrong even if
                                                          the Mat and
                                                          Vec are the
                                                          same?<br>
                                                          <br>
                                                          Did you set
                                                          the null space
                                                          for the matrix
                                                          when you have
                                                          Neumann
                                                          conditions?<br>
                                                          </blockquote>
                                                          Yes, for the
                                                          matrix, I set
                                                          as:<br>
                                                          <br>
                                                          call
MatNullSpaceCreate(PETSC_COMM_WORLD,PETSC_TRUE,0,PETSC_NULL_OBJECT,nullspace,ierr)<br>
                                                          <br>
                                                              call
                                                          MatSetNullSpace(jac,nullspace,ierr)<br>
                                                          <br>
                                                              call
                                                          MatNullSpaceDestroy(nullspace,ierr)<br>
                                                          <br>
                                                          for the Vec,<br>
                                                          <br>
                                                          call
MatNullSpaceCreate(PETSC_COMM_WORLD,PETSC_TRUE,0,PETSC_NULL_OBJECT,nullspace,ierr)<br>
                                                          <br>
                                                              !call
                                                          MatNullSpaceRemove(nullspace,b,PETSC_NULL,ierr)<br>
                                                          <br>
                                                              call
                                                          MatNullSpaceDestroy(nullspace,ierr)<br>
                                                          <br>
                                                          MatNullSpaceRemove



                                                          was comment
                                                          out because
                                                          there's error
                                                          during linking<br>
                                                          <br>
                                                          <br>
                                                          <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0



                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">
                                                             Matt<br>
                                                          <br>
                                                          Thanks!<br>
                                                          <br>
                                                          Fortran:<br>
                                                          <br>
                                                          Matrix Object:
                                                          1 MPI
                                                          processes<br>
                                                            type:
                                                          seqaij<br>
                                                          row 0: (0, 2)
                                                           (1, -1)
                                                           (3, -1)<br>
                                                          row 1: (0, -1)
                                                           (1, 3)  (2,
                                                          -1)  (4, -1)<br>
                                                          row 2: (1, -1)
                                                           (2, 2)  (5,
                                                          -1)<br>
                                                          row 3: (0, -1)
                                                           (3, 3)  (4,
                                                          -1)  (6, -1)<br>
                                                          row 4: (1, -1)
                                                           (3, -1)
                                                           (4, 4)  (5,
                                                          -1)  (7, -1)<br>
                                                          row 5: (2, -1)
                                                           (4, -1)
                                                           (5, 3)  (8,
                                                          -1)<br>
                                                          row 6: (3, -1)
                                                           (6, 2)  (7,
                                                          -1)<br>
                                                          row 7: (4, -1)
                                                           (6, -1)
                                                           (7, 3)  (8,
                                                          -1)<br>
                                                          row 8: (5, -1)
                                                           (7, -1)
                                                           (8, 2)<br>
                                                          Vector
                                                          Object:Vec_0000000084000000_0
                                                          1 MPI
                                                          processes<br>
                                                            type: mpi<br>
                                                          Process [0]<br>
                                                          0.25<br>
                                                          0.0205213<br>
                                                          1.135e-005<br>
                                                          0.0205213<br>
                                                          0.00168449<br>
                                                          9.31663e-007<br>
                                                          1.135e-005<br>
                                                          9.31663e-007<br>
                                                          5.15289e-010<br>
                                                          Vector
                                                          Object:Vec_0000000084000000_1
                                                          1 MPI
                                                          processes<br>
                                                            type: mpi<br>
                                                          Process [0]<br>
                                                          0.14924<br>
                                                          0.0242397<br>
                                                          -0.0260347<br>
                                                          0.0242397<br>
                                                          -0.0256192<br>
                                                          -0.0400102<br>
                                                          -0.0260347<br>
                                                          -0.0400102<br>
                                                          -0.0400102<br>
                                                          Press any key
                                                          to continue .
                                                          . .<br>
                                                          <br>
                                                          C:<br>
                                                          <br>
                                                          Matrix Object:
                                                          1 MPI
                                                          processes<br>
                                                            type:
                                                          seqaij<br>
                                                          row 0: (0, 2)
                                                           (1, -1)
                                                           (3, -1)<br>
                                                          row 1: (0, -1)
                                                           (1, 3)  (2,
                                                          -1)  (4, -1)<br>
                                                          row 2: (1, -1)
                                                           (2, 2)  (5,
                                                          -1)<br>
                                                          row 3: (0, -1)
                                                           (3, 3)  (4,
                                                          -1)  (6, -1)<br>
                                                          row 4: (1, -1)
                                                           (3, -1)
                                                           (4, 4)  (5,
                                                          -1)  (7, -1)<br>
                                                          row 5: (2, -1)
                                                           (4, -1)
                                                           (5, 3)  (8,
                                                          -1)<br>
                                                          row 6: (3, -1)
                                                           (6, 2)  (7,
                                                          -1)<br>
                                                          row 7: (4, -1)
                                                           (6, -1)
                                                           (7, 3)  (8,
                                                          -1)<br>
                                                          row 8: (5, -1)
                                                           (7, -1)
                                                           (8, 2)<br>
                                                          Vector
                                                          Object:Vec_0x1d3b000_0
                                                          1 MPI
                                                          processes<br>
                                                            type: mpi<br>
                                                          Process [0]<br>
                                                          0.25<br>
                                                          0.0205212<br>
                                                          1.135e-05<br>
                                                          0.0205212<br>
                                                          0.00168449<br>
                                                          9.31663e-07<br>
                                                          1.135e-05<br>
                                                          9.31663e-07<br>
                                                          5.15288e-10<br>
                                                          Vector
                                                          Object:Vec_0x1d3b000_1
                                                          1 MPI
                                                          processes<br>
                                                            type: mpi<br>
                                                          Process [0]<br>
                                                          0.139311<br>
                                                          0.0305751<br>
                                                          -0.0220633<br>
                                                          0.0305751<br>
                                                          -0.0135158<br>
                                                          -0.042185<br>
                                                          -0.0220633<br>
                                                          -0.042185<br>
                                                          -0.058449<br>
                                                          <br>
                                                          <br>
                                                          <br>
                                                          Yours
                                                          sincerely,<br>
                                                          <br>
                                                          TAY wee-beng<br>
                                                          <br>
                                                          <br>
                                                          On 1/5/2012
                                                          11:54 PM,
                                                          Matthew
                                                          Knepley wrote:<br>
                                                          <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0



                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">
                                                          On Tue, May 1,
                                                          2012 at 5:48
                                                          PM, TAY
                                                          wee-beng<<a
moz-do-not-send="true" href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>>




                                                           wrote:<br>
                                                          Hi,<br>
                                                          <br>
                                                          Do you mean my
                                                          method is
                                                          wrong?<br>
                                                          <br>
                                                          I am following
                                                          the template
                                                          of ex22f,<br>
                                                          <br>
                                                          where the
                                                          variables are
                                                          declared as :<br>
                                                          <br>
                                                          PetscScalar
                                                           v(5)<br>
                                                          <br>
                                                          MatStencil  
row(4),col(4,5)<br>
                                                          <br>
                                                          Hence,<br>
                                                          <br>
                                                          for the
                                                          neumann BC<br>
                                                          <br>
                                                          num = 1<br>
                                                          <br>
                                                                   
                                                               if
                                                          (j/=0) then<br>
                                                          <br>
                                                                   
                                                                 
                                                           v(num) =
                                                          -rho*HxdHy<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_i,num)
                                                          = i<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_j,num)
                                                          = j-1<br>
                                                          <br>
                                                                   
                                                                 
                                                           num = num +
                                                          1<br>
                                                          <br>
                                                                   
                                                               end if<br>
                                                          <br>
                                                                   
                                                               if
                                                          (i/=0) then<br>
                                                          <br>
                                                                   
                                                                 
                                                           v(num) =
                                                          -rho*HydHx<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_i,num)
                                                          = i-1<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_j,num)
                                                          = j<br>
                                                          <br>
                                                                   
                                                                 
                                                           num = num +
                                                          1<br>
                                                          <br>
                                                                   
                                                               end if<br>
                                                          <br>
                                                                   
                                                               if
                                                          (i/=mx-1) then<br>
                                                          <br>
                                                                   
                                                                 
                                                           v(num) =
                                                          -rho*HydHx<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_i,num)
                                                          = i+1<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_j,num)
                                                          = j<br>
                                                          <br>
                                                                   
                                                                 
                                                           num = num +
                                                          1<br>
                                                          <br>
                                                                   
                                                               end if<br>
                                                          <br>
                                                                   
                                                               if
                                                          (j/=my-1) then<br>
                                                          <br>
                                                                   
                                                                 
                                                           v(num) =
                                                          -rho*HxdHy<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_i,num)
                                                          = i<br>
                                                          <br>
                                                                   
                                                                 
                                                           col(MatStencil_j,num)
                                                          = j+1<br>
                                                          <br>
                                                                   
                                                                 
                                                           num = num +
                                                          1<br>
                                                          <br>
                                                                   
                                                               end if<br>
                                                          <br>
                                                                   
                                                               v(num)
                                                          =
                                                          ((num-1)/2.0)*rho*(HxdHy
                                                          + HydHx)<br>
                                                          <br>
                                                                   
                                                               print
                                                          *, v<br>
                                                          <br>
                                                                   
                                                             
                                                           col(MatStencil_i,num)
                                                          = i<br>
                                                          <br>
                                                                   
                                                             
                                                           col(MatStencil_j,num)
                                                          = j<br>
                                                          <br>
                                                                   
                                                               !num =
                                                          num + 1<br>
                                                          <br>
                                                                   
                                                               call
                                                          MatSetValuesStencil(jac,i1,row,num,col,v,INSERT_VALUES,ierr)<br>
                                                          <br>
                                                          I do not get
                                                          any more out
                                                          of range
                                                          error.
                                                          However,my ans
                                                          is still
                                                          different from
                                                          that of ex29
                                                          in C.<br>
                                                          <br>
                                                          This is very
                                                          simple. You
                                                          have an error
                                                          in your code.
                                                          Checking it is
                                                          very simple:
                                                          run the code
                                                          and<br>
                                                          break in
                                                          MatSetValues().
                                                          Make sure ex29
                                                          makes calls
                                                          with exactly
                                                          the same
                                                          indices as
                                                          your ex29f.<br>
                                                          <br>
                                                              Matt<br>
                                                          <br>
                                                          Yours
                                                          sincerely,<br>
                                                          <br>
                                                          TAY wee-beng<br>
                                                          <br>
                                                          -- <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>
                                                          <br>
                                                          <br>
                                                          -- <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>
                                                          <br>
                                                          <br>
                                                          -- <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>
                                                        <br>
                                                        <span><font
                                                          color="#888888">
                                                          <br>
                                                          -- <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>
                                                      <span><font
                                                          color="#888888">
                                                          <br>
                                                          <span><font
                                                          color="#888888">
                                                          <br>
                                                          -- <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></font></span></blockquote>
                                                    <span><font
                                                        color="#888888">
                                                      </font></span></blockquote>
                                                  <span><font
                                                      color="#888888"> </font></span></blockquote>
                                                <span><font
                                                    color="#888888"> </font></span></div>
                                              <span><font
                                                  color="#888888"> <br>
                                                  <br clear="all">
                                                  <span><font
                                                      color="#888888"> <span><font
color="#888888">
                                                          <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></font></span></font></span></div>
                                            <span><font color="#888888">
                                                <span><font
                                                    color="#888888"> </font></span></font></span></blockquote>
                                          <span><font color="#888888"> <span><font
                                                  color="#888888"> </font></span></font></span></div>
                                        <span><font color="#888888"> <span><font
                                                color="#888888"> </font></span></font></span></blockquote>
                                      <span><font color="#888888"> <span><font
                                              color="#888888"> </font></span></font></span></div>
                                    <span><font color="#888888"> <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></font></span></div>
                                  <span><font color="#888888"> </font></span></blockquote>
                                <span><font color="#888888"> </font></span></div>
                              <span><font color="#888888"> </font></span></blockquote>
                            <span><font color="#888888"> </font></span></div>
                          <span><font color="#888888"> <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>
            </div>
          </div>
        </blockquote>
      </div>
      <br>
    </blockquote>
  </body>
</html>