[petsc-users] MatGetRow_MPIAIJ error

Eda Oktay eda.oktay at metu.edu.tr
Wed Mar 20 02:52:21 CDT 2019


Hello,

I wrote a code computing element wise absolute value of a matrix. When I
run the code sequentially, it works. However, when I try to use it in
parallel with the same matrix, I get the following error:

[1]PETSC ERROR: Argument out of range
[1]PETSC ERROR: Only local rows

The absolute value code is:

ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr);
ierr = MatDuplicate(A,MAT_COPY_VALUES,AbsA);CHKERRQ(ierr);

  for (i=0; i<n; i++) {
    ierr = MatGetRow(A,i,&nc,&aj,&aa);CHKERRQ(ierr);


    PetscMalloc1(nc,&absaa);
    for (j=0; j<nc; j++){
        absaa[j] = fabs(aa[j]);
    }

    ierr =
MatSetValues(*AbsA,1,&i,nc,aj,absaa,INSERT_VALUES);CHKERRQ(ierr);
ierr = MatRestoreRow(A,i,&nc,&aj,&aa);CHKERRQ(ierr);
  }

I didn't understand how I fix this problem since I am new to PETSc.

Thanks

Eda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190320/2118b7a6/attachment.html>


More information about the petsc-users mailing list