[petsc-users] Fortran alternative for DMDAGetElements?

Matthew Knepley knepley at gmail.com
Fri Jun 30 08:08:30 CDT 2023


On Fri, Jun 30, 2023 at 8:38 AM Ngoc Mai Monica Huynh <
ngocmaimonica.huynh at unipv.it> 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 <knepley at gmail.com> wrote:
>
> On Fri, Jun 30, 2023 at 6:47 AM Ngoc Mai Monica Huynh <
> ngocmaimonica.huynh at unipv.it> 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 and
>> 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 <knepley at gmail.com> wrote:
>>
>> On Thu, Jun 29, 2023 at 3:05 PM Ngoc Mai Monica Huynh <
>> ngocmaimonica.huynh at unipv.it> 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 <bsmith at petsc.dev>
>>> ha scritto:
>>>
>>> 
>>>
>>>   The code is ready in the branch
>>> *barry/2023-06-29/add-dmdagetelements-fortran *
>>> https://gitlab.com/petsc/petsc/-/merge_requests/6647
>>>
>>>   Barry
>>>
>>>
>>> On Jun 29, 2023, at 12:41 PM, Ngoc Mai Monica Huynh <
>>> ngocmaimonica.huynh at unipv.it> wrote:
>>>
>>> That would be amazing, thank you very much!
>>> Monica
>>>
>>> On 29 Jun 2023, at 18:38, Barry Smith <bsmith at petsc.dev> wrote:
>>>
>>>
>>> I can provide the Fortran interface this afternoon.
>>>
>>>  Barry
>>>
>>>
>>> On Jun 29, 2023, at 10:48 AM, Ngoc Mai Monica Huynh <
>>> ngocmaimonica.huynh at unipv.it> 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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230630/203bf0c4/attachment-0001.html>


More information about the petsc-users mailing list