<div dir="ltr">That is what I tried initially however, I get a segmentation fault. I can confirm it's due to the remote offsets because if I try and output remoteoffsets between the Distribute Section and Create Section it throws the same segmentation fault. <br><br>Thanks for the help<br>Nicholas</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 12, 2023 at 11:56 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com">junchao.zhang@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"><div dir="ltr"><div><br></div><div><div dir="ltr"><div dir="ltr"><br></div></div></div></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 12, 2023 at 1:28 PM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">Hi Junchao<br><br>Going back to this merge request. I'm not sure I follow exactly the usage described in the commit history. I have a c prototype of what I am trying to do which is <br><br><div style="color:rgb(255,255,255);background-color:rgb(0,36,81);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div> <span style="color:rgb(255,157,164)">PetscSectionCreate</span>(PETSC_COMM_WORLD, <span style="color:rgb(153,255,255)">&</span>leafSection);</div><div> <span style="color:rgb(255,157,164)">PetscSFDistributeSection</span>(redistributionSF, filteredSection_local, <span style="color:rgb(153,255,255)">&</span>remoteOffsets, leafSection);</div><div> <span style="color:rgb(255,157,164)">PetscSFCreateSectionSF</span>(redistributionSF, filteredSection_local, remoteOffsets, leafSection, <span style="color:rgb(153,255,255)">&</span>redistributionSF_dof);</div></div><br>But something seems unclear with the usage in fortran around the remoteoffsets. Do I have to insert the CreateRemoteOffsetsF90 like so? Any clarification would be greatly appreciated.<br><br><div style="color:rgb(255,255,255);background-color:rgb(0,36,81);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(235,187,255)">call</span> PetscSFDistributeSectionF90(distributionSF, section_filt_l, remoteoffsets, leafSection, ierr)</div><div><span style="color:rgb(235,187,255)">call</span> PetscSFCreateRemoteOffsetsf90(distributionSF, section_filt_l, leafSection, remoteoffsets, ierr )</div><div><span style="color:rgb(235,187,255)">call</span> PetscSFCreateSectionSFF90(distributionSF, section_filt_l, remoteoffsets, leafSection, distributionSF_dof, ierr)</div></div><br></div></blockquote><div>Hi, Nicholas,</div><div> Reading through comments at <a href="https://gitlab.com/petsc/petsc/-/merge_requests/5386#note_1022942470" target="_blank">https://gitlab.com/petsc/petsc/-/merge_requests/5386#note_1022942470</a>, I feel it should look like</div><div><br></div>PetscInt, pointer :: remoteOffsets(:)<br>call PetscSFDistributeSectionF90(distributionSF, section_filt_l, remoteoffsets, leafSection, ierr) // allocate remoteoffsets<br>call PetscSFCreateSectionSFF90(distributionSF, section_filt_l, remoteoffsets, leafSection, distributionSF_dof, ierr)<br>call PetscIntArray1dDestroyF90(remoteOffsets,ierr) // free remoteoffsets when not needed<br></div><div class="gmail_quote"><div><br></div><div>Could you try it? </div><div><br></div><div><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">Sincerely<br>Nicholas</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 10, 2023 at 4:42 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@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">Hi, Nicholas,<div> It seems we have implemented it, but with another name, PetscSFCreateSectionSFF90, see <a href="https://gitlab.com/petsc/petsc/-/merge_requests/5386" target="_blank">https://gitlab.com/petsc/petsc/-/merge_requests/5386</a></div><div> Try it to see if it works!</div><div> </div><div><div><div dir="ltr"><div dir="ltr">--Junchao Zhang</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 10, 2023 at 11:45 AM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">Er to be honest I still can't get my stub to compile properly, and I don't know how to go about making a merge request. But here is what I am attempting right now. Let me know how best to proceed<br><br><br>Its not exactly clear to me how to setup up the remote offset properly. <br><br>in src/vec/is/sf/interface/ftn-custom/zsf.c<br><br>PETSC_EXTERN void petscsfcreatesectionsf(PetscSF *sf, PetscSection *rootSection, F90Array1d *aremoteOffsets, PetscSection *leafSection, PetscSF *sectionSF, int * ierr PETSC_F90_2PTR_PROTO(remoteoffsetsd))<br>{<br><br> int * remoteOffsets;<br> *ierr = F90Array1dAccess(aremoteOffsets, PETSC_INT, (void**) &remoteOffsets PETSC_F90_2PTR_PARAM(remoteoffsetsd));if (*ierr) return;<br> *ierr = PetscSFCreateSectionSF(*sf,*rootSection, &remoteOffsets,*leafSection,*sectionSF);if (*ierr) return; <br><br>} <br><br>This is the sticking point. <br><br>Sincerely <br>Nicholas<br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 10, 2023 at 12:38 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@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"><div>Hi, Nicholas, </div><div> Could you make a merge request to PETSc and then our Fortran experts can comment on your MR?</div><div> Thanks.</div><br clear="all"><div><div dir="ltr"><div dir="ltr">--Junchao Zhang</div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 10, 2023 at 11:10 AM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">Hi Junchao<br><br>I think I'm almost there, but I could use some insight into how to use the PETSC_F90_2PTR_PROTO and F90Array1dAccess for the remoteOffset parameter input so if another function comes up, I can add it myself without wasting your time. <br>I am very grateful for your help and time. <br><br>Sincerely<br>Nicholas</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 10, 2023 at 10:55 AM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@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">Hi, Nicholas, <div> I am not a fortran guy, but I will try to add petscsfcreatesectionsf.<div> </div><div> Thanks.<br clear="all"><div><div dir="ltr"><div dir="ltr">--Junchao Zhang</div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 10, 2023 at 12:50 AM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">I think it should be something like this, but I'm not very fluent in Fortran C interop syntax. Any advice would be appreciated. Thanks<br><br><div style="color:rgb(255,255,255);background-color:rgb(0,36,81);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(187,218,255)">PETSC_EXTERN</span> <span style="color:rgb(235,187,255)">void</span> <span style="color:rgb(187,218,255)">petscsfcreatesectionsf</span>(<span style="color:rgb(255,238,173)">PetscSF</span> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">sf</span>, <span style="color:rgb(255,238,173)">PetscSection</span> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">rootSection</span>, <span style="color:rgb(255,238,173)">F90Array1d</span> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">aremoteOffsets</span>, <span style="color:rgb(255,238,173)">PetscSection</span> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">leafSection</span>, <span style="color:rgb(255,238,173)">PetscSF</span> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">sectionSF</span>, <span style="color:rgb(235,187,255)">int</span> <span style="color:rgb(153,255,255)">*</span> <span style="color:rgb(255,197,143)">ierr</span> <span style="color:rgb(187,218,255)">PETSC_F90_2PTR_PROTO</span>(remoteoffsetsd))</div><div>{</div><br><div> <span style="color:rgb(235,187,255)">int</span> <span style="color:rgb(153,255,255)">*</span> <span style="color:rgb(255,157,164)">remoteOffsets</span>;</div><div> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">ierr</span> <span style="color:rgb(153,255,255)">=</span> <span style="color:rgb(187,218,255)">F90Array1dAccess</span><span style="color:rgb(187,218,255)">(</span><span style="color:rgb(255,197,143)">aremoteOffsets</span><span style="color:rgb(187,218,255)">, </span><span style="color:rgb(255,157,164)">PETSC_INT</span><span style="color:rgb(187,218,255)">, (</span><span style="color:rgb(235,187,255)">void</span><span style="color:rgb(153,255,255)">**</span><span style="color:rgb(187,218,255)">) </span><span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">remoteOffsets</span><span style="color:rgb(187,218,255)"> </span><span style="color:rgb(187,218,255)">PETSC_F90_2PTR_PARAM</span><span style="color:rgb(187,218,255)">(remoteoffsetsd))</span>;<span style="color:rgb(235,187,255)">if</span> (<span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">ierr</span>) <span style="color:rgb(235,187,255)">return</span>;</div><div> <span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">ierr</span> <span style="color:rgb(153,255,255)">=</span> <span style="color:rgb(187,218,255)">PetscSFCreateSectionSF</span><span style="color:rgb(187,218,255)">(</span><span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">sf</span><span style="color:rgb(187,218,255)">,</span><span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">rootSection</span><span style="color:rgb(187,218,255)">, </span><span style="color:rgb(153,255,255)">&</span><span style="color:rgb(255,157,164)">remoteOffsets</span><span style="color:rgb(187,218,255)">,</span><span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">leafSection</span><span style="color:rgb(187,218,255)">,</span><span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">sectionSF</span><span style="color:rgb(187,218,255)">)</span>;<span style="color:rgb(235,187,255)">if</span> (<span style="color:rgb(153,255,255)">*</span><span style="color:rgb(255,197,143)">ierr</span>) <span style="color:rgb(235,187,255)">return</span>; </div><br><div>} </div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 9, 2023 at 11:41 PM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">Hi Junchao<br><br>Thanks again for your help in November. I've been using the your merge request branch quite heavily. Would it be possible to add a petscsfcreatesectionsf interface as well?<br>I'm trying to write it myself using your commits as a guide but I have been struggling with handling the section parameter properly. <br><br>Sincerely <br>Nicholas</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 19, 2022 at 9:44 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@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"><div dir="ltr"><br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 19, 2022 at 8:05 PM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">Hi<br><br>Thanks, this is awesome. Thanks for the very prompt fix. Just one question: will the array outputs on the fortran side copies (and need to be deallocated) or direct access to the dmplex? <br></div></blockquote><div>Direct access to internal data; no need to deallocate</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"><br>Sincerely<br>Nicholas</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 19, 2022 at 8:21 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@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">Hi, Nicholas,<br> See this MR, <a href="https://gitlab.com/petsc/petsc/-/merge_requests/5860" target="_blank">https://gitlab.com/petsc/petsc/-/merge_requests/5860</a><br> It is in testing, but you can try branch jczhang/add-petscsf-fortran to see if it works for you.<br><br> Thanks.<br>--Junchao Zhang<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Nov 19, 2022 at 4:16 PM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">Hi Junchao<br><br>Thanks. I was wondering if there is any update on this. I may write a small interface for those two routines myself in the interim but I'd appreciate any insight you have. <br><br>Sincerely<br>Nicholas</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 16, 2022 at 10:39 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@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">Hi, <span style="color:rgb(0,0,0);font-family:arial">Nicholas,</span><div><font color="#000000" face="arial"> I will have a look and get back to you. </font></div><div><font color="#000000" face="arial"> Thanks.</font></div><div><div><div dir="ltr"><div dir="ltr">--Junchao Zhang</div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 16, 2022 at 9:27 PM Nicholas Arnold-Medabalimi <<a href="mailto:narnoldm@umich.edu" target="_blank">narnoldm@umich.edu</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">Hi Petsc Users<br><br>I'm in the process of adding some Petsc for mesh management into an existing Fortran Solver. It has been relatively straightforward so far but I am running into an issue with using PetscSF routines. Some like the PetscSFGetGraph work no problem but a few of my routines require the use of PetscSFGetLeafRanks and PetscSFGetRootRanks and those don't seem to be in the fortran interface and I just get a linking error. I also don't seem to see a PetscSF file in the finclude. Any clarification or assistance would be appreciated.<br><br><br>Sincerely<br>Nicholas<br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></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 style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></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 style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></div></div></div></div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></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 style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></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 style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></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 style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></div></div></div></div></div>
</blockquote></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div style="font-family:arial;font-size:small"><font color="#000000">Nicholas Arnold-Medabalimi<br><br></font><span style="font-family:sans-serif;font-size:14px">Ph.D. Candidate</span><font color="#000000"><br>Computational Aeroscience Lab<br>University of Michigan</font></div></div></div></div></div>