<?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 formatted write, allocatable character array in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747954#M5322</link>
    <description>It's an I/O implied-DO loop, which goes back to F77 at least.</description>
    <pubDate>Wed, 14 Jul 2010 19:28:28 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2010-07-14T19:28:28Z</dc:date>
    <item>
      <title>formatted write, allocatable character array</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747951#M5319</link>
      <description>This program:&lt;BR /&gt;&lt;PRE&gt;[fortran]program test&lt;BR /&gt;	implicit none&lt;BR /&gt;&lt;BR /&gt;	character(len=:), allocatable, dimension(:) :: list&lt;BR /&gt;	character(len=*), parameter :: header_10 = '         1         2         3         4         5'&lt;BR /&gt;	character(len=*), parameter :: header_1  = '12345678901234567890123456789012345678901234567890'&lt;BR /&gt;	!&lt;BR /&gt;&lt;BR /&gt;	list = ['pear', '5', 'apple', 'foo', 'J']&lt;BR /&gt;&lt;BR /&gt;	write(*,'(A)')      header_10&lt;BR /&gt;	write(*,'(A)')      header_1&lt;BR /&gt;	write(*,'(5(A10))') 'pear', '5', 'apple', 'foo', 'J'&lt;BR /&gt;	write(*,'(5(A10))') list&lt;BR /&gt;	write(*,*)          list&lt;BR /&gt;&lt;BR /&gt;end program[/fortran]&lt;/PRE&gt; &lt;BR /&gt;Gives me this output when compiled with ifort linux 11.1.072:&lt;BR /&gt;&lt;PRE&gt;[bash]         1         2         3         4         5&lt;BR /&gt;12345678901234567890123456789012345678901234567890&lt;BR /&gt;      pear         5     apple       foo         J&lt;BR /&gt;     pear      5         apple     foo       J    &lt;BR /&gt; pear 5    applefoo  J  [/bash]&lt;/PRE&gt; &lt;BR /&gt;&lt;BR /&gt;I was hoping that the WRITEing the "list" array with the format specified '5(A10))' would lead to right-hand justification like it does when printing the 'pear', '5', etc. list of strings. However, it appears that the elements of the array were each "allocated" 5 characters ('apple' is the longest word with 5 characters) without right-justification, which wasn't the behaviour I was expecting.&lt;BR /&gt;&lt;BR /&gt;Is there a way for me to achieve right-justification of array items during formatted write? Any workarounds?</description>
      <pubDate>Wed, 14 Jul 2010 18:27:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747951#M5319</guid>
      <dc:creator>Alexis_R_</dc:creator>
      <dc:date>2010-07-14T18:27:37Z</dc:date>
    </item>
    <item>
      <title>formatted write, allocatable character array</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747952#M5320</link>
      <description>Your program is nonstandard - the F2003 rules for the array constructor are that each "ac-value" must be the same length. Intel Fortran has an extension where it picks the longest length. You can't have an array where each element has a different length. To be standard-conforming, you'd have to write:&lt;BR /&gt;&lt;BR /&gt;list = [character(5) :: 'pear', '5', 'apple', 'foo', 'J']&lt;BR /&gt;&lt;BR /&gt;Here's one way to get what you want:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]program test&lt;BR /&gt; implicit none&lt;BR /&gt; character(len=:), allocatable, dimension(:) :: list&lt;BR /&gt; character(len=*), parameter :: header_10 = ' 1 2 3 4 5'&lt;BR /&gt; character(len=*), parameter :: header_1 = '12345678901234567890123456789012345678901234567890'&lt;BR /&gt; integer i&lt;BR /&gt; !&lt;BR /&gt; list = ['pear', '5', 'apple', 'foo', 'J']&lt;BR /&gt; write(*,'(A)') header_10&lt;BR /&gt; write(*,'(A)') header_1&lt;BR /&gt; write(*,'(5(A10))') 'pear', '5', 'apple', 'foo', 'J'&lt;BR /&gt; write(*,'(5(A10))') (trim(list(i)),i=1,ubound(list,1))&lt;BR /&gt; write(*,*) list&lt;BR /&gt;end program[/fortran]&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jul 2010 18:50:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747952#M5320</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-07-14T18:50:09Z</dc:date>
    </item>
    <item>
      <title>formatted write, allocatable character array</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747953#M5321</link>
      <description>Thanks for your excellent reply.&lt;BR /&gt;&lt;BR /&gt;I had not encountered the construct you use on line 12, which I guess is a one-line implicit loop structure. Does this have a name? I'd like to read up on it!&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Jul 2010 19:07:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747953#M5321</guid>
      <dc:creator>Alexis_R_</dc:creator>
      <dc:date>2010-07-14T19:07:03Z</dc:date>
    </item>
    <item>
      <title>formatted write, allocatable character array</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747954#M5322</link>
      <description>It's an I/O implied-DO loop, which goes back to F77 at least.</description>
      <pubDate>Wed, 14 Jul 2010 19:28:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747954#M5322</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-07-14T19:28:28Z</dc:date>
    </item>
    <item>
      <title>formatted write, allocatable character array</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747955#M5323</link>
      <description>&amp;gt;&amp;gt;It's an I/O implied-DO loop, which goes back to F77 at least.&lt;BR /&gt;I've used it on Fortran IV (just before F77)</description>
      <pubDate>Fri, 16 Jul 2010 15:12:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/formatted-write-allocatable-character-array/m-p/747955#M5323</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-07-16T15:12:05Z</dc:date>
    </item>
  </channel>
</rss>

