c_to_f_string Subroutine

private subroutine c_to_f_string(c_str, c_len, f_str)

Convert a bind(c) character(kind=c_char) buffer + explicit length into a Fortran allocatable string. No null-termination assumption — c_len is authoritative (matches the recovered precedent’s convention).

Arguments

Type IntentOptional Attributes Name
character(kind=c_char, len=1), intent(in) :: c_str(c_len)
integer(kind=c_int), intent(in) :: c_len
character(len=:), intent(out), allocatable :: f_str

Called by

proc~~c_to_f_string~~CalledByGraph proc~c_to_f_string c_to_f_string proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~c_to_f_string proc~rdb_ocean_create_pending rdb_ocean_create_pending proc~rdb_ocean_create_pending->proc~c_to_f_string proc~rdb_ocean_get_diagnostic_ptr rdb_ocean_get_diagnostic_ptr proc~rdb_ocean_get_diagnostic_ptr->proc~c_to_f_string proc~rdb_ocean_get_tracer_ptr rdb_ocean_get_tracer_ptr proc~rdb_ocean_get_tracer_ptr->proc~c_to_f_string proc~rdb_ocean_required_halo rdb_ocean_required_halo proc~rdb_ocean_required_halo->proc~c_to_f_string proc~rdb_ocean_set_tracer rdb_ocean_set_tracer proc~rdb_ocean_set_tracer->proc~c_to_f_string

Variables

Type Visibility Attributes Name Initial
integer, private :: i

Source Code

   subroutine c_to_f_string(c_str, c_len, f_str)
      !! Convert a `bind(c)` `character(kind=c_char)` buffer + explicit
      !! length into a Fortran allocatable string. No null-termination
      !! assumption — `c_len` is authoritative (matches the recovered
      !! precedent's convention).
      integer(c_int), intent(in) :: c_len
      character(kind=c_char), intent(in) :: c_str(c_len)
      character(len=:), allocatable, intent(out) :: f_str

      integer :: i

      allocate (character(len=c_len) :: f_str)
      do i = 1, c_len
         f_str(i:i) = c_str(i)
      end do
   end subroutine c_to_f_string