[petsc-users] DMPlexGetCone in Fortran

Bernardo Rocha bernardomartinsrocha at gmail.com
Mon Apr 9 13:51:08 CDT 2018


OK, just found my mistake.

I was using other include files such as "petscksp.h" and etc that I needed
from previous codes.

I had to include ONLY
"#include <petsc/finclude/petsc.h90>"
to fix the problem.

After that the GetCone, GetTransitiveClosure and other routines returning
arrays stop
to result in Segmentation Fault.

It would be nice to give some warning when compiling to Fortran 90 and
including
the wrong header files.

Anyway, thanks.
Best regards,
Bernardo



On Sat, Apr 7, 2018 at 4:13 PM, Bernardo Rocha <
bernardomartinsrocha at gmail.com> wrote:

> OK, here is the entire code.
> I created a simple mesh to test DMPlex.
> As you can see, the GetCone is not working.
> As I said, I followed one of the examples for DMPlex using Fortran, I'm
> not an exper in F90.
>
> Best regards,
> Bernardo M. Rocha
>
>
> On Fri, Apr 6, 2018 at 11:48 PM, Matthew Knepley <knepley at gmail.com>
> wrote:
>
>> If you send the whole code, we can try it here. I am assuming that the
>> examples run for you.
>>
>>   Matt
>>
>> On Fri, Apr 6, 2018 at 5:47 PM, Bernardo Rocha <
>> bernardomartinsrocha at gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I can't get a a simple code to work for DMPlexGetCone.
>>> I have tried different ways of handling the array/pointer which is the
>>> third argument of DMPlexGetCone,
>>> but neither of them worked for me.
>>>
>>> The last version that I got compiling is this one, which is very much
>>> based on the
>>> following example: .../petsc-3.7.6/src/dm/impls/p
>>> lex/examples/tutorials/ex1f90.F
>>>
>>>     PetscInt, target, dimension(6) :: icone
>>>     PetscInt, pointer :: pIcone(:)
>>>
>>>     call DMPlexCreateFromCellList(PETSC_COMM_WORLD,
>>>      &                              ndim,numel,numnp,nen,PETSC_TRUE,
>>>      &                              ielement,ndim,xnodes,dm,ierr)
>>>       ...
>>>       call DMPlexGetCone(dm,0,pIcone,ierr)
>>>       write(*,*) icone(1),icone(2),icone(3),icone(4),icone(5),icone(6)
>>>       call DMPlexRestoreCone(dm,0,pIcone,ierr)
>>>
>>> I always get a segmentation fault.
>>>
>>> I've created a simple cuboid mesh with 2x2x2 hexaedral elements.
>>> Many other routines are working and give reasonable results.
>>>
>>> Output of DMView
>>>
>>> DM Object: 1 MPI processes
>>>   type: plex
>>> DM_0x84000000_0 in 3 dimensions:
>>>   0-cells: 27
>>>   1-cells: 66
>>>   2-cells: 44
>>>   3-cells: 8
>>> Labels:
>>>   depth: 4 strata of sizes (27, 66, 44, 8)
>>>
>>>
>>>
>>>
>>> On Thu, Apr 5, 2018 at 10:57 PM, Bernardo Rocha <
>>> bernardomartinsrocha at gmail.com> wrote:
>>>
>>>> OK, thanks a lot.
>>>> I had to rename the files and add -ffixed-form as argument to the
>>>> compiler.
>>>> Best regards,
>>>> Bernardo
>>>>
>>>> On Thu, Apr 5, 2018 at 8:21 PM, Matthew Knepley <knepley at gmail.com>
>>>> wrote:
>>>>
>>>>> On Thu, Apr 5, 2018 at 7:16 PM, Bernardo Rocha <
>>>>> bernardomartinsrocha at gmail.com> wrote:
>>>>>
>>>>>> Hello everyone,
>>>>>>
>>>>>> I've been trying to use DMPlex in a Fortran 77 application
>>>>>> (unfortunately this is legacy code and I can't move to F90).
>>>>>>
>>>>>> Is there a way to use DMPlexGetCone on it?
>>>>>> Although the documentation online says it is only available for F90,
>>>>>> I'm wondering if there is a trick like the ones in the users manual
>>>>>> for routines
>>>>>> that return an array. I tried, but I'm not sure it it is right.
>>>>>>
>>>>>
>>>>> We have standardized our array handling with F90, and I don't think we
>>>>> will go back
>>>>> to supporting new things for F77-style arrays.
>>>>>
>>>>> That being said, I think all you have to do is compile that source
>>>>> with an F90 compiler. You
>>>>> should not have to change anything. If you want the F90 array to look
>>>>> like an F77 array,
>>>>> just pass it as a function argument (I think this works).
>>>>>
>>>>>   Thanks,
>>>>>
>>>>>      Matt
>>>>>
>>>>>
>>>>>> Best regards,
>>>>>> Bernardo M. Rocha
>>>>>>
>>>>> --
>>>>> 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.caam.rice.edu/~mk51/>
>>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>> 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.caam.rice.edu/~mk51/>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180409/9a74c652/attachment-0001.html>


More information about the petsc-users mailing list