Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Вопросы программирования на FORTRAN (ФОРТРАН)

Модерирует : ShIvADeSt

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

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

Всего записей: 56 | Зарегистр. 28-08-2007 | Отправлено: 01:25 17-04-2021 | Исправлено: aur1, 08:51 17-04-2021
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Прикладное программирование » Вопросы программирования на FORTRAN (ФОРТРАН)


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru