[petsc-users] Problem with fortran version of ex29 in ksp

Matthew Knepley knepley at gmail.com
Tue May 1 16:54:56 CDT 2012


On Tue, May 1, 2012 at 5:48 PM, TAY wee-beng <zonexo at gmail.com> wrote:

> Hi,
>
> Do you mean my method is wrong?
>
> I am following the template of ex22f,
>
> where the variables are declared as :
>
> PetscScalar  v(5)
>
> MatStencil   row(4),col(4,5)
>
> Hence,
>
> for the neumann BC
>
> num = 1
>
>                if (j/=0) then
>
>                    v(num) = -rho*HxdHy
>
>                    col(MatStencil_i,num) = i
>
>                    col(MatStencil_j,num) = j-1
>
>                    num = num + 1
>
>                end if
>
>                if (i/=0) then
>
>                    v(num) = -rho*HydHx
>
>                    col(MatStencil_i,num) = i-1
>
>                    col(MatStencil_j,num) = j
>
>                    num = num + 1
>
>                end if
>
>                if (i/=mx-1) then
>
>                    v(num) = -rho*HydHx
>
>                    col(MatStencil_i,num) = i+1
>
>                    col(MatStencil_j,num) = j
>
>                    num = num + 1
>
>                end if
>
>                if (j/=my-1) then
>
>                    v(num) = -rho*HxdHy
>
>                    col(MatStencil_i,num) = i
>
>                    col(MatStencil_j,num) = j+1
>
>                    num = num + 1
>
>                end if
>
>                v(num) = ((num-1)/2.0)*rho*(HxdHy + HydHx)
>
>                print *, v
>
>                col(MatStencil_i,num) = i
>
>                col(MatStencil_j,num) = j
>
>                !num = num + 1
>
>                call MatSetValuesStencil(jac,i1,**
> row,num,col,v,INSERT_VALUES,**ierr)
>
> I do not get any more out of range error. However,my ans is still
> different from that of ex29 in C.
>

This is very simple. You have an error in your code. Checking it is very
simple: run the code and
break in MatSetValues(). Make sure ex29 makes calls with exactly the same
indices as your ex29f.

    Matt


> Yours sincerely,
>
> TAY wee-beng
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120501/4167ac1b/attachment.htm>


More information about the petsc-users mailing list