path_to_c_string Function

private pure function path_to_c_string(s) result(c)

Pack a Fortran string into a null-terminated c_char array for the mkdir binding above. Private duplicate of rdb_ocean_restart_io’s string_to_c (that one is private to its own module) — small enough that sharing it is not worth a cross-module dependency for a two-line helper.

Arguments

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

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


Called by

proc~~path_to_c_string~~CalledByGraph proc~path_to_c_string path_to_c_string proc~ensure_directory_exists ensure_directory_exists proc~ensure_directory_exists->proc~path_to_c_string proc~engine_configure_diag engine_configure_diag proc~engine_configure_diag->proc~ensure_directory_exists proc~engine_setup engine_setup proc~engine_setup->proc~engine_configure_diag proc~complete_ocean_create complete_ocean_create proc~complete_ocean_create->proc~engine_setup proc~driver_run_ocean driver_run_ocean proc~driver_run_ocean->proc~engine_setup proc~driver_validate driver_validate proc~driver_validate->proc~engine_setup proc~driver_run driver_run proc~driver_run->proc~driver_run_ocean proc~rdb_ocean_create_finalize rdb_ocean_create_finalize proc~rdb_ocean_create_finalize->proc~complete_ocean_create proc~rdb_ocean_create_from_string rdb_ocean_create_from_string proc~rdb_ocean_create_from_string->proc~complete_ocean_create

Variables

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

Source Code

   pure function path_to_c_string(s) result(c)
      !! Pack a Fortran string into a null-terminated c_char array for
      !! the `mkdir` binding above. Private duplicate of
      !! `rdb_ocean_restart_io`'s `string_to_c` (that one is private to
      !! its own module) — small enough that sharing it is not worth a
      !! cross-module dependency for a two-line helper.
      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 path_to_c_string