------- Comment #1 from kargl at gcc dot gnu dot org  2008-11-14 18:40 -------
(In reply to comment #0)
> The following program runs without error when compiled with g77 3.4.6 on 
> Redhat
> Linux:
> 
>        character*72 fnint
>        data fnint /'/dev/null'/
>        i=index(fnint,' ')
>        open(unit=29,file=fnint(1:i-1))
>        open(unit=30,file=fnint(1:i-1))
>        write(29,100)
>        write(30,100)
>  100   format('1Hello, world!')
>        end
> 
> When compiled with gfortran 4.3.2 on Redhat Linux, the following error message
> is printed when the program is run:
> 
> At line 5 of file bug.f (unit = 30, file = '')
> Fortran runtime error: File already opened in another unit
> 
> The same error results when I use /dev/tty in place of /dev/null, although 
> this
> too works in g77 3.4.6.
> 
> This bug is causing me to have to modify a program called NONMEM VI to get it
> to run properly.
> 

It's not a bug in gfortran.  It is a bug in your program.
>From the Fortran 95 standard, Section 9.3.4:

   If a file is already connected to a unit, execution of an OPEN
   statement on that file and a different unit is not permitted.

>From the Fortran 77 Standard, Section 12.3.2:

   A unit must not be connected to more than one file at the same time,
   and a file must not be connected to more than one unit at the same time.


-- 


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

Reply via email to