<?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 Advice please on a better way to read an enormous text file. in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827127#M50650</link>
    <description>Hi Guys,&lt;BR /&gt;&lt;BR /&gt;Thanks for the replies. I should have been a little clearer about the source data - it comes from a third party package (ArcGIS) so I am unable to change it.&lt;BR /&gt;&lt;BR /&gt;I would like to know a little more about Jim Dempsey's suggestion on multi-threading - how could I apply that to this problem?&lt;BR /&gt;&lt;BR /&gt;Many thanks&lt;BR /&gt;Mike</description>
    <pubDate>Wed, 05 May 2010 00:36:26 GMT</pubDate>
    <dc:creator>michael_green</dc:creator>
    <dc:date>2010-05-05T00:36:26Z</dc:date>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827122#M50645</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have been processing pairs of enormous text files, reading values as reals, manipulating those values, then outputting results to a third enormous text file. The data looks like this, with header info on the first 6 lines, then serious data to follow:&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;ncols 12095&lt;/P&gt;&lt;P&gt;nrows 17716&lt;/P&gt;&lt;P&gt;xllcorner 114.97464999692&lt;/P&gt;&lt;P&gt;yllcorner -35.064354662821&lt;/P&gt;&lt;P&gt;cellsize 0.000226&lt;/P&gt;&lt;P&gt;NODATA_value -9999&lt;/P&gt;&lt;P&gt;-9999 -9999 -9999 -9999 -9999 -9999 27.532 -26.49 -9999 -9999 10.6 -9999 .... etc for 12095 columns and 17716 rows.&lt;BR /&gt;&lt;BR /&gt;I open the file with the following statement:&lt;BR /&gt;open(1,file=grid1,status='old',form='formatted',recordtype='stream_lf',recl=100000,iostat=ios,err=1000)&lt;BR /&gt;&lt;BR /&gt;and after trivial reads of the header information read each record with:&lt;BR /&gt;&lt;BR /&gt;read(1,'(A)',iostat=ios)line !Where line is character(100000)&lt;BR /&gt;&lt;BR /&gt;Then I pick my way along the line looking for the space delimiters (these are not regularly placed) and read the values into an array of reals. The output method is an approximate inverse of the above.&lt;BR /&gt;&lt;BR /&gt;It works, but it's very slow for files of this size. Is there a better way?&lt;BR /&gt;&lt;BR /&gt;With many thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Mike&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2010 08:02:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827122#M50645</guid>
      <dc:creator>michael_green</dc:creator>
      <dc:date>2010-05-04T08:02:24Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827123#M50646</link>
      <description>It appears your priority is to trade fixed format for more compact data, saving on extra blank spaces? Why?&lt;BR /&gt;&lt;BR /&gt;Import your records into Excel, use a macro to convert text to cells using delected delimiter, then do your sums by calling a Fortran DLL, then export your data to a file with tab or comma delimiters?</description>
      <pubDate>Tue, 04 May 2010 09:28:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827123#M50646</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2010-05-04T09:28:39Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827124#M50647</link>
      <description>&lt;P&gt;Have you considered multi-threading the scan for blanks and conversion from text to real?&lt;BR /&gt;&lt;BR /&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2010 15:39:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827124#M50647</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-05-04T15:39:59Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827125#M50648</link>
      <description>If you prepare the data set with comma delimiters in NAMELIST style, then a NAMELIST read will read the data in OK , for example&lt;BR /&gt;&lt;BR /&gt; real(4) mynumbers(24)&lt;BR /&gt; namelist /myrecord/ mynumbers&lt;BR /&gt;&lt;BR /&gt; open(1,file="datafile.txt",form="formatted",status="unknown")&lt;BR /&gt; read(1,NML=myrecord)&lt;BR /&gt;&lt;BR /&gt;will read the following file OK and convert apparent integers to real(4)&lt;BR /&gt;&lt;BR /&gt;&amp;amp;myrecord&lt;BR /&gt;mynumbers=&lt;BR /&gt;-9999,-9999,-9999,-9999,-9999,-9999,27.532,-26.49,-9999,-9999,10.6,-9999,&lt;BR /&gt;-9999,-9999,-9999,-9999,-9999,-9999,27.532,-26.49,-9999,-9999,10.6,-9999&lt;BR /&gt;&amp;amp;end&lt;BR /&gt;&lt;BR /&gt;NAMELIST will accept 6*-9999 to represent 6 consecutive -9999 values, so you can save even more storage space if you write your output data in this form ready for NAMELIST input, if that is one of your requirements (however, NAMELIST output will impose a fixed length for each output value, so it will not produce similar compact data).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 04 May 2010 16:23:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827125#M50648</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2010-05-04T16:23:29Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827126#M50649</link>
      <description>i might suggest lookin at revising how the output is generated.&lt;BR /&gt;what genereates a 12095 col output?&lt;BR /&gt;why not simply output and at the end of each 'record' have a special character/etc for 'end of record?&lt;BR /&gt;Then input does not require the long read/breakdown?&lt;BR /&gt;&lt;BR /&gt;If modifying the input streamis not possible, then i'd suggest looking atmodifying HOW you 'pick along the line looking for space delimiters'.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;brian&lt;BR /&gt;</description>
      <pubDate>Tue, 04 May 2010 16:59:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827126#M50649</guid>
      <dc:creator>bmchenry</dc:creator>
      <dc:date>2010-05-04T16:59:35Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827127#M50650</link>
      <description>Hi Guys,&lt;BR /&gt;&lt;BR /&gt;Thanks for the replies. I should have been a little clearer about the source data - it comes from a third party package (ArcGIS) so I am unable to change it.&lt;BR /&gt;&lt;BR /&gt;I would like to know a little more about Jim Dempsey's suggestion on multi-threading - how could I apply that to this problem?&lt;BR /&gt;&lt;BR /&gt;Many thanks&lt;BR /&gt;Mike</description>
      <pubDate>Wed, 05 May 2010 00:36:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827127#M50650</guid>
      <dc:creator>michael_green</dc:creator>
      <dc:date>2010-05-05T00:36:26Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827128#M50651</link>
      <description>&lt;P&gt;Since it's a text file, you could simply use the list-directed feature:&lt;/P&gt;&lt;P&gt;  open(1,file=grid1,status='old',form='formatted',recordtype='stream_lf',recl=100000,iostat=ios,err=1000)&lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt;  !read the first six lines of the file here&lt;/P&gt;&lt;P&gt;  ...&lt;/P&gt;&lt;P&gt;  allocate (some_data(ncols, nrows))&lt;/P&gt;&lt;P&gt;  read (1, *, iostat = ios) some_data&lt;/P&gt;&lt;P&gt;  if (ios /= 0) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try it, if only to see how fast it is compared to what you're using now.&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2010 07:11:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827128#M50651</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2010-05-05T07:11:53Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827129#M50652</link>
      <description>Unttested non-optimized sketch&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]Simple method (first attempt)

type myType
  integer :: iCellCount
  real, allocatable :: cellData(:)
end type myType

type(myType), allocatable :: threadData(:)

iRow = 0
iMaxThreads = omp_get_mas_threads()
allocate(threadData(iMaxThreads)) ! add error test
iMaxThreadCells = (ncols / iMaxThreads) * 2 ! larger than worst case/thread
do i=1,iMaxThreads
   allocate(threadData(i)%cellData(iMaxThreadCells) ! error test
end do

! file read loop
while(.true.)
  read(1,'(A)',iostat=ios)line      !Where line is character(100000)
  if(ios) exit
  iRow = iRow + 1
  if(iRow &amp;gt; nrows)  PrintErrorAndAbort()
  iLastChar = useFastWayToFindLastCharOfLine(line) ! LENTRIM(line)?
!$omp parallel private(iThread)
  iThread = omp_get_thread_num() + 1 ! use 1-based thread number
  threadData(iThread)%iCellCount = 0
  if(iThread == 1) then
    ! special case for first number on line
    threadData(iThread)%iCellCount = 1
    read(threadData(iThread)%cellData(1), '(F&lt;YOUR.PREFERENCE&gt;)') line
  endif
!$omp do
  do i=1,iLastChar
    if(line(i) == ' ') then
      threadData(iThread)%iCellCount = threadData(iThread)%iCellCount + 1
      if(threadData(iThread)%iCellCount &amp;gt; iMaxThreadCells) PrintErrorAndAbort()
      read(threadData(iThread)%cellData(threadData(iThread)%iCellCount), '(F&lt;YOUR.PREFERENCE&gt;)') line(i+1:)
    endif
  end do ! end of parallel do
  iFill = 1
  do i=,iThread-1
    iFill = iFill + threadData(i)%iCellCount
  end do
  do i=1,threadData(iThread)%iCellCount
     bigArray(iFill, iRow) = threadData(iThread)%cellData(i)
  end do
!$omp end parallel
end do
[/bash]&lt;/YOUR.PREFERENCE&gt;&lt;/YOUR.PREFERENCE&gt;&lt;/PRE&gt;&lt;BR /&gt;Jim&lt;BR /&gt;</description>
      <pubDate>Wed, 05 May 2010 16:35:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827129#M50652</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-05-05T16:35:14Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827130#M50653</link>
      <description>Thanks Jim, this is brilliant stuff - I have never seen this sort of thing before and I'm going to learn heaps.&lt;BR /&gt;&lt;BR /&gt;I have come across a problem immediately though, I've got ...&lt;BR /&gt;&lt;BR /&gt;use omp_lib&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;i = omp_get_max_threads()&lt;BR /&gt;&lt;BR /&gt;This compiles but won't link - "unresolved external symbol". What do I need to do?&lt;BR /&gt;&lt;BR /&gt;Many thanks&lt;BR /&gt;Mike</description>
      <pubDate>Thu, 06 May 2010 08:22:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827130#M50653</guid>
      <dc:creator>michael_green</dc:creator>
      <dc:date>2010-05-06T08:22:21Z</dc:date>
    </item>
    <item>
      <title>Advice please on a better way to read an enormous text file.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827131#M50654</link>
      <description>You must enable OpenMP as a compiler option.&lt;BR /&gt;&lt;BR /&gt;In VS Solution pane&lt;BR /&gt;&lt;BR /&gt;Right-Click on your project&lt;BR /&gt;| Properties&lt;BR /&gt; | Fortran&lt;BR /&gt; | Language&lt;BR /&gt; | Process OpenMP directives&lt;BR /&gt; | &lt;V&gt;(select) Generate Parallel Code&lt;BR /&gt;&lt;BR /&gt;Or from command line add /Qopenmp&lt;BR /&gt;Then on link line add the appropriate OpenMP library&lt;BR /&gt;VS automatically adjust the link line&lt;BR /&gt;&lt;BR /&gt;The sketch code has typographical errors. The intent is to provide you with an overview of a simple parallel process.&lt;BR /&gt;&lt;BR /&gt;After you get this working, you can decide if you want to spend additional time on improving this section of your code. Efforts on parallization of other code in your application might be abetter choice. The code sketch I provided does not overlap the reading of the line with the conversion from text to REAL. An improvement can be attained with overlapping of I/O with conversion.&lt;BR /&gt;&lt;BR /&gt;Jim&lt;BR /&gt;&lt;/V&gt;</description>
      <pubDate>Thu, 06 May 2010 12:24:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Advice-please-on-a-better-way-to-read-an-enormous-text-file/m-p/827131#M50654</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2010-05-06T12:24:15Z</dc:date>
    </item>
  </channel>
</rss>

