[petsc-users] Problem With MatRestoreRow

ked1 at rice.edu ked1 at rice.edu
Thu Aug 11 12:08:20 CDT 2011


Barry,

That worked. Thanks for the info.

Kenny

Quoting Barry Smith <bsmith at mcs.anl.gov>:

>
>   One problem is you cannot pass petsc_null in Fortran you must pass  
> the specific type for example petsc_null_double or  
> petsc_null_integer depending on the argument type.
> This may or may not completely resolve the problem, send email to  
> petsc-maint at mcs.anl.gov if you still have difficulties
>
>     Barry
>
> On Aug 11, 2011, at 11:00 AM, ked1 at rice.edu wrote:
>
>> I am attempting to build a matrix and then get a row (or the number  
>> of nonzeros in the row) in Fortran 90. I can build the matrix and  
>> use it for calculations such as matrix multiplication, but if I  
>> call MatGetRow and then MatRestoreRow, I get an error about object  
>> type.
>>
>> However, if I reduce the size of the arrays I'm using in the  
>> MatSetValues command, everything works (except that I'm not  
>> building what I want).
>>
>>
>> The section of my code giving trouble is below.
>>
>> ---------------------- CODE  BEGINS ----------------------------
>> Mat  M
>> PetscInt  dnnz(locneq), onnz(locneq), rows(64)
>> PetscScalar Me(64*64)
>>
>> ...
>>
>> dnnz = 64
>> onnz = 0
>> call  
>> MatCreateMPIAIJ(petsc_comm_world,locneq,locneq,gnngu,gnngu,petsc_null,dnnz,petsc_null,onnz,M,ierr)
>>
>> Me = 1.0D0
>> if (procid==0) then
>>  do ii=1,ne        ! for all elements
>>    do jj=1,64      ! for number of rows
>>      kk = uconn(ii,jj)  ! get local node number
>>      rows(jj) = gnoden(kk)-1  ! get global node number
>>    end do
>>    call MatSetValues(M,64,rows,64,rows,Me,add_values,ierr)
>>  end do
>> end if
>>
>> ! Assemble
>> call MatAssemblyBegin(M,mat_final_assembly,ierr)
>> call MatAssemblyEnd(M,mat_final_assembly,ierr)
>>
>> ! Get number of nonzero columns
>> if (procid==0) then
>>  call MatGetRow(M,0,ii,petsc_null,petsc_null,ierr)
>>  print *, ii
>>  call MatRestoreRow(M,0,ii,petsc_null,petsc_null,ierr)
>> end if
>> ---------------------- CODE  ENDS ----------------------------
>>
>> The error I get is
>>
>> [0]PETSC ERROR: --------------------- Error Message  
>> ------------------------------------
>> [0]PETSC ERROR: Invalid argument!
>> [0]PETSC ERROR: Wrong type of object: Parameter # 1!
>> [0]PETSC ERROR:  
>> ------------------------------------------------------------------------
>> [0]PETSC ERROR: Petsc Release Version 3.1.0, Patch 8, Thu Mar 17  
>> 13:37:48 CDT 2011
>> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
>> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
>> [0]PETSC ERROR: See docs/index.html for manual pages.
>> [0]PETSC ERROR:  
>> ------------------------------------------------------------------------
>> [0]PETSC ERROR: ./semg3par on a linux-gnu named  
>> login1.sugar.rice.edu by ked1 Thu Aug 11 10:52:46 2011
>> [0]PETSC ERROR: Libraries linked from  
>> /projects/bch3862/petsc/linux-gnu-c-debug/lib
>> [0]PETSC ERROR: Configure run at Sun Jul 17 15:34:01 2011
>> [0]PETSC ERROR: Configure options --with-cc=icc --with-fc=ifort  
>> --download-f-blas-lapack=1 --download-mpich=1
>> [0]PETSC ERROR:  
>> ------------------------------------------------------------------------
>> [0]PETSC ERROR: MatRestoreRow() line 388 in src/mat/interface/matrix.c
>>
>> Line 388 in matrix.c is
>>
>> PetscValidHeaderSpecific(mat,MAT_COOKIE,1);
>>
>> Again, if I lower the number of rows, it will not give an error. In  
>> this case, replacing all instances of 64 with 46 will give no  
>> error. Going to 47 gives a error.
>>
>> Thanks for any help.
>>
>> Kenny
>>
>>
>>
>>
>>
>>
>
>
>





More information about the petsc-users mailing list