aur1
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору ! compile mingw32-gfortran.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 iWspSPT(p, t) bind(c) !gcc$ attributes stdcall :: iWspSPT double precision, VALUE :: p double precision, VALUE :: t end function iWspSPT 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 :: iwspVUSHCVWDERPTPT real*8, intent(in) :: p real*8, intent(in) :: t integer*4, value :: v integer*4, value :: u integer*4, value :: s integer*4, value :: h integer*4, value :: Cv integer*4, value :: w integer*4, value :: DVDPt integer*4, value :: DUDPt integer*4, value :: DSDPt integer*4, value :: DHDPt integer*4, value :: DVDTp integer*4, value :: DUDPTp integer*4, value :: DSDPTp integer*4, value :: DHDTp end function iwspVUSHCVWDERPTPT end interface integer(c_intptr_t) :: hMod type(c_funptr) :: cProc procedure(iWspSPT), bind(c), pointer :: WspSPT double precision :: p, t, ret type(c_funptr) :: cProc2 procedure(iwspVUSHCVWDERPTPT), bind(c), pointer :: wspVUSHCVWDERPTPT double precision :: v, u, s, h, Cv, w double precision DVDPt, DUDPt, DSDPt, DHDPt double precision DVDTp, DUDPTp, DSDPTp, DHDTp double precision ret1 hMod = LoadLibrary(c_char_'OKAWSP6' // c_null_char) cProc = GetProcAddress(hMod, c_char_'wspSPT' // c_null_char) cProc2 = GetProcAddress(hMod, c_char_'wspVUSHCVWDERPTPT' // c_null_char) call c_f_procpointer(cProc2, wspVUSHCVWDERPTPT) call c_f_procpointer(cProc, WspSPT) p = 36000000 t = 410.1 ret = WspSPT(p, t) print *, ret ret1=wspVUSHCVWDERPTPT(p, t, LOC(v), LOC(u), LOC(s), LOC(h), LOC(Cv), LOC(w), & & LOC(DVDPt),LOC(DUDPt),LOC(DSDPt),LOC(DHDPt),LOC(DVDTp), & & LOC(DUDPTp),LOC(DSDPTp),LOC(DHDTp)) print *, v print *, u print *, s print *, h print *, Cv end program main |