c_ptr_to_f_string Subroutine

private subroutine c_ptr_to_f_string(cp, fstr)

Convert a c_ptr to a string into a Fortran string.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: cp
character(len=:), intent(out), allocatable :: fstr

Calls

proc~~c_ptr_to_f_string~~CallsGraph proc~c_ptr_to_f_string c_interface_module::c_ptr_to_f_string interface~strlen c_interface_module::strlen proc~c_ptr_to_f_string->interface~strlen s s proc~c_ptr_to_f_string->s

Called by

proc~~c_ptr_to_f_string~~CalledByGraph proc~c_ptr_to_f_string c_interface_module::c_ptr_to_f_string proc~initialize_geopotential_model c_interface_module::initialize_geopotential_model proc~initialize_geopotential_model->proc~c_ptr_to_f_string

Source Code

    subroutine c_ptr_to_f_string(cp,fstr)

    implicit none

    type(c_ptr),intent(in) :: cp
    character(len=:),allocatable,intent(out) :: fstr

    integer :: ilen  !! string length

    ilen = strlen(cp)
    block
        !convert the C string to a Fortran string
        character(kind=c_char,len=ilen+1),pointer :: s
        call c_f_pointer(cp,s)
        fstr = s(1:ilen)
        nullify(s)
    end block

    end subroutine c_ptr_to_f_string