Discussion:
[petsc-users] Calling DMCompositeCreate() in Fortran
Bay, Yong Yi
2015-11-06 18:39:19 UTC
Permalink
Hi,

I noticed that DMCompositeCreate() does not exist in fortran format. What would be the best way to call this function if my code is written in Fortran? I tried using iso_c_binding as follows and it compiles but crashes on execution.

interface
subroutine DMCompositeCreate(comm, dm) bind(C,name="DMCompositeCreate")
import
integer(c_int), value :: comm
integer(c_long), value :: dm
end subroutine DMCompositeCreate
end interface
Barry Smith
2015-11-06 19:33:44 UTC
Permalink
When something crashes it is time to run in the debugger and determine what is causing the crash. The code looks ok and we could only speculate wildly why it crashes. Running in the debugger will likely revel the problem in less than 3 minutes.

Barry

> On Nov 6, 2015, at 12:39 PM, Bay, Yong Yi <***@illinois.edu> wrote:
>
> Hi,
>
> I noticed that DMCompositeCreate() does not exist in fortran format. What would be the best way to call this function if my code is written in Fortran? I tried using iso_c_binding as follows and it compiles but crashes on execution.
>
> interface
> subroutine DMCompositeCreate(comm, dm) bind(C,name="DMCompositeCreate")
> import
> integer(c_int), value :: comm
> integer(c_long), value :: dm
> end subroutine DMCompositeCreate
> end interface
Bay, Yong Yi
2015-11-06 21:51:58 UTC
Permalink
Thanks for the advice. I tried running in gdb, and the crash occurred in DMCreate. However I didn't manage to figure out the reason. After looking at what DMCompositeCreate actually does, I simply called DMCreate and DMSetType instead (binding DMSetType instead) and this worked.

Yong Yi
________________________________________
From: Barry Smith [***@mcs.anl.gov]
Sent: Friday, November 06, 2015 1:33 PM
To: Bay, Yong Yi
Cc: petsc-***@mcs.anl.gov
Subject: Re: [petsc-users] Calling DMCompositeCreate() in Fortran

When something crashes it is time to run in the debugger and determine what is causing the crash. The code looks ok and we could only speculate wildly why it crashes. Running in the debugger will likely revel the problem in less than 3 minutes.

Barry

> On Nov 6, 2015, at 12:39 PM, Bay, Yong Yi <***@illinois.edu> wrote:
>
> Hi,
>
> I noticed that DMCompositeCreate() does not exist in fortran format. What would be the best way to call this function if my code is written in Fortran? I tried using iso_c_binding as follows and it compiles but crashes on execution.
>
> interface
> subroutine DMCompositeCreate(comm, dm) bind(C,name="DMCompositeCreate")
> import
> integer(c_int), value :: comm
> integer(c_long), value :: dm
> end subroutine DMCompositeCreate
> end interface
Loading...