[petsc-users] Must call MatXXXSetPreallocation() or MatSetUp() on argument 1 "mat" before MatGetFactorAvailable()

Hong hzhang at mcs.anl.gov
Wed Jul 15 13:06:27 CDT 2015


Mehrzad:
We have many examples using MatLoad().
Under petsc/src/ksp/ksp/examples/tutorials
grep MatLoad *.c
ex10.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);
ex27.c:  ierr  = MatLoad(A,fd);CHKERRQ(ierr);
ex41.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);

ex10.c is used frequently.

Under petsc/src/ksp/ksp/examples/tests
grep MatLoad *.c
ex11.c:  ierr = MatLoad(*A11,viewer);CHKERRQ(ierr);

ex18.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);
ex25.c:  ierr = MatLoad(C,view);CHKERRQ(ierr);
ex27.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);
ex30.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);

ex31.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);
ex33.c:    ierr = MatLoad(A,viewer);CHKERRQ(ierr);
ex33.c:      ierr = MatLoad(B,viewer);CHKERRQ(ierr);
ex37.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);
ex43.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);
ex6.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);
ex7.c:  ierr = MatLoad(A,fd);CHKERRQ(ierr);

Hong

Thank you Hong,
>
> No I do not need that function. I'm looking for an example that reads a
> matrix from file and run pcg solver on it. I want to run it with CUDA and
> MPI.
> /ksp/examples/tutorials/ex2.c is a good example but it does not read from
> file and for some reason I cannot make "reading from file work".
> How can I find a working code like that?
>
> Best,
> Mehrzad
>
> On Wed, Jul 15, 2015 at 12:13 PM Hong <hzhang at mcs.anl.gov> wrote:
>
>> Mehrzad :
>> The error occurs at MatCreateNormal(A,&N), a function rarely used and not
>> well tested. We will fix it.
>>
>> Do you need this function?
>>
>> Hong
>>
>> Hello everyone,
>>>
>>> I'm really new to Petsc and when I try to run
>>> ksp/ksp/examples/tutorials/ex27
>>>
>>> I get this error
>>>
>>> [0]PETSC ERROR: Object is in wrong state
>>> [0]PETSC ERROR: Must call MatXXXSetPreallocation() or MatSetUp() on
>>> argument 1 "mat" before MatGetFactorAvailable()
>>> [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html
>>> for trouble shooting.
>>> [0]PETSC ERROR: Petsc Release Version 3.6.0, unknown
>>> [0]PETSC ERROR: ./ex27 on a arch-linux2-cxx-debug named scourge by
>>> mehrzads Wed Jul 15 11:27:48 2015
>>> [0]PETSC ERROR: Configure options --with-mpi=1 --prefix=/opt/petsc
>>> --with-clanguage=cxx
>>> [0]PETSC ERROR: #1 MatGetFactorAvailable() line 4199 in /../matrix.c
>>> [0]PETSC ERROR: #2 PCGetDefaultType_Private() line 27 in /../precon.c
>>> [0]PETSC ERROR: #3 PCSetFromOptions() line 159 in /../pcset.c
>>> [0]PETSC ERROR: #4 KSPSetFromOptions() line 358 in /../itcl.c
>>>
>>>
>>> Can you help me identify the problem?
>>>
>>> Best,
>>> Mehrzad
>>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150715/2bad803b/attachment.html>


More information about the petsc-users mailing list