http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60596

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
Looks like a bug in the program (and more importantly
a bug and/or processor-dependent behavior in ifort). 

  !! Unformatted I/O is faster in ifort under linux.
  close(input_unit)
  open(unit=input_unit,access='stream',form='unformatted')

You've closed the input_unit.  The standard states:

    The CLOSE statement is used to terminate the connection
    of a specified unit to an external file.

You then open a new file and associate that new file with
input_unit.  You'll find that you have a file named 'fort.5'
and it has, surprise, a size of 0.

program foo
  use iso_fortran_env
  integer fd,sz
  real x

  fd=10

  open(unit=fd, file='tmp.dat', access='stream')
  do i = 1, 100
     call random_number(x)
     write(fd) x
  end do
  close(fd)

  open(unit=fd, file='tmp.dat', access='stream')
  inquire(unit=fd,size=sz)
  print *, sz
  close(fd)

  open(unit=fd, access='stream')
  inquire(unit=fd,size=sz)
  print *, sz

  close(input_unit)
  open(unit=input_unit, access='stream')
  inquire(unit=input_unit,size=sz)
  print *, sz
  close(input_unit)

end program

troutmask:sgk[239] rm fort.*
troutmask:sgk[240] gfc4x -o z r.f90 && ./z
         512
           0
           0
troutmask:sgk[241] ls -al fort.*
-rw-r--r--  1 sgk  sgk  0 Mar 19 16:14 fort.10
-rw-r--r--  1 sgk  sgk  0 Mar 19 16:14 fort.5

Reply via email to