<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: passing an array of strings from Fortran to C in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212168#M151949</link>
    <description>&lt;P&gt;Thanks, Ian. What about:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    subroutine OCD()
        use, intrinsic :: iso_c_binding
        implicit none! (external)
        integer            :: howmany, J
        integer, parameter :: nmlen = 40
        integer(c_int)     :: OK
        character(len=nmlen,kind=c_char), allocatable, target :: names(:)
        type (c_ptr), allocatable                             :: comps(:)
        names = [character(nmlen) :: "methane", "ethane", &amp;amp;
                                     "propane", "i-butane"   ]
        howmany = size( names )
        allocate (comps( howmany))
        do J = 1 , howmany
            names(J) = trim(names(J)) // C_NULL_CHAR
            comps(J) = c_loc( names(J)) 
        enddo
        ok = SetupComponents(comps, howmany)
    end subroutine OCD&lt;/LI-CODE&gt;
&lt;P&gt;P.S. Modfied code to correct errors pointed out by GVautier below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Sep 2020 23:43:23 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2020-09-24T23:43:23Z</dc:date>
    <item>
      <title>passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211651#M151915</link>
      <description>&lt;P&gt;Hi all, I'm trying to pass an array of strings allocated in Fortran to a C function that takes a char** argument.&lt;/P&gt;
&lt;P&gt;The C function is this:&lt;/P&gt;
&lt;P&gt;int SetupComponents(char** compnames, int numnames)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;for (int i = 0; i &amp;lt; numnames; i++)&lt;BR /&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; /* Do setup work in here*/&lt;BR /&gt;&amp;nbsp; &amp;nbsp;}&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;An example of the Fortran code that calls this is:&lt;/P&gt;
&lt;P&gt;character(len=10,kind=c_char), allocatable :: comps(:)&lt;BR /&gt;character(len=10,kind=c_char), allocatable :: c1, c2, c3, c4&lt;/P&gt;
&lt;P&gt;c1 = "methane" ; c2 = "ethane"; c3 = "propane"; c4 = "i-butane"&lt;/P&gt;
&lt;P&gt;allocate (comps(4))&lt;BR /&gt;comps = [c1, c2, c3, c4]&lt;BR /&gt;ok = SetupComponents(comps, 4)&lt;BR /&gt;deallocate (comps)&lt;/P&gt;
&lt;P&gt;The Fortran wrapper to call this is (supposed to be...):&lt;/P&gt;
&lt;P&gt;function SetupComponents(compnames, numnames) result(ok) bind(C, name="SetupComponents")&lt;BR /&gt;use, intrinsic :: ISO_C_BINDING&lt;BR /&gt;character(kind=c_char) :: compnames !WHAT GOES ON THIS LINE?&lt;BR /&gt;integer(c_int), value :: numnames&lt;BR /&gt;integer(c_int) :: ok&lt;BR /&gt;end function SetupComponents&lt;/P&gt;
&lt;P&gt;I've tried various permutations of the "character(kind=c_char) :: compnames..." line but I'm either getting compiler errors about TARGETs or crashes inside the C function, where compnames is garbage but&amp;nbsp;numnames is fine. I'm not a Fortran expert, I know just enough to be dangerous.&lt;/P&gt;
&lt;P&gt;This is an API under development, so we can change any aspect of this to be standards-compliant. Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 22:34:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211651#M151915</guid>
      <dc:creator>damienhocking</dc:creator>
      <dc:date>2020-09-22T22:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211660#M151916</link>
      <description>&lt;P&gt;In C, char** is an array of pointers to strings. So you would need:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;type(C_PTR), dimension(*) :: compnames&lt;/LI-CODE&gt;
&lt;P&gt;Then in your Fortran code you would need to allocate a local array of type(C_PTR) and use C_LOC on each element of the array passed in to fill in the array to be passed to the C routine.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 23:25:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211660#M151916</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2020-09-22T23:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211690#M151920</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/5442"&gt;@Steve_Lionel&lt;/a&gt;&amp;nbsp;that's very helpful. Here's what I have now with a simple example, which appears to work, I can see the names passed in now:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;C prototype:&lt;/P&gt;
&lt;P&gt;int SetupComponents(char** compnames, int numnames);&lt;/P&gt;
&lt;P&gt;Fortran example that calls the above:&lt;/P&gt;
&lt;P&gt;type (c_ptr), dimension(:), allocatable :: comps&lt;BR /&gt;character(len=10,kind=c_char), allocatable, target :: c1, c2, c3, c4&lt;/P&gt;
&lt;P&gt;c1 = "methane" ; c2 = "ethane"; c3 = "propane"; c4 = "i-butane"&lt;/P&gt;
&lt;P&gt;allocate (comps(4))&lt;BR /&gt;comps = [c_loc(c1), c_loc(c2), c_loc(c3), c_loc(c4)]&lt;BR /&gt;ok = SetupComponents(comps, 4)&lt;BR /&gt;deallocate (comps)&lt;/P&gt;
&lt;P&gt;And the interface is:&lt;/P&gt;
&lt;P&gt;function SetupComponents(compnames, numnames) result(ok) bind(C, name="SetupComponents")&lt;BR /&gt;use, intrinsic :: ISO_C_BINDING&lt;BR /&gt;type (c_ptr), dimension(*) :: compnames&lt;BR /&gt;integer(c_int), value :: numnames&lt;BR /&gt;integer(c_int) :: ok&lt;BR /&gt;end function SetupComponents&lt;/P&gt;
&lt;P&gt;This seems to work. Is there anything on the Fortran side I should tweak to get null terminations right or any memory running over the ends?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 02:09:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211690#M151920</guid>
      <dc:creator>damienhocking</dc:creator>
      <dc:date>2020-09-23T02:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211851#M151925</link>
      <description>&lt;P&gt;You should terminate your Fortran strings with NULL when passing to C function.&lt;/P&gt;
&lt;P&gt;c1 = "methane"C ; c2 = "ethane"C; c3 = "propane"C; c4 = "i-butane"C&lt;/P&gt;
&lt;P&gt;c1 = "methane"//char(0) ; c2 = "ethane"//char(0); c3 = "propane"//char(0); c4 = "i-butane"//char(0)&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 13:04:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211851#M151925</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2020-09-23T13:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211858#M151926</link>
      <description>&lt;P&gt;Thanks Jim&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 13:24:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211858#M151926</guid>
      <dc:creator>damienhocking</dc:creator>
      <dc:date>2020-09-23T13:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211880#M151928</link>
      <description>&lt;P&gt;If you want to stick to the standard, concatenate with C_NULL_CHAR instead of the extension "xxx"C.&lt;/P&gt;
&lt;P&gt;The next revision of the standard will (probably) have a F_C_STRING function that returns a NUL-terminated copy of its argument, making this a bit cleaner. (It also will probably have a C_F_STRPOINTER subroutine to convert a NUL-terminated string to a CHARACTER, POINTER of the proper length.)&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 14:03:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211880#M151928</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2020-09-23T14:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211919#M151932</link>
      <description>&lt;P&gt;In the interests of a complete, clean example for future reference, here's the finished code:&lt;/P&gt;
&lt;P&gt;This is the C function to be called from Fortran:&lt;/P&gt;
&lt;PRE&gt;int SetupComponents(char** compnames, int numnames);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the iso_c_binding function that is used to wrap the C function:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(as per Steve Lionel, the&amp;nbsp;char** compnames needs to be an array of c_ptr inside the definition)&lt;/P&gt;
&lt;PRE&gt;function SetupComponents(compnames, numnames) result(ok) bind(C, name="SetupComponents")&lt;BR /&gt;   use, intrinsic :: iso_c_binding&lt;BR /&gt;   type (c_ptr), dimension(*) :: compnames  &lt;BR /&gt;   integer(c_int), value :: numnames&lt;BR /&gt;   integer(c_int) :: ok&lt;BR /&gt;end function SetupComponents&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the Fortran code that calls the function above. The names are now a dynamic array.&lt;/P&gt;
&lt;PRE&gt;integer(4) :: howmany ! how many names are you going to have &lt;BR /&gt;&lt;BR /&gt;! this is the array of names, max 40 characters including null termination&lt;BR /&gt;character(len=40,kind=c_char), allocatable, target :: names(:) ! must be target in order to get the starting C address of each name, which is a C char*&lt;BR /&gt;&lt;BR /&gt;type (c_ptr), dimension(:), allocatable :: comps ! this is what becomes the char** on the C side, an array of C char*, each entry is a starting address (see above)&lt;BR /&gt;&lt;BR /&gt;howmany = 4 ! 4 names&lt;BR /&gt;allocate(names(howmany)) ! allocate the names array&lt;BR /&gt;&lt;BR /&gt;! You must have //C_NULL_CHAR termination on dynamically allocated strings&lt;BR /&gt;! Otherwise on the C side there's no termination and this is very unpleasant&lt;BR /&gt;names(1) = "methane"//C_NULL_CHAR&lt;BR /&gt;names(2) = "ethane"//C_NULL_CHAR&lt;BR /&gt;names(3) = "propane"//C_NULL_CHAR&lt;BR /&gt;names(4) = "i-butane"//C_NULL_CHAR&lt;BR /&gt;&lt;BR /&gt;allocate (comps(howmany)) ! allocate the storage for what the C char** points to &lt;BR /&gt;comps(1) = c_loc(names(1)) ! get the starting C address of each name&lt;BR /&gt;comps(2) = c_loc(names(2))&lt;BR /&gt;comps(3) = c_loc(names(3))&lt;BR /&gt;comps(4) = c_loc(names(4))&lt;BR /&gt;&lt;BR /&gt;ok = SetupComponents(comps, howmany) ! call the C function&lt;BR /&gt;&lt;BR /&gt;deallocate (comps) ! deallocate the C char** array&lt;BR /&gt;deallocate (names) ! deallocate the names&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With thanks to&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/5442"&gt;@Steve_Lionel&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/63968"&gt;@jimdempseyatthecove&lt;/a&gt;&amp;nbsp;for their help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 15:42:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1211919#M151932</guid>
      <dc:creator>damienhocking</dc:creator>
      <dc:date>2020-09-23T15:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212111#M151942</link>
      <description>&lt;P&gt;I think this has been a neat thread for illustrating some usage of C interoperability. Just a small point in that the final code example set my OCD nerves on edge so I had to make a more compact version that was more parametric:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;    subroutine OCD()
        use, intrinsic :: iso_c_binding
        implicit none (external)
        integer            :: howmany, J
        integer, parameter :: nmlen = 40
        integer(c_int)     :: OK
        character(len=nmlen,kind=c_char), allocatable, target :: names(:)
        type (c_ptr), allocatable                             :: comps(:)
        names = [character(nmlen) :: "methane"//C_NULL_CHAR, "ethane"//C_NULL_CHAR, &amp;amp;
                                     "propane"//C_NULL_CHAR, "i-butane"//C_NULL_CHAR   ]
        howmany = size( names )
        allocate (comps( howmany) )
        do J = 1 , howmany
            comps(J) = c_loc( names(J) ) 
        enddo
        ok = SetupComponents(comps, howmany)
    end subroutine OCD&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Sep 2020 06:48:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212111#M151942</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2020-09-24T06:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212118#M151944</link>
      <description>&lt;P&gt;How about, in addition, we leave out the "//C_NULL_CHAR"-s in the initializations, and append "// C_NULL_CHAR" to the argument of&amp;nbsp; C_LOC?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 07:15:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212118#M151944</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-09-24T07:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212163#M151947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/41971"&gt;@mecej4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;How about, in addition, we leave out the "//C_NULL_CHAR"-s in the initializations, and append "// C_NULL_CHAR" to the argument of&amp;nbsp; C_LOC?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You (and the compiler...) are off TARGET with that suggestion.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 10:30:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212163#M151947</guid>
      <dc:creator>IanH</dc:creator>
      <dc:date>2020-09-24T10:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212168#M151949</link>
      <description>&lt;P&gt;Thanks, Ian. What about:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;    subroutine OCD()
        use, intrinsic :: iso_c_binding
        implicit none! (external)
        integer            :: howmany, J
        integer, parameter :: nmlen = 40
        integer(c_int)     :: OK
        character(len=nmlen,kind=c_char), allocatable, target :: names(:)
        type (c_ptr), allocatable                             :: comps(:)
        names = [character(nmlen) :: "methane", "ethane", &amp;amp;
                                     "propane", "i-butane"   ]
        howmany = size( names )
        allocate (comps( howmany))
        do J = 1 , howmany
            names(J) = trim(names(J)) // C_NULL_CHAR
            comps(J) = c_loc( names(J)) 
        enddo
        ok = SetupComponents(comps, howmany)
    end subroutine OCD&lt;/LI-CODE&gt;
&lt;P&gt;P.S. Modfied code to correct errors pointed out by GVautier below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 23:43:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212168#M151949</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-09-24T23:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212193#M151952</link>
      <description>&lt;P&gt;I'd like to mention the un-obvious here...&lt;/P&gt;
&lt;P&gt;It is not clear as to if the C function called (with the char** argument) requires the char** list, and more importantly those strings being pointed to, remain persistent following the call. That being the case, you would not want Fortran to auto-deallocate the arguments. In this situation, consider making the arguments either module variables or attribute them with SAVE.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 12:46:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212193#M151952</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2020-09-24T12:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212206#M151954</link>
      <description>&lt;P&gt;Jim, that's a good point and I didn't explain that aspect. In this particular case, names is a temporary list of components selected from somewhere else in the Fortran world (our client's software). That list is handed to us through the C interface, where we take those names, look those components up in our database and configure our C++ calculation engine based on those components. After that we have the configuration and names is discarded. Said client also has a C# .NET application that we had to develop an API for that's similar to the Fortran. API development takes just as long as the core engineering.&lt;/P&gt;
&lt;P&gt;Thanks to everyone else for their additional feedback, I went all over Google, Stackoverflow, etc trying to find out how to do this and couldn't find anything useful, before coming here. Many of the examples I found showed that there wasn't a clear understanding of how the interop worked let alone what to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 13:30:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212206#M151954</guid>
      <dc:creator>damienhocking</dc:creator>
      <dc:date>2020-09-24T13:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212217#M151955</link>
      <description>&lt;LI-CODE lang="fortran"&gt;        do J = 1 , howmany
            cname = names(J) // C_NULL_CHAR
            comps(J) = c_loc( cname) 
        enddo&lt;/LI-CODE&gt;
&lt;P&gt;For me that doesn't work. All comps(J) will have the same address.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 14:18:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212217#M151955</guid>
      <dc:creator>GVautier</dc:creator>
      <dc:date>2020-09-24T14:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212230#M151957</link>
      <description>&lt;P&gt;You are correct; I have corrected the code taking your comments into account.&lt;/P&gt;
&lt;P&gt;It is probably best to make such changes when working on the full problem rather than on an isolated subroutine.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 16:16:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212230#M151957</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-09-24T16:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212313#M151965</link>
      <description>&lt;P&gt;Instead of:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;names(J) = names(J) // C_NULL_CHAR&lt;/LI-CODE&gt;
&lt;P&gt;you should use:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;names(J) = TRIM(names(J)) // C_NULL_CHAR&lt;/LI-CODE&gt;
&lt;P&gt;otherwise you're including any trailing blanks.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2020 20:51:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1212313#M151965</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2020-09-24T20:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: passing an array of strings from Fortran to C</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1653426#M174731</link>
      <description>&lt;P&gt;Cheers Damien,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't thank you enough for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Andrea&lt;/P&gt;</description>
      <pubDate>Tue, 31 Dec 2024 16:10:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/passing-an-array-of-strings-from-Fortran-to-C/m-p/1653426#M174731</guid>
      <dc:creator>andreamancuso</dc:creator>
      <dc:date>2024-12-31T16:10:45Z</dc:date>
    </item>
  </channel>
</rss>

