<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 24, 2017 at 6:42 AM, Samuel Lanthaler <span dir="ltr"><<a href="mailto:s.lanthaler@gmail.com" target="_blank">s.lanthaler@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ah, great. I didn't understand that "optional" arguments are not optional in the fortran sense of the word. After setting up two vectors to pass to the routine, the program works. Thank you very much!<br>
<br>
One additional question: In the documentation, it is written that I can pass PETSC_NULL for these two vectors, if I don't actually need them. That probably only works in C, but not in fortran. Is there a corresponding argument I can pass to the routine in fortran? It seems, that PETSC_NULL_REAL doesn't work; is there some other PETSC_NULL_XXX that should be passed in this case from fortran? If not, then I'll just stick to creating vectors and distroying them afterwards, which is fine for me as well.<br></blockquote><div><br></div><div>You can use PETSC_NULL_VEC</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cheers,<br>
Sam<br>
<br>
<br>
On 11/24/2017 01:56 AM, Smith, Barry F. wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
MatZeroRowsColumns() as two vector arguments you are missing<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Nov 23, 2017, at 2:43 PM, Samuel Lanthaler <<a href="mailto:s.lanthaler@gmail.com" target="_blank">s.lanthaler@gmail.com</a>> wrote:<br>
<br>
Hi there,<br>
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:<br>
<br>
! initialize PETSc<br>
   CALL PetscInitialize(PETSC_NULL_CHA<wbr>RACTER,ierr)<br>
<br>
   ! Set up a new matrix<br>
   m = 3<br>
   CALL MatCreate(PETSC_COMM_WORLD,mat<wbr>A,ierr); CHKERRQ(ierr);<br>
   CALL MatSetType(matA,MATMPIAIJ,ierr<wbr>); CHKERRQ(ierr);<br>
   CALL MatSetSizes(matA,PETSC_DECIDE,<wbr>PETSC_DECIDE,m,m,ierr); CHKERRQ(ierr);<br>
   CALL MatMPIAIJSetPreallocation(matA<wbr>,3,PETSC_NULL_INTEGER,3,PETSC_<wbr>NULL_INTEGER,ierr); CHKERRQ(ierr);<br>
<br>
   ! set values of matrix<br>
   vals(1,:) = (/1.,2.,3./)<br>
   vals(2,:) = (/4.,5.,6./)<br>
   vals(3,:) = (/7.,8.,9./)<br>
   !<br>
   idxm = (/0,1,2/)<br>
   idxn = (/0,1,2/)<br>
   !<br>
   CALL MatSetValues(matA,3,idxm,3,idx<wbr>n,vals,INSERT_VALUES,ierr); CHKERRQ(ierr);<br>
      ! assemble matrix<br>
   CALL MatAssemblyBegin(matA,MAT_FINA<wbr>L_ASSEMBLY,ierr); CHKERRQ(ierr);<br>
   CALL MatAssemblyEnd(matA,MAT_FINAL_<wbr>ASSEMBLY,ierr); CHKERRQ(ierr);<br>
     ! set one row/column to zero, put 6.0d0 on diagonal<br>
   idone(1) = 2<br>
   val = 6.0d0<br>
   CALL MatZeroRowsColumns(matA,1,idon<wbr>e,val,ierr); CHKERRQ(ierr);<br>
<br>
! finalize PETSc<br>
   CALL PetscFinalize(PETSC_NULL_CHARA<wbr>CTER,ierr)<br>
<br>
When running the program, I get the following error message:<br>
<br>
[0]PETSC ERROR: ------------------------------<wbr>------------------------------<wbr>------------<br>
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range<br>
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger<br>
[0]PETSC ERROR: or see <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/d<wbr>ocumentation/faq.html#valgrind</a><br>
[0]PETSC ERROR: or try <a href="http://valgrind.org" rel="noreferrer" target="_blank">http://valgrind.org</a> on GNU/linux and Apple Mac OS X to find memory corruption errors<br>
[0]PETSC ERROR: likely location of problem given in stack below<br>
[0]PETSC ERROR: ---------------------  Stack Frames ------------------------------<wbr>------<br>
[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,<br>
[0]PETSC ERROR:       INSTEAD the line number of the start of the function<br>
[0]PETSC ERROR:       is given.<br>
[0]PETSC ERROR: --------------------- Error Message ------------------------------<wbr>------------------------------<wbr>--<br>
[0]PETSC ERROR: Signal received<br>
[0]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" rel="noreferrer" target="_blank">http://www.mcs.anl.gov/petsc/d<wbr>ocumentation/faq.html</a> for trouble shooting.<br>
[0]PETSC ERROR: Petsc Release Version 3.8.2, Nov, 09, 2017<br>
[0]PETSC ERROR: ./test on a arch-complex-debug named sam-ThinkPad-T450s by sam Thu Nov 23 23:28:15 2017<br>
[0]PETSC ERROR: Configure options PETSC_DIR=/home/sam/Progs/pets<wbr>c-3.8.2 PETSC_ARCH=arch-complex-debug --with-scalar-type=complex<br>
[0]PETSC ERROR: #1 User provided function() line 0 in  unknown file<br>
------------------------------<wbr>------------------------------<wbr>--------------<br>
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD<br>
with errorcode 59.<br>
Would someone be so kind as to tell me what I'm doing wrong? Thank you!<br>
<br>
Best regards,<br>
Sam<br>
</blockquote></blockquote>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div>
</div></div>