<?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: Fortran list-directed write and read turns huge(1d0) into Infinity. in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-list-directed-write-and-read-turns-huge-1d0-into/m-p/1225604#M152501</link>
    <description>&lt;P&gt;You created this problem when you used list-directed output to write LINE. This uses a "processor-dependent" format which ends up rounding the last few digits of the value from 3157 to 316[0]. When the rounded value is read in, it is too big for a REAL(8).&lt;/P&gt;
&lt;P&gt;If instead you did this:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;write(line,'(E25.17E3)') big&lt;/LI-CODE&gt;
&lt;P&gt;you would get in LINE the value ending in 3157 and this will read correctly into X.&lt;/P&gt;
&lt;P&gt;The moral of the story is to not use list-directed I/O when you care about the formatting.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Nov 2020 01:36:37 GMT</pubDate>
    <dc:creator>Steve_Lionel</dc:creator>
    <dc:date>2020-11-05T01:36:37Z</dc:date>
    <item>
      <title>Fortran list-directed write and read turns huge(1d0) into Infinity.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-list-directed-write-and-read-turns-huge-1d0-into/m-p/1225585#M152500</link>
      <description>&lt;P&gt;This program writes huge(1d0) to an internal file then reads it back. Both are list-directed. But reading gave Infinity, which looks like an ifort bug.&amp;nbsp; I suspect the trouble is that ifort Version&amp;nbsp; 19.1.3.304 Build 20200925_000000 writes&amp;nbsp; 1.797693134862316E+308,&amp;nbsp; which is &amp;gt; huge(1d0). With the same program gfortran gave 1.7976931348623157E+308, which is correct. Evidence:&lt;/P&gt;
&lt;P&gt;johns-laptop:~$ cat testhuge.f90&lt;BR /&gt;program testhuge&lt;BR /&gt;implicit none&lt;BR /&gt;real(kind(1d0)) big,x&lt;BR /&gt;character(80) line&lt;BR /&gt;integer ios&lt;BR /&gt;big = huge(big)&lt;BR /&gt;print *,big&lt;BR /&gt;write(line,*) big&lt;BR /&gt;read(line,*,iostat=ios) x&lt;BR /&gt;if(ios/=0) print "(A,I0)",'iostat from internal read = ',ios &lt;BR /&gt;print *,x&lt;BR /&gt;end program testhuge&lt;/P&gt;
&lt;P&gt;john@johns-laptop:~$ intel/bin/ifort -V testhuge.f90&lt;BR /&gt;Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.3.304 Build 20200925_000000&lt;BR /&gt;Copyright (C) 1985-2020 Intel Corporation. All rights reserved.&lt;/P&gt;
&lt;P&gt;Intel(R) Fortran 19.1-1655&lt;BR /&gt;GNU ld (GNU Binutils for Ubuntu) 2.30&lt;BR /&gt;john@johns-laptop:~$ ./a.out&lt;BR /&gt;1.797693134862316E+308&lt;BR /&gt;Internal read iostat=64&lt;BR /&gt;Infinity&lt;BR /&gt;john@johns-laptop:~$ gfortran testhuge.f90&lt;BR /&gt;john@johns-laptop:~$ ./a.out&lt;BR /&gt;1.7976931348623157E+308&lt;BR /&gt;1.7976931348623157E+308&lt;BR /&gt;johns-laptop:~$&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 00:23:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-list-directed-write-and-read-turns-huge-1d0-into/m-p/1225585#M152500</guid>
      <dc:creator>Harper__John</dc:creator>
      <dc:date>2020-11-05T00:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran list-directed write and read turns huge(1d0) into Infinity.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-list-directed-write-and-read-turns-huge-1d0-into/m-p/1225604#M152501</link>
      <description>&lt;P&gt;You created this problem when you used list-directed output to write LINE. This uses a "processor-dependent" format which ends up rounding the last few digits of the value from 3157 to 316[0]. When the rounded value is read in, it is too big for a REAL(8).&lt;/P&gt;
&lt;P&gt;If instead you did this:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;write(line,'(E25.17E3)') big&lt;/LI-CODE&gt;
&lt;P&gt;you would get in LINE the value ending in 3157 and this will read correctly into X.&lt;/P&gt;
&lt;P&gt;The moral of the story is to not use list-directed I/O when you care about the formatting.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 01:36:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-list-directed-write-and-read-turns-huge-1d0-into/m-p/1225604#M152501</guid>
      <dc:creator>Steve_Lionel</dc:creator>
      <dc:date>2020-11-05T01:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran list-directed write and read turns huge(1d0) into Infinity.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-list-directed-write-and-read-turns-huge-1d0-into/m-p/1225751#M152505</link>
      <description>&lt;P&gt;Here is a similar example to reinforce what Steve L. wrote:&lt;/P&gt;
&lt;LI-CODE lang="fortran"&gt;character(len=30) str
real x,z
x = acos(-1.0)
write(str,*)x
read(str,*)z
print *,tan(x*0.5),tan(z*0.5)
end program
&lt;/LI-CODE&gt;
&lt;P&gt;The output when IFort is used:&amp;nbsp; -2.2877332E+07 -6137956.&lt;/P&gt;
&lt;P&gt;The output from gFortran :&amp;nbsp; -22877332.0 -22877332.0&lt;/P&gt;
&lt;P&gt;You cannot use routine evaluations and list-directed I/O with such corner cases.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2020 13:31:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Fortran-list-directed-write-and-read-turns-huge-1d0-into/m-p/1225751#M152505</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2020-11-05T13:31:47Z</dc:date>
    </item>
  </channel>
</rss>

