<?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 Print statement generates weird error message in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803996#M39254</link>
    <description>Good counterexample! &lt;BR /&gt;&lt;BR /&gt;However, given non-conforming code the behavior of the "processor" can be "implementation-dependent". In other words, not every violation of the language rules is required to be caught. And, as you know, not reporting an error is not the same as reporting that errors do not exist.&lt;BR /&gt;&lt;BR /&gt;Try a small change to your second print line:&lt;BR /&gt;&lt;BR /&gt; print *,test1(6),test1(-2)&lt;BR /&gt;&lt;BR /&gt;Producing and looking at the assembly output from the compiler may throw light on the matter. &lt;BR /&gt;&lt;BR /&gt;Briefly, with your second print statement, there is only one expression to print, and the compiler can choose to call the function and evaluate the expression(s) in the I/O list &lt;SPAN style="text-decoration: underline;"&gt;before starting&lt;/SPAN&gt; the I/O.</description>
    <pubDate>Tue, 21 Jun 2011 04:24:58 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2011-06-21T04:24:58Z</dc:date>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803989#M39247</link>
      <description>&lt;P&gt;It does &lt;STRONG&gt;execute&lt;/STRONG&gt; the print statement, but then does this:&lt;BR /&gt;&lt;BR /&gt;numgood= 1&lt;/P&gt;&lt;P&gt;forrtl: severe (40): recursive I/O operation, unit -1, file unknown&lt;/P&gt;&lt;P&gt;Image PC Routine Line Source&lt;/P&gt;&lt;P&gt;Console1.exe 004CC14A Unknown Unknown Unknown&lt;/P&gt;&lt;P&gt;Console1.exe 004C9898 Unknown Unknown Unknown&lt;/P&gt;&lt;P&gt;Console1.exe 0041B54A Unknown Unknown Unknown&lt;/P&gt;&lt;P&gt;Console1.exe 0041D935 Unknown Unknown Unknown&lt;/P&gt;&lt;P&gt;Console1.exe 0040CA83 _NUMGOOD 11 numgood.F90&lt;/P&gt;&lt;P&gt;Console1.exe 004111BE _MAIN__ 69 Sudoku_4.f90&lt;/P&gt;&lt;P&gt;Console1.exe 004D35A3 Unknown Unknown Unknown&lt;/P&gt;&lt;P&gt;Console1.exe 00475427 Unknown Unknown Unknown&lt;/P&gt;&lt;P&gt;Console1.exe 004752FF Unknown Unknown Unknown&lt;/P&gt;&lt;P&gt;kernel32.dll 7C817077 Unknown Unknown Unknown&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;The code is given below.&lt;BR /&gt;Seems pretty straightforward - - so I am puzzled....&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;integer*2 function numgood(level)&lt;/P&gt;&lt;P&gt;implicit NONE&lt;/P&gt;&lt;P&gt;integer*2 imove,level,ng&lt;/P&gt;&lt;P&gt;include "sud008.cmn"&lt;/P&gt;&lt;P&gt;ng=0&lt;/P&gt;&lt;P&gt;do imove=1,nomoves&lt;/P&gt;&lt;P&gt;if(goodmove(imove,level))then&lt;/P&gt;&lt;P&gt;ng=ng+1&lt;/P&gt;&lt;P&gt;endif&lt;/P&gt;&lt;P&gt;end do &lt;/P&gt;&lt;P&gt;print *,"numgood=",ng ! blows up here, or perhaps the next line.&lt;/P&gt;&lt;P&gt;numgood=ng&lt;/P&gt;&lt;P&gt;end function&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2011 18:23:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803989#M39247</guid>
      <dc:creator>WSinc</dc:creator>
      <dc:date>2011-06-16T18:23:09Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803990#M39248</link>
      <description>I suspect that the line called out in the traceback&lt;BR /&gt;&lt;BR /&gt; Console1.exe 004111BE _MAIN__ 69 Sudoku_4.f90&lt;BR /&gt;&lt;BR /&gt;is an I/O statement that contains a reference to the function &lt;I&gt;numgood&lt;/I&gt;. That would explain the complaint of recursive I/O.&lt;BR /&gt;&lt;BR /&gt;What do you have in the COMMON block, and what does the statement on line 69 of sudoku_4.f90 say?&lt;BR /&gt;</description>
      <pubDate>Thu, 16 Jun 2011 18:49:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803990#M39248</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-06-16T18:49:15Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803991#M39249</link>
      <description>I suspect that mecej4 is exactly on target. In particular, it would be a PRINT statement. Fortran disallows starting an I/O operation on a unit while another one is in progress on the same unit.</description>
      <pubDate>Thu, 16 Jun 2011 19:56:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803991#M39249</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-06-16T19:56:54Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803992#M39250</link>
      <description>I don't see why whatMECEJ4 says is relevant.&lt;BR /&gt;First of all NUMGOOD is in quotes, so I am not creating a recursive call.&lt;BR /&gt;Secondly, the unit number it gives is -1.&lt;BR /&gt; I don't even know that those can exist. Aren't they supposed to be positive?&lt;BR /&gt;Third, I thought it was allowed in the &lt;STRONG&gt;current standard&lt;/STRONG&gt; to be able&lt;BR /&gt;to &lt;STRONG&gt;print out&lt;/STRONG&gt; a function value without generating a recursion.&lt;BR /&gt;At least with REAL and LOGICAL types, you can, so - - -&lt;BR /&gt;Why would this be any different?&lt;BR /&gt;&lt;BR /&gt;I replied to this before, but I don't see that last one.&lt;BR /&gt;&lt;BR /&gt;This subroutine works fine:&lt;BR /&gt; &lt;STRONG&gt;real*8 function krudd&lt;BR /&gt; krudd=1.0&lt;BR /&gt; print *,krudd&lt;BR /&gt; end&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;I think I found the problem:&lt;BR /&gt;NUMGOOD is also in the COMMON block,&lt;BR /&gt;so that probably confused the compiler.&lt;BR /&gt;I don't get a warning message, though,&lt;BR /&gt;telling me there's a conflict.&lt;BR /&gt;shouldn't it tell me?&lt;BR /&gt;&lt;BR /&gt;Maybe the compiler guys should look at that?</description>
      <pubDate>Mon, 20 Jun 2011 21:05:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803992#M39250</guid>
      <dc:creator>WSinc</dc:creator>
      <dc:date>2011-06-20T21:05:10Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803993#M39251</link>
      <description>In our implementation, we use negative unit numbers for statements such as PRINT, TYPE, ACCEPT, etc. that don't have a unit number. In Fortran 2008, negative unit numbers are allowed when returned by OPEN(NEWUNIT=).&lt;BR /&gt;&lt;BR /&gt;What we are asking you to look at is the procedure that calls function numgood. We suspect that there is something like:&lt;BR /&gt;&lt;BR /&gt;print *, numgood(arg)&lt;BR /&gt;&lt;BR /&gt;This would not be legal because function NUMGOOD also tries to do a print.</description>
      <pubDate>Mon, 20 Jun 2011 21:17:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803993#M39251</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-06-20T21:17:34Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803994#M39252</link>
      <description>There seems to be some confusion between recursive I/O and recursive functions. Please consider this example, which invokes recursive I/O but has no recursive functions or subroutines in the source code.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]program recursiveIO
integer :: i
write(*,10)(i,isqr(i),i=5,10)
10 format(1x,2I4)

contains
   integer function isqr(ix)
      integer ix
      isqr=ix*ix
      write(*,*)' Function isqr : ',ix,isqr
      return
   end function isqr
end program recursiveIO
[/fortran]&lt;/PRE&gt; &lt;BR /&gt;Compile and run the program with traceback enabled, and then look at the description for Runtime Error-40 in the Intel Fortran documentation.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Jun 2011 02:57:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803994#M39252</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-06-21T02:57:00Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803995#M39253</link>
      <description>Well, this very simple test example does not cause &lt;STRONG&gt;any problems -&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;P&gt;&lt;STRONG&gt;program test&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;x= test1(4)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;print *,"x=",x&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;print *,test1(6)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;read(*,*)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;end&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;function test1(n)&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;test1=n&lt;BR /&gt;&lt;/STRONG&gt;&lt;STRONG&gt;print *,"test1=",test1&lt;BR /&gt;e&lt;/STRONG&gt;&lt;STRONG&gt;nd&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;It runs to completion, with no error messages of any kind.&lt;BR /&gt;Doesn't think it's recursive I/O either.....&lt;BR /&gt;But YOUR EXAMPLE did generate the error message.&lt;BR /&gt;What's the difference?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2011 03:31:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803995#M39253</guid>
      <dc:creator>WSinc</dc:creator>
      <dc:date>2011-06-21T03:31:57Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803996#M39254</link>
      <description>Good counterexample! &lt;BR /&gt;&lt;BR /&gt;However, given non-conforming code the behavior of the "processor" can be "implementation-dependent". In other words, not every violation of the language rules is required to be caught. And, as you know, not reporting an error is not the same as reporting that errors do not exist.&lt;BR /&gt;&lt;BR /&gt;Try a small change to your second print line:&lt;BR /&gt;&lt;BR /&gt; print *,test1(6),test1(-2)&lt;BR /&gt;&lt;BR /&gt;Producing and looking at the assembly output from the compiler may throw light on the matter. &lt;BR /&gt;&lt;BR /&gt;Briefly, with your second print statement, there is only one expression to print, and the compiler can choose to call the function and evaluate the expression(s) in the I/O list &lt;SPAN style="text-decoration: underline;"&gt;before starting&lt;/SPAN&gt; the I/O.</description>
      <pubDate>Tue, 21 Jun 2011 04:24:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803996#M39254</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-06-21T04:24:58Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803997#M39255</link>
      <description>HI -&lt;BR /&gt;sorry I don't know your first name.........&lt;BR /&gt;&lt;BR /&gt;anyway, I did make the minor change you suggested,&lt;BR /&gt;and it &lt;STRONG&gt;did generate&lt;/STRONG&gt; the "Recursive I/O" error mesage.&lt;BR /&gt;&lt;BR /&gt;So, is there any way to avoid this problem later on?&lt;BR /&gt;I do occasionally need to print out the results of a &lt;BR /&gt;function output.</description>
      <pubDate>Tue, 21 Jun 2011 18:20:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803997#M39255</guid>
      <dc:creator>WSinc</dc:creator>
      <dc:date>2011-06-21T18:20:50Z</dc:date>
    </item>
    <item>
      <title>Print statement generates weird error message</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803998#M39256</link>
      <description>&lt;I&gt;&amp;gt; So, is there any way to avoid this problem later on?&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;Two simple ways, which I am sure you have already used a number of times:&lt;BR /&gt;&lt;BR /&gt; 1. Avoid I/O in functions that are going to be used in expressions instead of stand-alone invocations. Instead of writing out intermediate values or error messages, set the value of an integer, say "istat", to one of a set of values. You can either make &lt;B&gt;istat&lt;/B&gt; an extra argument to the function, or keep in in a module that may be used by a helper/reporter function. This is how it is done in, e.g., IMSL. Compare also to &lt;B&gt;errno&lt;/B&gt; in Unix.&lt;BR /&gt;&lt;BR /&gt; 2. Assign the function values to one or more temporary variables in the caller just before the I/O statement, and put the temporary variables in the I/O list expressions.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Jun 2011 18:44:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Print-statement-generates-weird-error-message/m-p/803998#M39256</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-06-21T18:44:13Z</dc:date>
    </item>
  </channel>
</rss>

