<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi there, <br>
</p>
<p>I'm new to PETSc and have been trying to do some basic
manipulation of matrices in fortran, but don't seem to be able to
set a row/column to zero using the MatZeroRowsColumns command: The
following is a small example program:<code><br>
</code></p>
<p><code> ! initialize PETSc</code><code><br>
</code><code> CALL PetscInitialize(PETSC_NULL_CHARACTER,ierr)</code><code><br>
</code><code><br>
</code><code> ! Set up a new matrix</code><code><br>
</code><code> m = 3</code><code><br>
</code><code> CALL MatCreate(PETSC_COMM_WORLD,matA,ierr);
CHKERRQ(ierr);</code><code><br>
</code><code> CALL MatSetType(matA,MATMPIAIJ,ierr);
CHKERRQ(ierr);</code><code><br>
</code><code> CALL
MatSetSizes(matA,PETSC_DECIDE,PETSC_DECIDE,m,m,ierr);
CHKERRQ(ierr);</code><code><br>
</code><code> CALL
MatMPIAIJSetPreallocation(matA,3,PETSC_NULL_INTEGER,3,PETSC_NULL_INTEGER,ierr);
CHKERRQ(ierr);</code><code><br>
</code><code><br>
</code><code> ! set values of matrix</code><code><br>
</code><code> vals(1,:) = (/1.,2.,3./)</code><code><br>
</code><code> vals(2,:) = (/4.,5.,6./)</code><code><br>
</code><code> vals(3,:) = (/7.,8.,9./)</code><code><br>
</code><code> ! </code><code><br>
</code><code> idxm = (/0,1,2/)</code><code><br>
</code><code> idxn = (/0,1,2/)</code><code><br>
</code><code> !</code><code><br>
</code><code> CALL
MatSetValues(matA,3,idxm,3,idxn,vals,INSERT_VALUES,ierr);
CHKERRQ(ierr);</code><code><br>
</code><code> </code><code><br>
</code><code> ! assemble matrix</code><code><br>
</code><code> CALL
MatAssemblyBegin(matA,MAT_FINAL_ASSEMBLY,ierr); CHKERRQ(ierr);</code><code><br>
</code><code> CALL MatAssemblyEnd(matA,MAT_FINAL_ASSEMBLY,ierr);
CHKERRQ(ierr);</code><code><br>
</code><code> </code><code><br>
</code><code> ! set one row/column to zero, put 6.0d0 on diagonal</code><code><br>
</code><code> idone(1) = 2</code><code><br>
</code><code> val = 6.0d0</code><code><br>
</code><code> CALL MatZeroRowsColumns(matA,1,idone,val,ierr);
CHKERRQ(ierr);</code><code></code></p>
<p><code>! finalize PETSc</code><code><br>
</code><code> CALL PetscFinalize(PETSC_NULL_CHARACTER,ierr)</code><code><br>
</code><code><br>
</code>When running the program, I get the following error
message:</p>
<p><code>[0]PETSC ERROR:
------------------------------------------------------------------------</code><code><br>
</code><code>[0]PETSC ERROR: Caught signal number 11 SEGV:
Segmentation Violation, probably memory access out of range</code><code><br>
</code><code>[0]PETSC ERROR: Try option -start_in_debugger or
-on_error_attach_debugger</code><code><br>
</code><code>[0]PETSC ERROR: or see
<a class="moz-txt-link-freetext" href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind">http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind</a></code><code><br>
</code><code>[0]PETSC ERROR: or try <a class="moz-txt-link-freetext" href="http://valgrind.org">http://valgrind.org</a> on
GNU/linux and Apple Mac OS X to find memory corruption errors</code><code><br>
</code><code>[0]PETSC ERROR: likely location of problem given in
stack below</code><code><br>
</code><code>[0]PETSC ERROR: --------------------- Stack Frames
------------------------------------</code><code><br>
</code><code>[0]PETSC ERROR: Note: The EXACT line numbers in the
stack are not available,</code><code><br>
</code><code>[0]PETSC ERROR: INSTEAD the line number of the
start of the function</code><code><br>
</code><code>[0]PETSC ERROR: is given.</code><code><br>
</code><code>[0]PETSC ERROR: --------------------- Error Message
--------------------------------------------------------------</code><code><br>
</code><code>[0]PETSC ERROR: Signal received</code><code><br>
</code><code>[0]PETSC ERROR: See
<a class="moz-txt-link-freetext" href="http://www.mcs.anl.gov/petsc/documentation/faq.html">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble
shooting.</code><code><br>
</code><code>[0]PETSC ERROR: Petsc Release Version 3.8.2, Nov, 09,
2017 </code><code><br>
</code><code>[0]PETSC ERROR: ./test on a arch-complex-debug named
sam-ThinkPad-T450s by sam Thu Nov 23 23:28:15 2017</code><code><br>
</code><code>[0]PETSC ERROR: Configure options
PETSC_DIR=/home/sam/Progs/petsc-3.8.2
PETSC_ARCH=arch-complex-debug --with-scalar-type=complex</code><code><br>
</code><code>[0]PETSC ERROR: #1 User provided function() line 0
in unknown file</code><code><br>
</code><code>--------------------------------------------------------------------------</code><code><br>
</code><code>MPI_ABORT was invoked on rank 0 in communicator
MPI_COMM_WORLD </code><code><br>
</code><code>with errorcode 59.</code><br>
</p>
<p>Would someone be so kind as to tell me what I'm doing wrong?
Thank you!</p>
Best regards,<br>
Sam<br>
</body>
</html>