capi_version.f90 Source File


This file depends on

sourcefile~~capi_version.f90~~EfferentGraph sourcefile~capi_version.f90 capi_version.f90 sourcefile~iapws_version.f90 iapws_version.f90 sourcefile~capi_version.f90->sourcefile~iapws_version.f90

Files dependent on this one

sourcefile~~capi_version.f90~~AfferentGraph sourcefile~capi_version.f90 capi_version.f90 sourcefile~capi.f90 capi.f90 sourcefile~capi.f90->sourcefile~capi_version.f90 sourcefile~iapws.f90 iapws.f90 sourcefile~iapws.f90->sourcefile~capi.f90

Source Code

module iapws__capi_version
    !! Version: C API.
    use iso_c_binding, only: c_null_char, c_ptr, c_loc
    use iapws__version
    implicit none
    private

    character(len=:), allocatable, target :: version_c

    public :: capi_get_version

contains

function capi_get_version()bind(c,name="iapws_get_version")result(cptr)
    !! Get the version.
    implicit none
    
    ! Returns   
    type(c_ptr) :: cptr !! Pointer to version string.

    character(len=:), pointer :: fptr
    fptr => get_version() 

    if(allocated(version_c))then
        deallocate(version_c)
    endif
    allocate(character(len=len(fptr)+1) :: version_c)

    version_c = fptr // c_null_char
    cptr = c_loc(version_c)
end function

end module iapws__capi_version