<?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: String in Fortran in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Re-String-in-Fortran/m-p/984137#M26751</link>
    <description>For interaction with which language? &lt;BR /&gt; &lt;BR /&gt;Seriously, CHARACTER*(*) means that any memory associated with STR_OUT is allocated in the caller and info about amount in that memory is passed to Fortran. So, you can't &lt;B&gt;return&lt;/B&gt; string of variable length in Fortran as you couldn't in any language because it isn't &lt;B&gt;your&lt;/B&gt; routine that takes care about the memory. What you can do is to write something into that buffer whatever the size is. &lt;BR /&gt; &lt;BR /&gt;On the other hand, if you mean "how not to expect length argument from the caller", it is possible:&lt;PRE&gt;SUBROUTINE FSub(str_out) 
!DEC$ATTRIBUTES REFERENCE:: str_out 
CHARACTER(100):: str_out 
&lt;/PRE&gt; &lt;BR /&gt;But note that this means "I expect this buffer not to be smaller than 100". If it actually was, you might easily overwrite "caller's" memory and do some nasty thing.  &lt;BR /&gt; &lt;BR /&gt;Note that, for example, almost all Win32 API functions which fill in some string always have an additional length argument which the caller should fill in (e.g. RegQueryValueEx) (although strings are always passed by reference there); that ensures that an error will be returned if the buffer is too small, not that a silent overwrite would occur gobbling the memory. &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
    <pubDate>Sat, 16 Feb 2002 02:21:14 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2002-02-16T02:21:14Z</dc:date>
    <item>
      <title>Re: String in Fortran</title>
      <link>https://community.intel.com/t5/Software-Archive/Re-String-in-Fortran/m-p/984137#M26751</link>
      <description>For interaction with which language? &lt;BR /&gt; &lt;BR /&gt;Seriously, CHARACTER*(*) means that any memory associated with STR_OUT is allocated in the caller and info about amount in that memory is passed to Fortran. So, you can't &lt;B&gt;return&lt;/B&gt; string of variable length in Fortran as you couldn't in any language because it isn't &lt;B&gt;your&lt;/B&gt; routine that takes care about the memory. What you can do is to write something into that buffer whatever the size is. &lt;BR /&gt; &lt;BR /&gt;On the other hand, if you mean "how not to expect length argument from the caller", it is possible:&lt;PRE&gt;SUBROUTINE FSub(str_out) 
!DEC$ATTRIBUTES REFERENCE:: str_out 
CHARACTER(100):: str_out 
&lt;/PRE&gt; &lt;BR /&gt;But note that this means "I expect this buffer not to be smaller than 100". If it actually was, you might easily overwrite "caller's" memory and do some nasty thing.  &lt;BR /&gt; &lt;BR /&gt;Note that, for example, almost all Win32 API functions which fill in some string always have an additional length argument which the caller should fill in (e.g. RegQueryValueEx) (although strings are always passed by reference there); that ensures that an error will be returned if the buffer is too small, not that a silent overwrite would occur gobbling the memory. &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
      <pubDate>Sat, 16 Feb 2002 02:21:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Re-String-in-Fortran/m-p/984137#M26751</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2002-02-16T02:21:14Z</dc:date>
    </item>
  </channel>
</rss>

