Hi,
yes, it runs and now also my code.
I moved it from the extension .F to .F90.
(With my older codes the extension .F still works fine, but not with this one)

Thank you for the patience and support!
        Monica

> On 30 Jun 2023, at 15:54, Barry Smith <[email protected]> wrote:
> 
> 
>   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?
> 
>      program main
> #include <petsc/finclude/petscdm.h>
>       use petsc
>       implicit none
>       integer ierr
> 
>       MPI_Comm comm
>       DM da3d
>       ISLocalToGlobalMapping map
>       PetscInt nel,nen
>       PetscInt, pointer :: e_loc(:)
> 
>       PetscCallA(PetscInitialize(ierr))
>       comm = PETSC_COMM_WORLD
>       call DMDACreate3d(comm,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,  &
>      &                  DM_BOUNDARY_NONE,DMDA_STENCIL_BOX,433,41,29,  &
>      &                  8,2,1,3,1,PETSC_NULL_INTEGER, &
>      &                  PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,  &
>      &                  da3d,ierr)
>       call DMSetMatType(da3d,MATIS,ierr)
>       call DMSetFromOptions(da3d,ierr)
>       call DMDASetElementType(da3d,DMDA_ELEMENT_Q1,ierr)
>       call DMSetUp(da3d,ierr)
>       call DMGetLocalToGlobalMapping(da3d,map,ierr)
> 
>       call DMDAGetElements(da3d,nel,nen,e_loc,ierr)
>       call DMDARestoreElements(da3d,nel,nen,e_loc,ierr)
>       PetscCallA(DMDestroy(da3d,ierr))
> 
>       PetscCallA(PetscFinalize(ierr)
> 
> 
> 
>> On Jun 30, 2023, at 9:21 AM, Ngoc Mai Monica Huynh 
>> <[email protected]> wrote:
>> 
>> Yes, I have the #include at the top of the code.
>> 
>> Thank you very much for your help.
>> I’ll let you know if I have any improvements from my side.
>> Looking forward to hearing from you.
>> 
>> Thanks,
>>      Monica
>> 
>>> On 30 Jun 2023, at 15:08, Matthew Knepley <[email protected] 
>>> <mailto:[email protected]>> wrote:
>>> 
>>> On Fri, Jun 30, 2023 at 8:38 AM Ngoc Mai Monica Huynh 
>>> <[email protected] <mailto:[email protected]>> wrote:
>>> Yes, it compiles and run correctly
>>> 
>>> Okay, then we try to alter that example until it looks like your test.
>>> 
>>> One thing is the #include at the top. Do you have that in your code? If 
>>> Fortran does not find the interface,
>>> then it will just SEGV.
>>> 
>>>   Thanks,
>>> 
>>>     Matt
>>>  
>>>     Monica
>>> 
>>>> On 30 Jun 2023, at 12:50, Matthew Knepley <[email protected] 
>>>> <mailto:[email protected]>> wrote:
>>>> 
>>>> On Fri, Jun 30, 2023 at 6:47 AM Ngoc Mai Monica Huynh 
>>>> <[email protected] <mailto:[email protected]>> wrote:
>>>> Hi,
>>>> 
>>>> I have no problem now in compiling, thank you for providing the Fortran 
>>>> interface.
>>>> I have a follow up question.
>>>> 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.
>>>> 
>>>> [0]PETSC ERROR: 
>>>> ------------------------------------------------------------------------
>>>> [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, 
>>>> probably memory access out of range
>>>> [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
>>>> [0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind 
>>>> <https://petsc.org/release/faq/#valgrind> and 
>>>> https://petsc.org/release/faq/ <https://petsc.org/release/faq/>
>>>> [0]PETSC ERROR: ---------------------  Stack Frames 
>>>> ------------------------------------
>>>> [0]PETSC ERROR: No error traceback is available, the problem could be in 
>>>> the main program. 
>>>> --------------------------------------------------------------------------
>>>> MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
>>>> with errorcode 59.
>>>> 
>>>> NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
>>>> You may or may not see output from other processes, depending on
>>>> exactly when Open MPI kills them.
>>>> —————————————————————————————————————
>>>> 
>>>> The lines of code I’m working on are the following:
>>>> 
>>>>       integer ierr
>>>> 
>>>>       MPI_Comm comm
>>>>       DM da3d
>>>>       ISLocalToGlobalMapping map
>>>>       PetscInt nel,nen
>>>>       PetscInt, pointer :: e_loc(:)
>>>> 
>>>>       call DMDACreate3d(comm,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,
>>>>      &                  DM_BOUNDARY_NONE,DMDA_STENCIL_BOX,433,41,29,
>>>>      &                  8,2,1,3,1,PETSC_NULL_INTEGER,
>>>>      &                  PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,
>>>>      &                  da3d,ierr)
>>>>       call DMSetMatType(da3d,MATIS,ierr)
>>>>       call DMSetFromOptions(da3d,ierr)
>>>>       call DMDASetElementType(da3d,DMDA_ELEMENT_Q1,ierr)
>>>>       call DMSetUp(da3d,ierr)
>>>>       call DMGetLocalToGlobalMapping(da3d,map,ierr)
>>>> 
>>>>       call DMDAGetElements(da3d,nel,nen,e_loc,ierr)
>>>> 
>>>> By printing in a dummy way any kind of message before and after 
>>>> DMDAGetElements(), I cannot pass over it.
>>>> Unfortunately, I cannot run with the debug option on this machine.
>>>> Am I calling the routine in a wrong way?
>>>> 
>>>> Does
>>>> 
>>>>   src/dm/tutorials/ex11f90.F90
>>>> 
>>>> run for you?
>>>> 
>>>>   Thanks,
>>>> 
>>>>      Matt
>>>>  
>>>> Thanks,
>>>>    Monica
>>>> 
>>>> 
>>>>> On 29 Jun 2023, at 21:09, Matthew Knepley <[email protected] 
>>>>> <mailto:[email protected]>> wrote:
>>>>> 
>>>>> On Thu, Jun 29, 2023 at 3:05 PM Ngoc Mai Monica Huynh 
>>>>> <[email protected] <mailto:[email protected]>> 
>>>>> wrote:
>>>>> Thank you.
>>>>> Does this mean that DMDARestoreElements() is supported as well now? 
>>>>> 
>>>>> Yes.
>>>>> 
>>>>>  Thanks,
>>>>> 
>>>>>     Matt
>>>>>  
>>>>> Monica
>>>>> 
>>>>> 
>>>>>> Il giorno 29 giu 2023, alle ore 20:17, Barry Smith <[email protected] 
>>>>>> <mailto:[email protected]>> ha scritto:
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>>   The code is ready in the branch 
>>>>>> barry/2023-06-29/add-dmdagetelements-fortran 
>>>>>> https://gitlab.com/petsc/petsc/-/merge_requests/6647 
>>>>>> <https://gitlab.com/petsc/petsc/-/merge_requests/6647>
>>>>>> 
>>>>>>   Barry
>>>>>> 
>>>>>> 
>>>>>>> On Jun 29, 2023, at 12:41 PM, Ngoc Mai Monica Huynh 
>>>>>>> <[email protected] <mailto:[email protected]>> 
>>>>>>> wrote:
>>>>>>> 
>>>>>>> That would be amazing, thank you very much!
>>>>>>>         Monica
>>>>>>> 
>>>>>>>> On 29 Jun 2023, at 18:38, Barry Smith <[email protected] 
>>>>>>>> <mailto:[email protected]>> wrote:
>>>>>>>> 
>>>>>>>> 
>>>>>>>> I can provide the Fortran interface this afternoon.
>>>>>>>> 
>>>>>>>>  Barry
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On Jun 29, 2023, at 10:48 AM, Ngoc Mai Monica Huynh 
>>>>>>>>> <[email protected] <mailto:[email protected]>> 
>>>>>>>>> wrote:
>>>>>>>>> 
>>>>>>>>> Hi everyone, 
>>>>>>>>> 
>>>>>>>>> I would need to use the routine DMDAGetElements() in our Fortran code.
>>>>>>>>> However, as I read from the manual, there is no Fortran support for 
>>>>>>>>> this routine.
>>>>>>>>> Is there any similar alternative there?
>>>>>>>>> 
>>>>>>>>> Many thanks!
>>>>>>>>> Best regards,
>>>>>>>>>       Monica Huynh
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> -- 
>>>>> What most experimenters take for granted before they begin their 
>>>>> experiments is infinitely more interesting than any results to which 
>>>>> their experiments lead.
>>>>> -- Norbert Wiener
>>>>> 
>>>>> https://www.cse.buffalo.edu/~knepley/ 
>>>>> <http://www.cse.buffalo.edu/~knepley/>
>>>> 
>>>> 
>>>> -- 
>>>> What most experimenters take for granted before they begin their 
>>>> experiments is infinitely more interesting than any results to which their 
>>>> experiments lead.
>>>> -- Norbert Wiener
>>>> 
>>>> https://www.cse.buffalo.edu/~knepley/ 
>>>> <http://www.cse.buffalo.edu/~knepley/>
>>> 
>>> 
>>> -- 
>>> What most experimenters take for granted before they begin their 
>>> experiments is infinitely more interesting than any results to which their 
>>> experiments lead.
>>> -- Norbert Wiener
>>> 
>>> https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
> 

Reply via email to