<?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 formatting in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947221#M18591</link>
    <description>Sorry, wrong tags: &lt;BR /&gt; &lt;BR /&gt;Hello,  &lt;BR /&gt; &lt;BR /&gt;I wonder why the following two methods of filling the strings fmt(i), generate different results.  &lt;BR /&gt;In the debugger the strings appear to be exactly the same, but writing the strings using the format statement generates different results.  &lt;BR /&gt; &lt;BR /&gt;The first method gives: 'F9.0 '  &lt;BR /&gt;The second method gives: 'F9.0 F6.0 '  &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
implicit none  
character(6) :: fmt(4)  
character(12) :: bufstr(2)  
interface  
  character(6) function frmt(cs)  
    character(6), intent(in) :: cs  
  end function  
end interface  
 
fmt(1)=frmt('F9.0')  
fmt(2)=frmt('F6.0')  
write(bufstr(1),100) fmt(1),fmt(2)  
fmt(3)='F9.0'  
fmt(4)='F6.0'  
write(bufstr(2),100) fmt(3),fmt(4)  
100 format(A,A)  
end  
 
character(6) function frmt(cs)  
  character(6), intent(in) :: cs  
  frmt=cs  
end function  
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;It seems to be a hidden length problem, because when I fool the compiler by defining the function frmt as character(4) in the interface section. the result is again as it should be.  &lt;BR /&gt; &lt;BR /&gt;Thanks,  &lt;BR /&gt; &lt;BR /&gt;Walter Kramer</description>
    <pubDate>Thu, 12 Apr 2001 23:15:08 GMT</pubDate>
    <dc:creator>Intel_C_Intel</dc:creator>
    <dc:date>2001-04-12T23:15:08Z</dc:date>
    <item>
      <title>String formatting</title>
      <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947220#M18590</link>
      <description>Hello, &lt;BR /&gt; &lt;BR /&gt;I wonder why the following two methods of filling the strings fmt(i), generate different results. &lt;BR /&gt;In the debugger the strings appear to be exactly the same, but writing the strings using the format statement generates different results. &lt;BR /&gt; &lt;BR /&gt;The first method gives: 'F9.0        ' &lt;BR /&gt;The second method gives: 'F9.0  F6.0  ' &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
implicit none 
character(6)  :: fmt(4) 
character(12) :: bufstr(2) 
interface 
  character(6) function frmt(cs) 
    character(6), intent(in) :: cs 
  end function 
end interface 
 
fmt(1)=frmt('F9.0') 
fmt(2)=frmt('F6.0') 
write(bufstr(1),100) fmt(1),fmt(2) 
fmt(3)='F9.0' 
fmt(4)='F6.0' 
write(bufstr(2),100) fmt(3),fmt(4) 
100 format(A,A) 
end 
 
character(6) function frmt(cs) 
  character(6), intent(in) :: cs 
  frmt=cs 
end function 
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;It seems to be a hidden length problem, because when I fool the compiler by defining the function frmt as character(4) in the interface section. the result is again as it should be. &lt;BR /&gt; &lt;BR /&gt;Thanks, &lt;BR /&gt; &lt;BR /&gt;Walter Kramer</description>
      <pubDate>Thu, 12 Apr 2001 23:12:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947220#M18590</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-12T23:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: String formatting</title>
      <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947221#M18591</link>
      <description>Sorry, wrong tags: &lt;BR /&gt; &lt;BR /&gt;Hello,  &lt;BR /&gt; &lt;BR /&gt;I wonder why the following two methods of filling the strings fmt(i), generate different results.  &lt;BR /&gt;In the debugger the strings appear to be exactly the same, but writing the strings using the format statement generates different results.  &lt;BR /&gt; &lt;BR /&gt;The first method gives: 'F9.0 '  &lt;BR /&gt;The second method gives: 'F9.0 F6.0 '  &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt; 
implicit none  
character(6) :: fmt(4)  
character(12) :: bufstr(2)  
interface  
  character(6) function frmt(cs)  
    character(6), intent(in) :: cs  
  end function  
end interface  
 
fmt(1)=frmt('F9.0')  
fmt(2)=frmt('F6.0')  
write(bufstr(1),100) fmt(1),fmt(2)  
fmt(3)='F9.0'  
fmt(4)='F6.0'  
write(bufstr(2),100) fmt(3),fmt(4)  
100 format(A,A)  
end  
 
character(6) function frmt(cs)  
  character(6), intent(in) :: cs  
  frmt=cs  
end function  
&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;It seems to be a hidden length problem, because when I fool the compiler by defining the function frmt as character(4) in the interface section. the result is again as it should be.  &lt;BR /&gt; &lt;BR /&gt;Thanks,  &lt;BR /&gt; &lt;BR /&gt;Walter Kramer</description>
      <pubDate>Thu, 12 Apr 2001 23:15:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947221#M18591</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-12T23:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: String formatting</title>
      <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947222#M18592</link>
      <description>Walter, &lt;BR /&gt;A recent thread introduced me to the Memory Debug Window. Set a breakpoint on your "end" statement and run to that point. Open the Memory window and type fmt as the Address. You'll see that the last two characters of fmt(1) and fmt(2) are NULs (x00), while the last two characters of fmt(3) and fmt(4) are spaces (x20). Looks like the actual arguments have to be padded to six characters. &lt;BR /&gt; &lt;BR /&gt;Dick</description>
      <pubDate>Fri, 13 Apr 2001 01:31:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947222#M18592</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-13T01:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: String formatting</title>
      <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947223#M18593</link>
      <description>Dick, thank you.  &lt;BR /&gt;  &lt;BR /&gt;Luckily I didn't have to pad the actual argument with spaces. I now use character(*) as type definition for the argument. This solves the problem.  &lt;BR /&gt;  &lt;BR /&gt;Walter</description>
      <pubDate>Fri, 13 Apr 2001 05:05:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947223#M18593</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-13T05:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: String formatting</title>
      <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947224#M18594</link>
      <description>I am still curious.  &lt;BR /&gt;If actual character argument A is passed to dummy argument B, and A has less characters than B, then B will be padded with NUL characters. In an ordinary assignment B=A, B will be padded with blanks. &lt;BR /&gt;I this a consequence of passing by reference? &lt;BR /&gt; &lt;BR /&gt;Walter</description>
      <pubDate>Fri, 13 Apr 2001 15:02:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947224#M18594</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-13T15:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: String formatting</title>
      <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947225#M18595</link>
      <description>Well, when a constant, such as string literal 'F6.0' has to be passed &lt;BR /&gt;into routine by reference, compiler has to "make up" a real address of &lt;BR /&gt;it somehow. Now, Compaq's experts could tell you better, but it &lt;BR /&gt;can be done either by: &lt;BR /&gt; &lt;BR /&gt;a) passing the address where the constant is actually stored in the &lt;BR /&gt;image of .exe file itself or&lt;BR /&gt; &lt;BR /&gt;b) creating a space somewhere on the stack, filling it with the &lt;BR /&gt;value of the constant and passing address of that space. &lt;BR /&gt; &lt;BR /&gt;In your case, what you get as value of the actual argument, is your &lt;BR /&gt;constant plus whatever happened to be immediately behind the space in memory where it is stored. I guess you're just lucky that you get CHAR(0) &lt;BR /&gt;there, but I may be wrong. Point is, that the declaration of dummy argument (LEN=6) just overrides the actual length of the constant (passed &lt;BR /&gt;as hidden argument), which is 4 in the example. &lt;BR /&gt;With simple assignment (B=A) compiler "knows" what's the right thing to &lt;BR /&gt;do, since it has all information present; with your sample, it perhaps could deduce that it should pad the rest with blanks, but it apparently doesn't, &lt;BR /&gt;and I wouldn't blame Compaq for that. &lt;BR /&gt; &lt;BR /&gt;Btw, I deem declaring character arguments other than (LEN=*) bad practice and I don't see why otherwise would it allowed at all -- perhaps someone can tell a good reason, but I don't see it right now. &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
      <pubDate>Fri, 13 Apr 2001 20:59:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947225#M18595</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2001-04-13T20:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: String formatting</title>
      <link>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947226#M18596</link>
      <description>Jugoslav, thanks for your explanation. In the future I will follow your advise and declare all character dummy arguments with (LEN=*). &lt;BR /&gt; &lt;BR /&gt;Walter Kramer</description>
      <pubDate>Sat, 14 Apr 2001 01:18:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/String-formatting/m-p/947226#M18596</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-04-14T01:18:40Z</dc:date>
    </item>
  </channel>
</rss>

