<?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 Matrix read-write problem in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797165#M35801</link>
    <description>Dear Arjen&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;I have
applied the same as what you proposed, but it doesn't work.&lt;/P&gt;

&lt;P&gt;For
example, I simply generate a binary file by Matlab and try to read it by
Fortran as below:&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;m file:&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;a=1:1:100; &lt;/P&gt;

&lt;P&gt;fid=fopen('a.txt','w');&lt;/P&gt;

&lt;P&gt;fwrite(fid,
a', 'integer*4');&lt;/P&gt;

&lt;P&gt;fclose(fid);&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;fortran file:&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt; program data_read&lt;/P&gt;

&lt;P&gt; implicit none&lt;/P&gt;

&lt;P&gt; INTEGER::pos&lt;/P&gt;

&lt;P&gt; real:: R&lt;/P&gt;

&lt;P&gt; open(15, FILE='a.txt', ACCESS = 'STREAM')&lt;/P&gt;

&lt;P&gt; pos=10&lt;/P&gt;

&lt;P&gt; read (15,rec=pos) R&lt;/P&gt;

&lt;P&gt; close (15)
&lt;/P&gt;

&lt;P&gt; print *, R&lt;/P&gt;

&lt;P&gt; end program data_read&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;it shows a
very small value close to zero on the screen.&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 22 Jun 2012 17:59:05 GMT</pubDate>
    <dc:creator>mjv_aau</dc:creator>
    <dc:date>2012-06-22T17:59:05Z</dc:date>
    <item>
      <title>Matrix read-write problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797163#M35799</link>
      <description>Hi all,&lt;BR /&gt;&lt;BR /&gt;I would like to read some specific elements of an array stored on a file on the disk, i.e. a matrix. I know which rows and columns my elements are located at but I do not want to waste time to read every element before or after them (since the array is pretty huge). Does anyone know a fast way to move the pointer to these elements and read only them !&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.</description>
      <pubDate>Fri, 22 Jun 2012 12:36:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797163#M35799</guid>
      <dc:creator>mjv_aau</dc:creator>
      <dc:date>2012-06-22T12:36:06Z</dc:date>
    </item>
    <item>
      <title>Matrix read-write problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797164#M35800</link>
      <description>That would depend on the storage format:&lt;BR /&gt;- If the file is structured as a direct-access file, that is, the records are all of the same length.&lt;BR /&gt; then open it with ACCESS = 'DIRECT' and use record number to read the record that contains&lt;BR /&gt; the information you want:&lt;BR /&gt; &lt;BR /&gt; rec = ....&lt;BR /&gt; read( 10, rec = rec ) record_data&lt;BR /&gt;&lt;BR /&gt;- If the file is a binary file without any record structure, then use ACCESS = 'STREAM'.&lt;BR /&gt; With the POS= key in the READ statement you can position the file pointer and read just what &lt;BR /&gt; you need:&lt;BR /&gt;&lt;BR /&gt; pos = ....&lt;BR /&gt; read( 10, pos = pos ) record_data&lt;BR /&gt;&lt;BR /&gt;The computations of the record number or the file position depend entirely on the layout of&lt;BR /&gt;the file. I am not going to speculate on that :) &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Arjen</description>
      <pubDate>Fri, 22 Jun 2012 12:55:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797164#M35800</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2012-06-22T12:55:06Z</dc:date>
    </item>
    <item>
      <title>Matrix read-write problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797165#M35801</link>
      <description>Dear Arjen&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;I have
applied the same as what you proposed, but it doesn't work.&lt;/P&gt;

&lt;P&gt;For
example, I simply generate a binary file by Matlab and try to read it by
Fortran as below:&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;m file:&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;a=1:1:100; &lt;/P&gt;

&lt;P&gt;fid=fopen('a.txt','w');&lt;/P&gt;

&lt;P&gt;fwrite(fid,
a', 'integer*4');&lt;/P&gt;

&lt;P&gt;fclose(fid);&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;fortran file:&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt; program data_read&lt;/P&gt;

&lt;P&gt; implicit none&lt;/P&gt;

&lt;P&gt; INTEGER::pos&lt;/P&gt;

&lt;P&gt; real:: R&lt;/P&gt;

&lt;P&gt; open(15, FILE='a.txt', ACCESS = 'STREAM')&lt;/P&gt;

&lt;P&gt; pos=10&lt;/P&gt;

&lt;P&gt; read (15,rec=pos) R&lt;/P&gt;

&lt;P&gt; close (15)
&lt;/P&gt;

&lt;P&gt; print *, R&lt;/P&gt;

&lt;P&gt; end program data_read&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;

&lt;P&gt;it shows a
very small value close to zero on the screen.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 22 Jun 2012 17:59:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797165#M35801</guid>
      <dc:creator>mjv_aau</dc:creator>
      <dc:date>2012-06-22T17:59:05Z</dc:date>
    </item>
    <item>
      <title>Matrix read-write problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797166#M35802</link>
      <description>&lt;I&gt;&amp;gt; it shows a
very small value close to zero on the screen&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;That is what one should expect in return for writing binary &lt;B&gt;integers&lt;/B&gt; into a file and then reading the same file as if it contained 32-bit &lt;B&gt;reals&lt;/B&gt;.</description>
      <pubDate>Fri, 22 Jun 2012 21:25:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797166#M35802</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-06-22T21:25:46Z</dc:date>
    </item>
    <item>
      <title>Matrix read-write problem</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797167#M35803</link>
      <description>Yes, mecej4 is absolutely right: one of the "problems" of binary files is that they contain no inherent &lt;BR /&gt;information on the type of data. So if you write an integer to the file like in the MATLAB code then you should&lt;BR /&gt;read back an integer. This has nothing to do with the combination MATLAB-Fortran, but everything with the&lt;BR /&gt;way integers and reals are represented in bits or bytes and the nature of binary files.&lt;BR /&gt;&lt;BR /&gt;What you need to do is mirror the data types when reading the file as closely as possible. Watch out for &lt;BR /&gt;strings - in Fortran the length of a string is defined by its declaration or length allocation (from F2003 &lt;BR /&gt;onwards), in other languages it could depend on the content - I do not know where MATLAB stands in this&lt;BR /&gt;spectrum.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Arjen&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jun 2012 07:54:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Matrix-read-write-problem/m-p/797167#M35803</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2012-06-25T07:54:31Z</dc:date>
    </item>
  </channel>
</rss>

