Re: Opening an already-connected unit with status='unknown'

From: Greg Lindahl (lindahl_at_pbm.com)
Date: 01/07/05


Date: 7 Jan 2005 10:52:27 -0800

In article <t8voeg19l08.fsf@parabrisas.esc.cam.ac.uk>,
Toby White <tow21@cam.ac.uk> wrote:

>program status
> open(unit=13,name="file")
>
> open(unit=13,name="file",status='unknown')
>end program

FILE= is standard-conforming, NAME= is an extension.

The F2003 standard says this is illegal in section 9.4.5:

30 If the file to be connected to the unit is the same as the file to which the unit is connected, only the
31 specifiers for changeable modes (9.4.1) may have values different from those currently in effect. If the
32 POSITION= specifier appears in such an OPEN statement, the value specified shall not disagree with
33 the current position of the file. If the STATUS= specifier is included in such an OPEN statement, it shall
34 be specified with the value OLD.

The easy way to avoid this is to CLOSE the unit before opening it again.

-- greg



Relevant Pages

  • Re: old fortran code
    ... is there any connection between the error label 'err=1010' and the ... The specifier ERR=1010 specifies that control should ... raises an I/O error condition. ... If you want execution to terminate if the open statement ...
    (comp.lang.fortran)
  • Re: OPENs STATUS=SCRATCH file name
    ... dispose='delete' option in the open statement, ... of an openspecifier that would specify the close status. ... between normal termination and error termination. ...
    (comp.lang.fortran)
  • Re: Stack size, g77 and segmentation fault
    ... > specific OPEN statement, I might suggest adding a status= specifier to ... > that OPEN and then printing out the returned status value. ... I meant an iostat= specifier. ... Prev by Date: ...
    (comp.lang.fortran)