Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29253 Discussions

Need help on writing C interface from a fortran subroutine

congcongkx
Beginner
598 Views
hi all,
I need to create a C inteface for the following subroutine:

SUBROUTINE CUBATR_X (DIMENS,NumFun,Integrand,NumRgn,Vertices,RgType,Value,AbsErr, IFAIL,Neval,EpsAbs,EpsRel,Restart,MinPts,MaxPts,Key,Job,Tune)

But there are two special parameters I am not sure about the translation:

1. Integrand is a interface to array-valued function
INTERFACE
FUNCTION Integrand(NUMFUN,X) RESULT(Value)
USE Precision_Model
INTEGER, INTENT(IN) :: NUMFUN
REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X
REAL(kind=stnd), DIMENSION(NUMFUN) :: Value
END FUNCTION Integrand
END INTERFACE
typedef float* (*integrand_t)(const int*, const float*) ????

2. REAL(kind=stnd), INTENT(IN), DIMENSION(:,:,:) :: Vertices
float ***Vertices ?????
besides, what does "kind=stnd" mean?
I found that "stnd = Selected_Real_Kind ( 12, 50 )". should I use "double" instead of "float" in this case?

thanks in advance
0 Kudos
2 Replies
jeffrey_t_b
Beginner
598 Views
When I have run into bad ones like that, I usually end up writing a wrapper function in fortran (with arguments that are easy to translate to C), and then call that wrapper instead.

Good luck!
0 Kudos
congcongkx
Beginner
598 Views
thanks for your suggestion.
but I have no idea of fortran programming at all. Could you please write a wrapper for me?
thanks
0 Kudos
Reply