title: How to bind C's char** argument in Fortran?
body: <p>I need to bind a C function in Fortran. The C function's prototype is something like</p>
  
  <pre><code>/* If argv[i] is NULL, then i is the length of argv[] */
  int foo(char* argv[]);
  </code></pre>
  
  <p>I want to call foo in a Fortran subroutine bar</p>
  
  <pre><code>! If argv(i) is a blank string, then i is the length of argv.
  ! Constant MAX_STRING_LEN is the maximal length of any possible element in argv.
  subroutine bar(argv) 
    character(len=*), intent(in) :: argv(*)
  
    character(kind=c_char), dimension(*), allocatable :: argv_c(*) !???
  
    ! convert argv to argv_c element by element, something like
    ! allocate(argv_c(len_trim(argv(i)) + 1) ! Plus 1 to put C_NULL_CHAR
    ! assign argv(i) to argv_c(i)
  
    ierror = foo(argv_c)
    ! deallocate each argv_c(i)
  end subroutine bar
  </code></pre>
  
  <p>I want to know how to declare a prototype for foo. I designed this one, but I am not sure if it is correct. Is this argv interoperable with char**?</p>
  
  <pre><code>function foo(argv) bind(c, name="foo")
      character(kind=c_char), dimension(*), intent(in) :: argv(*)
  end function
  </code></pre>