<div dir="ltr"><div dir="ltr">On Fri, Jun 30, 2023 at 10:48 AM Ngoc Mai Monica Huynh <<a href="mailto:ngocmaimonica.huynh@unipv.it">ngocmaimonica.huynh@unipv.it</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 style="overflow-wrap: break-word;">Hi,<div>yes, it runs and now also my code.</div><div>I moved it from the extension .F to .F90.</div><div>(With my older codes the extension .F still works fine, but not with this one)</div></div></blockquote><div><br></div><div>Yes, you need .F90 to properly handle the interface definitions.</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 style="overflow-wrap: break-word;"><div>Thank you for the patience and support!</div><div><span style="white-space:pre-wrap">        </span>Monica<br><div><br><blockquote type="cite"><div>On 30 Jun 2023, at 15:54, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:</div><br><div><div><div><br></div>  I glued your code fragment into a stand-alone program and it runs fine for me on 16 ranks. Does this simple program run for you?<div><br></div><div><div>     program main</div><div>#include <petsc/finclude/petscdm.h></div><div>      use petsc</div><div>      implicit none</div><div>      integer ierr</div><div><br></div><div>      MPI_Comm comm</div><div>      DM da3d</div><div>      ISLocalToGlobalMapping map</div><div>      PetscInt nel,nen</div><div>      PetscInt, pointer :: e_loc(:)</div><div><br></div><div>      PetscCallA(PetscInitialize(ierr))</div><div>      comm = PETSC_COMM_WORLD</div><div>      call DMDACreate3d(comm,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,  &</div><div>     &                  DM_BOUNDARY_NONE,DMDA_STENCIL_BOX,433,41,29,  &</div><div>     &                  8,2,1,3,1,PETSC_NULL_INTEGER, &</div><div>     &                  PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,  &</div><div>     &                  da3d,ierr)</div><div>      call DMSetMatType(da3d,MATIS,ierr)</div><div>      call DMSetFromOptions(da3d,ierr)</div><div>      call DMDASetElementType(da3d,DMDA_ELEMENT_Q1,ierr)</div><div>      call DMSetUp(da3d,ierr)</div><div>      call DMGetLocalToGlobalMapping(da3d,map,ierr)</div><div><br></div><div>      call DMDAGetElements(da3d,nel,nen,e_loc,ierr)</div><div>      call DMDARestoreElements(da3d,nel,nen,e_loc,ierr)</div><div>      PetscCallA(DMDestroy(da3d,ierr))</div><div><br></div><div>      PetscCallA(PetscFinalize(ierr)</div><div><br></div><div><br></div><div><br><blockquote type="cite"><div>On Jun 30, 2023, at 9:21 AM, Ngoc Mai Monica Huynh <<a href="mailto:ngocmaimonica.huynh@unipv.it" target="_blank">ngocmaimonica.huynh@unipv.it</a>> wrote:</div><br><div><div style="overflow-wrap: break-word;">Yes, I have the #include at the top of the code.<div><br></div><div>Thank you very much for your help.</div><div>I’ll let you know if I have any improvements from my side.</div><div>Looking forward to hearing from you.</div><div><br></div><div>Thanks,</div><div><span style="white-space:pre-wrap">        </span>Monica<br><div><div><br><blockquote type="cite"><div>On 30 Jun 2023, at 15:08, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="ltr">On Fri, Jun 30, 2023 at 8:38 AM Ngoc Mai Monica Huynh <<a href="mailto:ngocmaimonica.huynh@unipv.it" target="_blank">ngocmaimonica.huynh@unipv.it</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>Yes, it compiles and run correctly<div><span style="white-space:pre-wrap"></span></div></div></blockquote><div><br></div><div>Okay, then we try to alter that example until it looks like your test.</div><div><br></div><div>One thing is the #include at the top. Do you have that in your code? If Fortran does not find the interface,</div><div>then it will just SEGV.</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><div><span style="white-space:pre-wrap">       </span>Monica<br><div><br><blockquote type="cite"><div>On 30 Jun 2023, at 12:50, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="ltr">On Fri, Jun 30, 2023 at 6:47 AM Ngoc Mai Monica Huynh <<a href="mailto:ngocmaimonica.huynh@unipv.it" target="_blank">ngocmaimonica.huynh@unipv.it</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>Hi,<div><br></div><div>I have no problem now in compiling, thank you for providing the Fortran interface.</div><div>I have a follow up question.</div><div>When running the code, I get this error, which I’m pretty sure it is related to DMDAGetElements(), since up to that line everything works fine.</div><div><br></div><div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: ------------------------------------------------------------------------</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: or see<span> </span><a href="https://petsc.org/release/faq/#valgrind" target="_blank">https://petsc.org/release/faq/#valgrind</a><span> </span>and<span> </span><a href="https://petsc.org/release/faq/" target="_blank">https://petsc.org/release/faq/</a></span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: ---------------------  Stack Frames ------------------------------------</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: No error traceback is available, the problem could be in the main program. </span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">--------------------------------------------------------------------------</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">with errorcode 59.</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo;min-height:20px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">You may or may not see output from other processes, depending on</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">exactly when Open MPI kills them.</span></div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">—————————————————————————————————————</span></div></div><div style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-stretch:normal;font-size:17px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><span style="font-family:Helvetica;font-size:14px">The lines of code I’m working on are the following:</span></span></div><div><br></div><div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">      integer ierr</span></div></div><div><br></div><div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">      MPI_Comm comm</span></div></div><div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">      DM da3d</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">      ISLocalToGlobalMapping map</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">     <span> </span>PetscInt nel,nen</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">     <span> </span>PetscInt, pointer :: e_loc(:)</span></div></span></div></div></div><div><br></div><div><div style="margin:0px;font-stretch:normal;line-height:normal;font-family:Menlo"><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">      </span><span style="font-variant-ligatures:no-common-ligatures">call</span><span style="font-variant-ligatures:no-common-ligatures"><span> </span>DMDACreate3d(comm,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">&</span><span style="font-variant-ligatures:no-common-ligatures">                 <span> </span>DM_BOUNDARY_NONE,DMDA_STENCIL_BOX,433,41,29,</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">&</span><span style="font-variant-ligatures:no-common-ligatures">                 <span> </span>8,2,1,</span><span style="font-variant-ligatures:no-common-ligatures">3</span><span style="font-variant-ligatures:no-common-ligatures">,</span><span style="font-variant-ligatures:no-common-ligatures">1</span><span style="font-variant-ligatures:no-common-ligatures">,PETSC_NULL_INTEGER,</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">&</span><span style="font-variant-ligatures:no-common-ligatures">                 <span> </span>PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">&</span><span style="font-variant-ligatures:no-common-ligatures">                 <span> </span>da3d,ierr)</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">      </span><span style="font-variant-ligatures:no-common-ligatures">call</span><span style="font-variant-ligatures:no-common-ligatures"><span> </span>DMSetMatType(da3d,MATIS,ierr)</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">     <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">call</span><span style="font-variant-ligatures:no-common-ligatures"><span> </span>DMSetFromOptions(da3d,ierr)</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">     <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">call</span><span style="font-variant-ligatures:no-common-ligatures"><span> </span>DMDASetElementType(da3d,DMDA_ELEMENT_Q1,ierr)</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">     <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">call</span><span style="font-variant-ligatures:no-common-ligatures"><span> </span>DMSetUp(da3d,ierr)</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">     <span> </span></span><span style="font-variant-ligatures:no-common-ligatures">call</span><span style="font-variant-ligatures:no-common-ligatures"><span> </span>DMGetLocalToGlobalMapping(da3d,map,ierr)</span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-stretch:normal;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">     <span> </span><span style="font-variant-ligatures:no-common-ligatures">call</span><span> </span>DMDAGetElements(da3d,nel,nen,e_loc,ierr)</span></div></span></div></div></div><div><div><br></div><div>By printing in a dummy way any kind of message before and after DMDAGetElements(), I cannot pass over it.</div><div>Unfortunately, I cannot run with the debug option on this machine.</div><div>Am I calling the routine in a wrong way?</div></div></div></blockquote><div><br></div><div>Does</div><div><br></div><div> <span> </span>src/dm/tutorials/ex11f90.F90</div><div><br></div><div>run for you?</div><div><br></div><div> <span> </span>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><div><div>Thanks,</div><div><span style="white-space:pre-wrap"> </span>Monica</div><div><br></div><div><br><blockquote type="cite"><div>On 29 Jun 2023, at 21:09, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="ltr">On Thu, Jun 29, 2023 at 3:05 PM Ngoc Mai Monica Huynh <<a href="mailto:ngocmaimonica.huynh@unipv.it" target="_blank">ngocmaimonica.huynh@unipv.it</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="auto"><div dir="ltr"></div><div dir="ltr">Thank you.</div><div dir="ltr">Does this mean that DMDARestoreElements() is supported as well now? </div><div dir="ltr"></div></div></blockquote><div><br></div><div>Yes.</div><div><br></div><div> Thanks,</div><div><br></div><div>   <span> </span>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="auto"><div dir="ltr">Monica</div><div dir="ltr"><br></div><div dir="ltr"><br><blockquote type="cite">Il giorno 29 giu 2023, alle ore 20:17, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> ha scritto:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div><br></div> <span> </span>The code is ready in the branch <b style="color:rgb(200,20,201);font-family:Menlo;font-size:14px">barry/2023-06-29/add-dmdagetelements-fortran </b><a href="https://gitlab.com/petsc/petsc/-/merge_requests/6647" target="_blank">https://gitlab.com/petsc/petsc/-/merge_requests/6647</a><div><br></div><div> <span> </span>Barry</div><div><br><div><br><blockquote type="cite"><div>On Jun 29, 2023, at 12:41 PM, Ngoc Mai Monica Huynh <<a href="mailto:ngocmaimonica.huynh@unipv.it" target="_blank">ngocmaimonica.huynh@unipv.it</a>> wrote:</div><br><div><div>That would be amazing, thank you very much!<br><span style="white-space:pre-wrap">       </span>Monica<br><br><blockquote type="cite">On 29 Jun 2023, at 18:38, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<br><br><br>I can provide the Fortran interface this afternoon.<br><br> Barry<br><br><br><blockquote type="cite">On Jun 29, 2023, at 10:48 AM, Ngoc Mai Monica Huynh <<a href="mailto:ngocmaimonica.huynh@unipv.it" target="_blank">ngocmaimonica.huynh@unipv.it</a>> wrote:<br><br>Hi everyone,<span> </span><br><br>I would need to use the routine DMDAGetElements() in our Fortran code.<br>However, as I read from the manual, there is no Fortran support for this routine.<br>Is there any similar alternative there?<br><br>Many thanks!<br>Best regards,<br><span style="white-space:pre-wrap">      </span>Monica Huynh<br></blockquote><br></blockquote><br></div></div></blockquote></div><br></div></div></blockquote></div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">--<span> </span></span><br><div dir="ltr" class="gmail_signature"><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></div></div></div></div></div></div></div></div></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">--<span> </span></span><br><div dir="ltr" class="gmail_signature"><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></div></div></div></div></div></div></div></div></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">--<span> </span></span><br><div dir="ltr" class="gmail_signature"><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></div></div></div></div></div></div></div></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div></div></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><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>