<?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: Determining file length in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845336#M63305</link>
    <description>It's pretty easy to get how many bytes are in a file (GETFILEINFOQQ).  But "lines"?  unless you know that each line is the same number of bytes, you will have to read through the file and count the lines yourself.&lt;BR /&gt;&lt;BR /&gt;Most applications like this require that the size of the data be specified in a prior record first.</description>
    <pubDate>Wed, 18 Jan 2006 03:02:44 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2006-01-18T03:02:44Z</dc:date>
    <item>
      <title>Determining file length</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845335#M63304</link>
      <description>Hi everyone,&lt;BR /&gt;&lt;BR /&gt;   I was wondering if there was an easy way to do this.  I wan't to read some data from a file, and input it into an allocatable matrix.      To do this I need to know how many lines there are in the file, so that I can allocate the right size to the matrix.  &lt;BR /&gt;&lt;BR /&gt;   For example, suppose that I have a file called data.dat which has the following data:&lt;BR /&gt;&lt;BR /&gt;1 2 3&lt;BR /&gt;4 5 6 &lt;BR /&gt;7 8 9&lt;BR /&gt;&lt;BR /&gt;I would like to know that there are 3 lines, so that I can allocate my array appropriately.  Is there an easy way to do this?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Alexis</description>
      <pubDate>Wed, 18 Jan 2006 02:48:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845335#M63304</guid>
      <dc:creator>alexismor</dc:creator>
      <dc:date>2006-01-18T02:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: Determining file length</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845336#M63305</link>
      <description>It's pretty easy to get how many bytes are in a file (GETFILEINFOQQ).  But "lines"?  unless you know that each line is the same number of bytes, you will have to read through the file and count the lines yourself.&lt;BR /&gt;&lt;BR /&gt;Most applications like this require that the size of the data be specified in a prior record first.</description>
      <pubDate>Wed, 18 Jan 2006 03:02:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845336#M63305</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2006-01-18T03:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Determining file length</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845337#M63306</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Or in a final last record.&lt;/P&gt;
&lt;P&gt;e.g. FileSize-n bytes is a record containing&lt;/P&gt;
&lt;P&gt; Signature&lt;/P&gt;
&lt;P&gt; File information (array dimensions in this case)&lt;/P&gt;
&lt;P&gt;The Signature is used to verify if the file is corrupt.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2006 04:31:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845337#M63306</guid>
      <dc:creator>jim_dempsey</dc:creator>
      <dc:date>2006-01-18T04:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Determining file length</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845338#M63307</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Alexis&lt;BR /&gt;By the example you gave:&lt;/P&gt;
&lt;P&gt;1 2 3&lt;/P&gt;
&lt;P&gt;4 5 6&lt;/P&gt;
&lt;P&gt;7 8 9&lt;/P&gt;
&lt;P&gt;it seems to be a sequential formatted ASCII file. In this case I use:&lt;/P&gt;
&lt;P&gt;open(unit=3, file='data.txt',form='formatted')&lt;BR /&gt;nlines=0&lt;BR /&gt;do while(.not.eof(3))&lt;BR /&gt;read(3,*)&lt;BR /&gt;nlines=nlines+1&lt;BR /&gt;end do&lt;BR /&gt;rewind(3)&lt;BR /&gt;allocate(matrix(nlines,...))&lt;BR /&gt;do i=1,nlines&lt;BR /&gt;read(3,fmt='....')matrix(i,..)&lt;BR /&gt;end do &lt;/P&gt;
&lt;P&gt;Don't know if read(3,*) would work with binary sequential files.&lt;/P&gt;
&lt;P&gt;Geraldo&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2006 09:17:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Determining-file-length/m-p/845338#M63307</guid>
      <dc:creator>cacciatore</dc:creator>
      <dc:date>2006-01-18T09:17:26Z</dc:date>
    </item>
  </channel>
</rss>

