Fortran Interface:
interface
logical function NodeData_Export(NodeNum,Node_X,Node_Y,Node_Z,Node_JN,Node_JS) bind(c,name='CUDAMallocNodeData_Export')
use data_def
integer, value:: NodeNum
real(gk):: Node_X(NodeNum)
real(gk):: Node_Y(NodeNum)
real(gk):: Node_Z(NodeNum)
integer :: Node_JN(NodeNum*6)
integer :: Node_JS(NodeNum*3)
end function
end interface
C++函数声明与实现:
extern "C" bool __declspec(dllexport) NodeData_Export(const int NodeNum, float Node_X[], float Node_Y[], float Node_Z[], int Node_JN[], int Node_JS[]);
bool NodeData_Export(const int NodeNum, float Node_X[], float Node_Y[], float Node_Z[], int Node_JN[], int Node_JS[])
{
……
}
Fortran 调用:(Fortran调用的函数要添加interface的module)
DO I = 1,NJ
Node_X(I) = NOD(I)%X
Node_Y(I) = NOD(I)%Y
Node_Z(I) = NOD(I)%Z
Node_JN((I-1)*6 + 1:I*6) = NOD(I)%JN(1:6)
Node_JS((I-1)*3 + 1:I*3) = NOD(I)%JS(4:6)
END DO
ERR = NodeData_Export(NJ,Node_X,Node_Y,Node_Z,Node_JN,Node_JS)