aur1
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору ! compile with mingw-w64: ! gfortran test.f90 -o test.exe program main use, intrinsic :: iso_c_binding implicit none interface function LoadLibrary(LibName) bind(c,name='LoadLibraryA') use, intrinsic :: iso_c_binding, only: c_intptr_t, c_char !gcc$ attributes stdcall :: LoadLibrary character(kind=c_char) :: LibName(*) integer(c_intptr_t) :: LoadLibrary end function LoadLibrary function GetProcAddress(hModule, ProcName) bind(c, name='GetProcAddress') use, intrinsic :: iso_c_binding, only: c_funptr, c_intptr_t, c_char !gcc$ attributes stdcall :: GetProcAddress type(c_funptr) :: GetProcAddress integer(c_intptr_t), value :: hModule character(kind=c_char) :: ProcName(*) end function GetProcAddress end interface abstract interface double precision function iwspVUSHCVWDERPTPT(p, t, & & v, u, s, h, Cv, w, & & DVDPt, DUDPt, DSDPt, DHDPt, DVDTp, DUDPTp, DSDPTp, DHDTp) bind(c) !gcc$ attributes stdcall :: iwspVUSHCVWDERPTP real*8, intent(in) :: p real*8, intent(in) :: t real*8, intent(out) :: v real*8, intent(out) :: u real*8, intent(out) :: s real*8, intent(out) :: h real*8, intent(out) :: Cv real*8, intent(out) :: w real*8, intent(out) :: DVDPt real*8, intent(out) :: DUDPt real*8, intent(out) :: DSDPt real*8, intent(out) :: DHDPt real*8, intent(out) :: DVDTp real*8, intent(out) :: DUDPTp real*8, intent(out) :: DSDPTp real*8, intent(out) :: DHDTp end function iwspVUSHCVWDERPTPT end interface integer(c_intptr_t) :: hMod type(c_funptr) :: cProc procedure(iwspVUSHCVWDERPTPT), bind(c), pointer :: wspVUSHCVWDERPTPT double precision :: p, t double precision :: v=0, u=0 double precision :: s=0, h=0, Cv=0, w=0, DVDPt=0 double precision :: DUDPt=0, DSDPt=0, DHDPt=0 double precision :: DVDTp=0,DUDPTp=0, DSDPTp=0, DHDTp=0 double precision :: ret1 hMod = LoadLibrary(c_char_'OKAWSP6_64' // c_null_char) cProc = GetProcAddress(hMod, c_char_'wspVUSHCVWDERPTPT' // c_null_char) call c_f_procpointer(cProc,wspVUSHCVWDERPTPT) p = 36000000.0 t = 410.1 ret1=wspVUSHCVWDERPTPT(p, t, v, u, s, h, Cv, w, DVDPt,DUDPt,DSDPt,DHDPt,DVDTp,DUDPTp,DSDPTp,DHDTp) print *, v print *, u print *, DVDPt print *, ret1 print *, p end program main |