Intel Fortran 调用Delphi编制的DLL

Posted china3s

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Intel Fortran 调用Delphi编制的DLL相关的知识,希望对你有一定的参考价值。

module link_cont
  interface
    subroutine I_FileOpenCont (ncase,ndata,lpool,xfiles)
      integer(kind=4) :: ncase
      integer(kind=4) :: ndata
      integer(kind=4) :: lpool
      character(len=40), dimension(10) :: xfiles
    endsubroutine I_FileOpenCont
  endinterface
endmodule link_cont

program s
  use link_cont
  use Kernel32
  use , intrinsic :: ISO_C_Binding !// 标准模块
  implicit none
  type(C_FUNPTR) :: C_FileOpenCont !// C 语言指向函数的指针
  procedure(I_FileOpenCont) , pointer :: FileOpenCont !// fortran 指向函数的指针
  !<-------------------------------------------------------------------------------------------------------------------------------
  integer(kind=4)                  :: add
  integer(kind=4)                  :: hwnd
  integer(kind=4)                  :: n_case
  integer(kind=4)                  :: n_data
  integer(kind=4)                  :: lpool
  character(len=40), dimension(10) :: c_files
  logical                          :: fail
  logical                          :: syslink
  !<-------------------------------------------------------------------------------------------------------------------------------
  hwnd = LoadLibrary(control.dll//c_null_char)
  if (hwnd <= 0) then
    fail    = .true.
    syslink = .false.
    write(*,*) DLL Loading failure because control.dll was not found
    read(*,*)
  else
    write(*,*) Succeed Contempt DLL (control.dll) Loading
    add     = GetProcAddress(hWnd,FILEOPENCONT//c_null_char) !//获得地址(整数)
    C_FileOpenCont = transfer( add , C_FileOpenCont ) !//把整数的地址转换成 C 指针
    call C_F_PROCPOINTER( C_FileOpenCont , FileOpenCont ) !//把C指针转换成 fortran 指针
    call FileOpenCont(n_case,n_data,lpool,c_files)
  endif
end program s

在delphi和intel fortran下实证过。

以上是关于Intel Fortran 调用Delphi编制的DLL的主要内容,如果未能解决你的问题,请参考以下文章

intel visual fortran compiler干嘛用的

intel visual fortran 2013编译器怎么用

使用 Intel Visual Fortran + Microsoft Visual Studio 运行简单的 fortran 程序

Fortran 调用 C:如何获得有效的矢量化函数

使用 Notepad++ 和 Intel Fortran 编译器编译文件

intel fortran如何实现单机多核并行运算