Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Puzzling error message - BUG?

WSinc
New Contributor I
407 Views

I get this "recursive I/O operation" breakpoint.
Are there ANY rules that prevent me from priniting out the function value as an intermediate result?

It runs OK if I comment out the second print statement near the end.
It might be related to having that array in COMMON rather thanhaving it as input argument.

Why does it say "UNIT -1" - - does that even exist?
That why it seems peculiar, anyway.
************************************************************************************
program test4

integer*1 p(10)/10*10/

integer*8 prod,prod1

common/com1/p

print *,"prod=",prod()

read(*,*)

end program

integer*8 function prod()

common/com1/p

integer*1 p(10)

prod=1

do i=1,10

prod=prod*p(i)

print *,"i=",i," prod=",prod

end do

end

0 Kudos
8 Replies
Steven_L_Intel1
Employee
407 Views
It is a bug in your code, yes. The Fortran standard prohibits starting an I/O operation on a unit while another operation on that unit is in progress. PRINT implies a specific unit. You have a reference to prod() in the PRINT in the main program and prod also does a print - this will result in the "recursive I/O error".
0 Kudos
WSinc
New Contributor I
407 Views
Even when it's a console unit?
How would I modify this so that I can print out an intermediate result (for debugging) anyway.

BTW, is there a way to make the forum letters a little larger?
I don't see an option for that.
0 Kudos
mecej4
Honored Contributor III
407 Views
Avoid expressions in I/O lists that contain references to functions that do I/O. For example, instead of

print *,"prod=",prod()

do

prod1 = prod()
print *, "prod=",prod1

0 Kudos
Steven_L_Intel1
Employee
407 Views
You can use WRITE(6,*) as a replacement for PRINT *, in the function. This will use a separate unit.
0 Kudos
Les_Neilson
Valued Contributor II
407 Views

BTW, is there a way to make the forum letters a little larger?

I don't see an option for that.

If you are using IE to access the forum then from the menu View->Text Size-> you have a choice from Largest to Smallest

Les


Ignore that I've just tried it and it made no difference. Strange.
0 Kudos
David_Kinniburgh
Beginner
407 Views
On Windows, you could use the generic Cntrl-+, Cntrl-- and Cntrl-0 for changing text size (hold down Cntrl then press + etc)
0 Kudos
Steven_L_Intel1
Employee
407 Views
In Firefox, you can use View > Zoom for this and it does work.
0 Kudos
WSinc
New Contributor I
407 Views
Those don't change the text size relative to the window, but still the
zoom is good for senior eyes like mine.

Thanx for suggestion ! ! !

Actually, another answer rather than WRITE(6,*) is to put the function value
in a temporary variable, then print that out instead.
0 Kudos
Reply