load_library Function

public function load_library(name, path, global, err) result(lib)

Load a shared library and return a handle on it.

name may be a bare name ("kernels"), a file name ("libkernels.so.2") or a path ("./plugins/kernels.dll"). A name without extension is decorated with the platform prefix/suffix. If path is given, the library is searched only in that directory; otherwise the OS search rules apply (LD_LIBRARY_PATH, rpath, PATH, ...).

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: name

Library name, file name or path

character(len=*), intent(in), optional :: path

Optional directory to search in, instead of the OS search rules

logical, intent(in), optional :: global

Optional flag to make the library symbols available to libraries loaded afterwards (RTLD_GLOBAL). Ignored on Windows

type(state_type), intent(out), optional :: err

Optional state return flag. On error, if not requested, the code stops

Return Value type(shared_library_type)

Handle on the loaded library


Source Code

    function load_library(name, path, global, err) result(lib)
        !> Library name, file name or path
        character(len=*), intent(in) :: name
        !> Optional directory to search in, instead of the OS search rules
        character(len=*), intent(in), optional :: path
        !> Optional flag to make the library symbols available to libraries
        !> loaded afterwards (`RTLD_GLOBAL`). Ignored on Windows
        logical, intent(in), optional :: global
        !> Optional state return flag. On error, if not requested, the code stops
        type(state_type), intent(out), optional :: err
        !> Handle on the loaded library
        type(shared_library_type) :: lib

        call lib%open(name, path, global, err)
    end function load_library