title: Passing an array of strings from c++ to Fortran90
body: <p>I would like to be able to pass an array of strings from c++ to fortran90. I am able to pass double arrays and character arrays with the following fortran module:</p>
  
  <pre><code>MODULE rocker
  
      CONTAINS
  
      SUBROUTINE alltwice(numbers, doubles, n)
          INTEGER*4, INTENT(IN) :: n
          REAL(KIND=dp), INTENT(IN) :: numbers(1:n)
          REAL(KIND=dp), INTENT(OUT) :: doubles(1:n)
          DO i=1,n
              WRITE(*,*) numbers(i)
          END DO
          WRITE(*,*)
          DO i=1,n
              doubles(i)=2.0*numbers(i)
          END DO
      END SUBROUTINE alltwice
  
      SUBROUTINE printstring(str, k)
          CHARACTER(len=k), INTENT(IN) :: str
          WRITE(*,*) str
      END SUBROUTINE printstring
  
      SUBROUTINE printsevstrings(strs, ks, n)
          INTEGER, INTENT(IN) :: n, ks
          CHARACTER(len=ks), INTENT(IN) :: strs(1:n)
          WRITE(*,*)  (strs(i), i=1, n)
      END SUBROUTINE printsevstrings
  
  END MODULE rocker
  </code></pre>
  
  <p>In the c++ code I have</p>
  
  <pre><code>extern "C"{
      extern void __rocker_MOD_alltwice(double a1[], double a2[], const int&amp; n);
      extern void __rocker_MOD_printstring(const char* c, int&amp; length);
      extern void __rocker_MOD_printsevstrings(const char* argv[], int&amp; length, int&amp; number);
  }
  </code></pre>
  
  <p>Now I can pass double arrays using e.g.</p>
  
  <pre><code>const int n=4;
  double a1[n], a2[n];
  for(int i=0;i&lt;n;i++) a1[i]=i+0.5;
  __rocker_MOD_alltwice(a1, a2, n);
  for(int i=0;i&lt;n;i++) {cout &lt;&lt; i &lt;&lt; " " &lt;&lt; a2[i] &lt;&lt; endl;}
  </code></pre>
  
  <p>and character arrays using e.g.</p>
  
  <pre><code>string s="jkljkloi9";
  const char* c=s.c_str();
  int length=s.length();
  __rocker_MOD_printstring(c, length);
  </code></pre>
  
  <p>but I haven't been able to make something like this work:</p>
  
  <pre><code>int main(int argc, const char* argv[])  {
      length=100;
      const char* passarg[argc];
      for(int i=0;i&lt;argc;i++) passarg[i]=argv[i];
      __rocker_MOD_printsevstrings(passarg, length, argc);
  }
  </code></pre>