New unit, inquire and recursive i/o

New unit, inquire and recursive i/o

program test_inquire
implicit none
integer :: i, ios, iunit, junit
open (newunit=iunit, file = 'new.dat', status = 'OLD', iostat = ios)
do i = 1,2
   inquire (file = 'missing1.dat',  number = junit, iostat = ios) 
   if (ios.eq.0) then

	      print *, i, 'ok'

	   elseif (ios .eq. 40) then

	      print *, i, 'Recursive i/o'


	      print *, i, "ios = ", ios

end program test_inquire

The second time round, this seems to catch a recursive i/o error. gfortran runs without error.



4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I tried that with XE [IA-32] and get the same result.

whilst the example of making the same enquiry twice makes no sense, the result is still wrong IMO also.


   inquire (file = 'missing1.dat',  number = junit1, iostat = ios) 

	   inquire (file = 'missing2.dat',  number = junit2, iostat = ios) 

	   inquire (file = 'missing1.dat',  number = junit3, iostat = ios)

Gives ios=0 40 and 40 which is even more wrong!

Compiler XE [IA-32] gives the same results

Thank you for reporting this error. FWIW, the case behaves correctly under Linux but incorrectly on Windows as was noted. I forwarded it to Development and will post updated status as I learn it.

(Internal tracking id: DPD200250673)

Leave a Comment

Please sign in to add a comment. Not a member? Join today