c2f_string Function

public function c2f_string(c) result(f)

Convert a C string to a Fortran string.

Arguments

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

C string

Return Value character(len=:), allocatable

Fortran string


Called by

proc~~c2f_string~~CalledByGraph proc~c2f_string popen_module::c2f_string proc~get_command_as_string popen_module::get_command_as_string proc~get_command_as_string->proc~c2f_string

Source Code

    function c2f_string(c) result(f)

        character(len=*),intent(in) :: c !! C string
        character(len=:),allocatable :: f !! Fortran string

        integer :: i

        i = index(c,c_null_char)

        if (i<=0) then
            f = c
        else if (i==1) then
            f = ''
        else if (i>1) then
            f = c(1:i-1)
        end if

    end function c2f_string