f18-llvm-project icon indicating copy to clipboard operation
f18-llvm-project copied to clipboard

Flang demands a FILE specifier when STATUS='NEW'

Open sscalpone opened this issue 4 years ago • 5 comments

From NASTRAN-95/mis/endsys.f

% cat o.f
        OPEN (UNIT=97,ACCESS='SEQUENTIAL',STATUS='NEW',ERR=64)
64      CONTINUE
        END
% gfortran -c o.f
o.f:1:72:

         OPEN (UNIT=97,ACCESS='SEQUENTIAL',STATUS='NEW',ERR=64)
                                                                        1
Warning: The STATUS specified in OPEN statement at (1) is ‘NEW’ and no FILE specifier is present
% ifort -c o.f
% flang -c o.f
o.f:1:9: error: If STATUS='NEW' appears, FILE must also appear
          OPEN (UNIT=97,ACCESS='SEQUENTIAL',STATUS='NEW',ERR=64)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

sscalpone avatar Aug 08 '20 22:08 sscalpone

This is an f18 program requirement, which also appears in various forms in f08, f03, f90, and f77. Here are excerpts from f18 and f77. Is there a reasonable interpretation for this statement that would allow it to be executed as an extension? (The processor can't determine all violations at compile time, which is presumably why this is a program requirement, rather than a constraint.)

f18 -- 12.5.6.10 FILE= specifier in the OPEN statement

This specifier shall appear if the STATUS= specifier has the value NEW or REPLACE. This specifier shall not appear if the STATUS= specifier has the value SCRATCH. If the STATUS= specifier has the value OLD, this specifier shall appear unless the unit is connected and the file connected to the unit exists. If this specifier is omitted and the unit is not connected to a file, the STATUS= specifier shall be specified with a value of SCRATCH; in this case, the connection is made to a processor-dependent file.

f77 -- 12.10.1 OPEN Statement

STATUS = sta

sta is a character expression whose value when any trailing blanks are removed is OLD, NEW, SCRATCH, or UNKNOWN. If OLD or NEW is specified, a FILE= specifier must be given.

vdonaldson avatar Aug 10 '20 18:08 vdonaldson

Document somewhere and close?

schweitzpgi avatar Aug 11 '20 15:08 schweitzpgi

I've assigned it to me to create an Issue for NASTRAN and then close.

sscalpone avatar Aug 11 '20 15:08 sscalpone

Closing as this has been sitting here for a while.

schweitzpgi avatar Feb 02 '21 20:02 schweitzpgi

I've got it.

sscalpone avatar Feb 03 '21 03:02 sscalpone