[petsc-users] Problem using MatSetValue with SeqAIJ. Values not being inserted.

Matthew Knepley knepley at gmail.com
Mon Jul 16 06:42:17 CDT 2012


On Mon, Jul 16, 2012 at 3:23 AM, Shitij Bhargava <shitij.cse at gmail.com>wrote:

> Hi all !!
>
> I am using Fortan and petsc 3.2-p7.
>
> I am creating the array as:
> *call
> MatCreateSeqAIJ(PETSC_COMM_SELF,natoms,natoms,PETSC_DECIDE,PETSC_NULL,bonds,ierr)
> *
>
> And then inserting elements as:
> *call MatSetValue(bonds,temp_int1-1,temp_int2-1,1,INSERT_VALUES,ierr)*
>
> I even did:
> *call MatSetValue(bonds,1,8,35,INSERT_VALUES,ierr)*
>
> then I finalize the matrix by these:
> *call MatAssemblyBegin(bonds,MAT_FINAL_ASSEMBLY,ierr)*
> *call MatAssemblyEnd(bonds,MAT_FINAL_ASSEMBLY,ierr)*
>
> But none of these values show up when I view the matrix by this:
> *call MatView(bonds,PETSC_VIEWER_STDOUT_SELF,ierr)*
>
> It's output is the following:
> Matrix Object: 1 MPI processes
>   type: seqaij
> row 0: (0, 2.47033e-323)  (1, 2.8034e-85)  (4, 2.8034e-85)  (5,
> 2.8034e-85)  (6, 2.8034e-85)
> row 1: (0, 2.8034e-85)  (2, 2.8034e-85)  (7, 2.8034e-85)  (8, 1.6976e-313)
> row 2: (1, 2.8034e-85)  (3, 2.8034e-85)  (9, 2.8034e-85)
> row 3: (2, 2.8034e-85)
> row 4: (0, 2.8034e-85)
> row 5: (0, 2.8034e-85)
> row 6: (0, 2.8034e-85)
> row 7: (1, 2.8034e-85)
> row 8: (1, 2.8034e-85)
> ..............
>
> Why are the values not being inserted? (Even at (1,8), 35 is not there.)
>

Because the values are the wrong type, and Fortran does not know how to
coerce them
correctly (typing is weak in Fortran). Take a look at


http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex2f.F.html

     Matt


> Thank you in advance !!
>
> Shitij
>
>


-- 
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/20120716/c075586e/attachment-0001.html>


More information about the petsc-users mailing list