The subroutine Rule_Tn
in the Fortran library CUBPACK needs a parameter Integrand
describing the integrated vector function. It's a
INTERFACE
FUNCTION Integrand(NF,X) RESULT(Value)
USE Precision_Model
INTEGER, INTENT(IN) :: NF
REAL(KIND=STND), DIMENSION(:), INTENT(IN) :: X
REAL(KIND=STND), DIMENSION(NF) :: Value
END FUNCTION Integrand
END INTERFACE
Since I want to call Rule_Tn
from C code I need to define a function type in C exactly matching to this interface above. Thus I tried figure out how a Fortran function returns arrays. At first I supposed the following C signature
void Integrand(double* value, const int* nf, const int* x);
matches to the interface above. But far wrong! I got a segfault. And I already tested that double is the corresponding type to REAL(KIND=STND)
, the STND
comes out of the module Precision_Model
.
Now can anyone tell me what's the right signature? I'm using the GNU Fortran and C compilers.