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