MODULE EXAMP
use , Intrinsic :: ISO_C_Binding
implicit none
TYPE EXAMP_A
INTEGER(4), value :: N
REAL(8), value :: M
!DEC$ ATTRIBUTES DLLEXPORT :: TYPE EXAMP_A
END TYPE EXAMP_A
END MODULE EXAMP
Integer Function Add(X,B) Bind(C,Name="Add")!
!DEC$ ATTRIBUTES DLLEXPORT :: Add
use , Intrinsic :: ISO_C_Binding
implicit none
integer , value :: X , B
Add = M*N(X + b)
end Function Add
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
[DllImport(@"J:\ConsoleApplication1\Dll1\Debug\Dll1.dll", EntryPoint = "Add")]
//DLL文件地址
extern static int Add(int A,int B);
extern static struct EXAMP_A
{int N
double M};
static void Main(string[] args)
{
N=2 //想通过C#的结构体向FORTRAN的TYPE类型赋值
M=0.5 //想通过C#的结构体向FORTRAN的TYPE类型赋值
int c = Add(1,2);
Console.WriteLine(c);
Console.Read();
}
}
}
单独.png (7.82 KB, 下载次数: 95)
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |