Unable to pass array from FORTRAN to C

后端 未结 2 2054
别跟我提以往
别跟我提以往 2020-12-22 02:15

I am trying to pass a single dimension array from a FORTRAN program to C.

The C function is called but the values that it holds are garbage. But whereas if I try ca

2条回答
  •  执念已碎
    2020-12-22 02:40

    Passing arrays between Fortran and C is a non-trivial problem. The particular C and Fortran compilers matter.

    The first problem I see is that you specify double to match real*4. That is certainly invalid on almost all platforms. Declare the C function as:

    int test_func (float *a)
    

    This could work on some platforms, though many Fortran compilers pass the address of an "array descriptor" and not the array itself. Check the documentation for the Fortran compiler.

提交回复
热议问题