<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">PETSC_OWN_POINTER,</div></div></blockquote><div><br></div>indicates that the IS is to take ownership of the memory in indices, hence you are no longer reasonable for that memory and should not call PetscFree() on it. So the code is running correctly.<div><br><div><br><blockquote type="cite"><div>On Feb 4, 2023, at 3:24 AM, 김성익 <ksi2443@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div dir="ltr">Following your comments, that works in multi processes.<div>After extracting procedure from 'newmat' which is submatrix.</div><div><div><br></div><div>PetscInt *indices;</div><div>PetscMalloc1(1, &indices);</div><div>Indices[0] = 0;</div><div>ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, &isrow);</div><div>MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,&newmat);</div><div>(extract from newmat)</div><div><br style="color:rgb(80,0,80)"></div></div><div>I did 'ISDestroy(&isrow); PetscFree(indices);'</div><div>However I got an error 'double free'.</div><div>So I deleted PetscFree. </div><div>Is this correct response of that error?</div><div>If not, how should I deal with that error??</div><div><br></div><div>Thanks,</div><div>Hyung Kim </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2023년 2월 3일 (금) 오후 11:33, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>>님이 작성:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Feb 3, 2023 at 9:04 AM 김성익 <<a href="mailto:ksi2443@gmail.com" target="_blank">ksi2443@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Actually in the last mail, below scripts are running in all processes.</div><div><br></div><div>IS isrow;</div><div>PetscInt *indices;</div><div>PetscMalloc1(1, &indices);</div><div>Indices[0] = 0;</div><div>ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, &isrow);</div><div>MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,&newmat);</div><div>(extract from newmat)</div><div><br></div><div>However, you said it cannot get the values of first row of global matrix.<br></div><div>Please let me know how can I fix this scripts for getting the 1st row of global matrix in all processes.</div></div></blockquote><div><br></div><div>Did you run and see what you get? If it is on all processes, it should work.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hyung Kim</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2023년 2월 3일 (금) 오후 10:54, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>님이 작성:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Feb 3, 2023 at 8:52 AM 김성익 <<a href="mailto:ksi2443@gmail.com" target="_blank">ksi2443@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I want to extract same row values of global matrix in all processes.<div>Then how can I do this??</div></div></blockquote><div><br></div><div>Create the same IS on each process.</div><div><br></div><div> THanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>The case of same problem of vector, I just use vecscattertoall.</div><div>However, I can't find same function for matrix.</div><div><br></div><div>Hyung Kim</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2023년 2월 3일 (금) 오후 10:47, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>님이 작성:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Feb 3, 2023 at 8:45 AM 김성익 <<a href="mailto:ksi2443@gmail.com" target="_blank">ksi2443@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Following your comments,<br>If I extract first row of below matrix.<br><div><span id="cid:ii_ldokt9u31"><image.png></span><br></div><div>IS isrow;</div><div>PetscInt *indices;</div><div>PetscMalloc1(1, *indices);</div></div></div></blockquote><div><br></div><div>That should be &indices.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Indices[0] = 0;</div><div>ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES, &isrow);</div></div></div></blockquote><div><br></div><div>You should use PETSC_OWN_POINTER.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,&newmat);</div><div><br></div><div>Then can I get the array about first row of global matrix in all processes?</div></div></div></blockquote><div><br></div><div>No, just on the process which gives 0. If you do that on every process, every rank with get row 0.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hyung Kim</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2023년 2월 3일 (금) 오후 10:26, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>님이 작성:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, Feb 3, 2023 at 8:06 AM 김성익 <<a href="mailto:ksi2443@gmail.com" target="_blank">ksi2443@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Following your comments,<br>I want to check below things.<div>For example, the global dense matrix are as below.</div><div><span id="cid:ii_ldojdn3o0"><image.png></span><br></div><div>If I want to get first row ('1 2 0 0 3 0 0 4') in Proc 1.</div><div>Then I should put '<span style="font-size: 13.125px; box-sizing: border-box;"><a href="https://petsc.org/main/docs/manualpages/Mat/MatCreateSubMatrix/" style="box-sizing:border-box;background-color:transparent;text-decoration-line:none" target="_blank">MatCreateSubMatrix</a></span><span style="font-size: 13.125px; box-sizing: border-box; font-weight: bold;">(</span><span style="font-size: 13.125px; box-sizing: border-box;">mat</span><span style="font-size: 13.125px; box-sizing: border-box; font-weight: bold;">,</span><span style="font-size:13.125px;box-sizing:border-box;color:rgb(248,248,248)"> </span><span style="font-size: 13.125px; box-sizing: border-box;">isrow</span><span style="font-size: 13.125px; box-sizing: border-box; font-weight: bold;">,</span><span style="font-size:13.125px;box-sizing:border-box;color:rgb(248,248,248)"> </span><span style="font-size: 13.125px; box-sizing: border-box;">NULL</span><span style="font-size: 13.125px; box-sizing: border-box; font-weight: bold;">,</span><span style="font-size:13.125px;box-sizing:border-box;color:rgb(248,248,248)"> </span><span style="font-size: 13.125px; box-sizing: border-box;">MAT_INITIAL_MATRIX</span><span style="font-size: 13.125px; box-sizing: border-box; font-weight: bold;">,</span><span style="font-size:13.125px;box-sizing:border-box;color:rgb(248,248,248)"> </span><span style="font-size:13.125px;box-sizing:border-box"><font color="#ce5c00"><b>&</b></font></span><span style="font-size: 13.125px; box-sizing: border-box;">newmat</span><span style="font-size: 13.125px; box-sizing: border-box; font-weight: bold;">)'</span></div><div><font><span style="font-size:13.125px">and isrow will be [0 1 2 3 4 5 6 7].</span></font></div><div><font><span style="font-size:13.125px"><br></span></font></div><div><font><span style="font-size:13.125px">In this case, How can I make isrow?<br>Actually I can't understand the procedure of handling isrow.</span></font></div></div></blockquote><div><br></div><div>You create an IS object of type ISGENERAL and give it the array of global indices that you want to extract.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><font><span style="font-size:13.125px">Hyung Kim</span></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2023년 2월 3일 (금) 오후 9:03, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>>님이 작성:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><a href="https://petsc.org/main/docs/manualpages/Mat/MatCreateSubMatrix/" target="_blank">https://petsc.org/main/docs/manualpages/Mat/MatCreateSubMatrix/</a><br><div><br></div><div>Note, PETSc lets you give NULL arguments if there is a reasonable default.</div><div>In this case give NULL for the column IS and you will get the whole columns.</div><div><br></div><div>Mark</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 3, 2023 at 4:05 AM 김성익 <<a href="mailto:ksi2443@gmail.com" target="_blank">ksi2443@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div><br></div><div>By using MatGetRow, user can get vectors from local matrix (at each process).</div><div><br></div><div>However, I need other process's row values.</div><div>So I have 2 questions.</div><div><br></div><div>1. Is there any function for getting arrays from other process's??</div><div><br></div><div>2. Or is there any function like matrix version of vecscattertoall??</div><div><br></div><div>Thanks,</div><div>Hyung Kim</div></div>
</blockquote></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><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.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><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.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><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.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><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.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div></div>
</div></blockquote></div><br></div></body></html>