codata_capi.f90 Source File


This file depends on

sourcefile~~codata_capi.f90~~EfferentGraph sourcefile~codata_capi.f90 codata_capi.f90 sourcefile~codata_api.f90 codata_api.f90 sourcefile~codata_capi.f90->sourcefile~codata_api.f90 sourcefile~codata_version.f90 codata_version.f90 sourcefile~codata_api.f90->sourcefile~codata_version.f90

Files dependent on this one

sourcefile~~codata_capi.f90~~AfferentGraph sourcefile~codata_capi.f90 codata_capi.f90 sourcefile~codata.f90 codata.f90 sourcefile~codata.f90->sourcefile~codata_capi.f90

Source Code

module codata__capi
    !! C API.
    !! See [specs](../page/specs/capi.html).
use codata__api, only: get_version
use iso_c_binding, only: c_ptr, c_null_char, c_loc
implicit none
private

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

public :: capi_get_version

contains


function capi_get_version()bind(C, name="codata_get_version")result(cptr)
    !! C API for [[codata__api(module):get_version(function)]].

    type(c_ptr) :: cptr !! C pointer to a string indicating the version.

    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 codata__capi