string_to_c Function

private pure function string_to_c(s) result(c)

Pack a Fortran string into a null-terminated c_char array.

Arguments

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

Return Value character(kind=c_char, len=1), allocatable, (:)


Called by

proc~~string_to_c~~CalledByGraph proc~string_to_c string_to_c proc~posix_rename posix_rename proc~posix_rename->proc~string_to_c proc~ocean_restart_write_local ocean_restart_write_local proc~ocean_restart_write_local->proc~posix_rename proc~ocean_state_restart_write ocean_state_restart_write proc~ocean_state_restart_write->proc~ocean_restart_write_local proc~ocean_state_restart_write_drop_field ocean_state_restart_write_drop_field proc~ocean_state_restart_write_drop_field->proc~ocean_restart_write_local proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~ocean_state_restart_write proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean

Variables

Type Visibility Attributes Name Initial
integer, private :: i
integer, private :: n

Source Code

   pure function string_to_c(s) result(c)
      !! Pack a Fortran string into a null-terminated c_char array.
      character(len=*), intent(in) :: s
      character(kind=c_char), allocatable :: c(:)
      integer :: i, n
      n = len_trim(s)
      allocate (c(n + 1))
      do i = 1, n
         c(i) = s(i:i)
      end do
      c(n + 1) = c_null_char
   end function string_to_c