<?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: Formatting output in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776237#M25214</link>
    <description>&lt;DIV&gt;Ok Les, here it goes&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;For example this is what the real contains:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;1.119999964457385E-001&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;and i was wondering how can i limit this real, following the first post, to amaximum length like1.0000&lt;/DIV&gt;&lt;DIV&gt;I hope this make clearer my goal.&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 26 Apr 2006 17:39:26 GMT</pubDate>
    <dc:creator>patuco</dc:creator>
    <dc:date>2006-04-26T17:39:26Z</dc:date>
    <item>
      <title>Formatting output</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776232#M25209</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hi everyone in the forum,&lt;/DIV&gt;&lt;DIV&gt;just a question because i have no idea how to format the output i need.&lt;/DIV&gt;&lt;DIV&gt;I have a REAL *8 and the output restrictions shows that it should be:&lt;/DIV&gt;&lt;DIV&gt;1.0000 D-08 if the value is less than 1&lt;/DIV&gt;&lt;DIV&gt;1.0000 if the value is [1,9]&lt;/DIV&gt;&lt;DIV&gt;1.0000 D+03 is value bigger than 9&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;and the other problem is whith other variable(type CHARACTER) which represents integers, e.g, 0.000000 1.0000000 2.000000; and i have to return only 0 1 2 .&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Any suggestion about how to format the output?&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;</description>
      <pubDate>Mon, 17 Apr 2006 17:14:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776232#M25209</guid>
      <dc:creator>patuco</dc:creator>
      <dc:date>2006-04-17T17:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting output</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776233#M25210</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Hi everyon in the forum,&lt;/P&gt;&lt;P&gt;according to the lat post to achieve my goal, i was checking how the command FORMAT works but i do not know how to restrict the values.&lt;/P&gt;&lt;P&gt;One of the examples i have tryed :&lt;/P&gt;&lt;P&gt;WRITE(6,20) COM&lt;/P&gt;&lt;P&gt;FORMAT (I&lt;MAX&gt;)&lt;/MAX&gt;&lt;/P&gt;&lt;P&gt;Message Edited by patuco on &lt;SPAN class="date_text"&gt;04-25-2006&lt;/SPAN&gt;&lt;SPAN class="time_text"&gt;02:10 AM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2006 16:09:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776233#M25210</guid>
      <dc:creator>patuco</dc:creator>
      <dc:date>2006-04-25T16:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting output</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776234#M25211</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;First of all FORMAT is not a "command".&lt;/P&gt;&lt;P&gt;It might be useful for you to think offormat as a "template" which is used by the write statement(s) to describe how the variables on the write statement are to be presented.&lt;/P&gt;&lt;P&gt;To takea simplified example as put in your first message you have your REAL*8 variable to print out:&lt;/P&gt;&lt;P&gt;real*8 rvar&lt;/P&gt;&lt;P&gt;.... code to set value of rvar somehow ...&lt;/P&gt;&lt;P&gt;if (rvar .lt 1.0d0) then&lt;/P&gt;&lt;P&gt;write (6,20) rvar&lt;/P&gt;&lt;P&gt;else if (rvar .ge. 1.0d0 .and. rvar .le. 9.0d0) then&lt;/P&gt;&lt;P&gt;write (6,21) rvar&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;write (6,22) rvar&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;20 format(something suitable for numbers less than 1.0)&lt;/P&gt;&lt;P&gt;21 format(for numbers between 1 and 9)&lt;/P&gt;&lt;P&gt;22 format( for numbers greater than 9)&lt;/P&gt;&lt;P&gt;As for your second question. I am not sure I understand correctly. Do you have a character variable which contains the character representation of a real number? for example:&lt;/P&gt;&lt;P&gt;character*10 cvar&lt;/P&gt;&lt;P&gt;cvar = " 1.0000000"&lt;/P&gt;&lt;P&gt;if so then all you need to do is an "internal read" for example:&lt;/P&gt;&lt;P&gt;integer ivar&lt;/P&gt;&lt;P&gt;real rvar&lt;/P&gt;&lt;P&gt;read(cvar,"(F10.0)") rvar ! read the number from the character variable&lt;/P&gt;&lt;P&gt;ivar = nint(rvar) ! Get the nearest integer number to rvar and assign to ivar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;Les&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2006 17:09:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776234#M25211</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2006-04-25T17:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting output</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776235#M25212</link>
      <description>&lt;DIV&gt;Thanks for the explanation and the help Les,&lt;/DIV&gt;&lt;DIV&gt;it is very useful. Another problem is that I do not know how to limit the size of a real number in Fortran.&lt;/DIV&gt;</description>
      <pubDate>Wed, 26 Apr 2006 16:01:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776235#M25212</guid>
      <dc:creator>patuco</dc:creator>
      <dc:date>2006-04-26T16:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting output</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776236#M25213</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Can you explainin moredetail what you mean "limit the size of a real number" ? What is the problem you are trying to solve?&lt;/P&gt;&lt;P&gt;Les&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2006 16:58:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776236#M25213</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2006-04-26T16:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting output</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776237#M25214</link>
      <description>&lt;DIV&gt;Ok Les, here it goes&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;For example this is what the real contains:&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;1.119999964457385E-001&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;and i was wondering how can i limit this real, following the first post, to amaximum length like1.0000&lt;/DIV&gt;&lt;DIV&gt;I hope this make clearer my goal.&lt;/DIV&gt;&lt;DIV&gt;Thanks&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 26 Apr 2006 17:39:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776237#M25214</guid>
      <dc:creator>patuco</dc:creator>
      <dc:date>2006-04-26T17:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting output</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776238#M25215</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;I assume you mean output the real number to a fileor to thescreen?&lt;/P&gt;&lt;P&gt;OK This is where formats apply. You should really read the online manual or get a Fortran book for the full explanation of the format Edit Descriptors (D,E,F,G for real numbers), but here is the simplified version :&lt;/P&gt;&lt;P&gt;real rvar&lt;/P&gt;&lt;P&gt;rvar = 1.119999964457385E-001&lt;/P&gt;&lt;P&gt;write(6,20) rvar&lt;/P&gt;&lt;P&gt;20 format(f10.4)&lt;/P&gt;&lt;P&gt;In the format (f10.4) the "10" says the size of the output is 10 characters in total, and the "4" says output with 4 decimal places. I this case the output would be " 0.1120"&lt;/P&gt;&lt;P&gt;10 characters totalwith 4leading spaces.&lt;/P&gt;&lt;P&gt;Example (F20.10) would be 20 characters total with 10 decimal places, and so on.&lt;/P&gt;&lt;P&gt;Les&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2006 18:19:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Formatting-output/m-p/776238#M25215</guid>
      <dc:creator>Les_Neilson</dc:creator>
      <dc:date>2006-04-26T18:19:28Z</dc:date>
    </item>
  </channel>
</rss>

