[petsc-users] tmat is not C interoperable

Anthony Ruth Anthony.J.Ruth.12 at nd.edu
Thu Jun 7 12:37:00 CDT 2018


Hello,

I am trying to call a function in a C library from fortran. The fortran
code should pass a Mat object to the C code. I defined the interface within
the fortran code like this:

#include <petsc/finclude/petscmat.h>

interface
    subroutine MY_FUNC(A_Mat) bind ( C, name = "MY_FUNC" )
use petscmat
      Mat, intent(in) :: A_Mat
    end subroutine MY_FUNC
  end interface

When I try to compile the code it produces this error:

Variable ‘a_mat’ at (1) is a dummy argument to the BIND(C) procedure
‘MY_FUNC’ but is not C interoperable because derived type ‘tmat’ is not C
interoperable

My interpretation of the error is that there is some mismatch between the
Mat data type defined in fortran and the Mat data type defined in C, so
that I cannot pass one to the other. Is this true? Is there a compatible
way to pass the Mat? Are the C and fortran implementations actually
properly aligned and interchangeable so that all that is needed is
something to tell the compiler to try anyway? I tried changing the data
type of A_Mat to Integer Pointer (void *), but ran into a syntax error when
attempting that.

regards,
Anthony Ruth
NASA Space Technology Research Fellow
Condensed Matter Theory
University of Notre Dame
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180607/cc742b4a/attachment.html>


More information about the petsc-users mailing list