------- Comment #7 from burnus at gcc dot gnu dot org  2009-10-13 15:39 -------
(In reply to comment #0)
> The following is rejected by gfortran.  I think it is valid.
> real i
> read(unit=2, 100) i
> 100 format (f10.7)

In case of Fortran 95 it is trivially invalid (cf. comment 3 and comment 5).

In case of Fortran 2003/2008 one has:

R913 io-control-spec is [ UNIT = ] io-unit
                     or [ FMT = ] format
                     or [ NML = ] namelist-group-name
       (long list of other arguments with required keyword specifier)

C910 (R913) An io-unit shall be specified; if the optional characters UNIT=
            are omitted, the io-unit shall be the first item in the
            io-control-spec-list.
C917 (R913) If format appears without a preceding FMT=, it shall be the
            second item in the io-control-spec-list and the first item shall
            be io-unit.
C918 (R913) If namelist-group-name appears without a preceding NML=, it shall 
            be the second item in the io-control-spec-list and the first item
            shall be io-unit.

R901 io-unit is file-unit-number
             or *
             or internal-file-variable

Thus it seems to be allowed. The only question is whether "the first item shall
be io-unit" is only fulfilled when it is not specified with keyword specifier,
i.e. whether "the first item shall be io-unit" is not fulfilled by "unit=2" and
only by "2". My reading is that it applies to both and that thus the example is
_valid_. 
(I think the allowing this syntax is a bit counterintuitive compared to the
common syntax in Fortran, but it is implementable. Possibly it is something
which has been unintentionally changed but won't be corrected as it is
implementable.)

It would be interesting to get the opinion of Richard Maine.


-- 


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

Reply via email to