c_f_character Subroutine

private subroutine c_f_character(rhs, lhs)

Arguments

Type IntentOptional Attributes Name
character(kind=c_char, len=1), intent(in) :: rhs(*)
character(kind=c_char, len=:), intent(out), allocatable :: lhs

Source Code

subroutine c_f_character(rhs, lhs)
   character(kind=c_char), intent(in) :: rhs(*)
   character(len=:, kind=c_char), allocatable, intent(out) :: lhs

   integer :: ii

   do ii = 1, huge(ii) - 1
      if (rhs(ii) == c_null_char) then
         exit
      end if
   end do
   allocate(character(len=ii-1) :: lhs)
   lhs = transfer(rhs(1:ii-1), lhs)

end subroutine c_f_character