Illegal internal write?



The f95 standard 9.4.4.4, and the f2003 standard 9.5.3.4, both say:

"If an internal file has been specified, an input/output list item
shall not be in the file or associated with the file."

In the WRITE statement in the following program, the input/output
list item is IMHO not in the file, but it is an expression whose
value depends on that of the file. Does that make it "associated"
as that term is used in those Fortran standards?

PROGRAM testnoforall
CHARACTER :: fmts(3)*24 = (/"I0 ","ES11.4","F8.4 "/)
WRITE(fmts,'(A)')("(1X,A,"//trim(fmts(i))//")", i=1,3)
PRINT "(A)",fmts
END PROGRAM testnoforall

Five f95 compilers that I tried accepted the program at compile time.
At run time, four of them printed
(1X,A,I0)
(1X,A,ES11.4)
(1X,A,F8.4)
as I had hoped. However, one (gfortran) printed
(1X,A,) (1X,A,) (1X,A,)

The quoted rule is not in a Constraint, so I can't complain if
a program defying it compiles and runs, but if the program is
standard-conforming, which output is correct?

--
John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@xxxxxxxxx phone (+64)(4)463 5341 fax (+64)(4)463 5045
.



Relevant Pages

  • Re: Strange error msg.
    ... All good compilers have an array subscript bounds check ... to a single precision argument, ... easy to do with constants--pass 1.0 to a subroutine that ... the compiler to make a slew of compile time error checks. ...
    (comp.lang.fortran)
  • Re: Another C# critique (major rewrite!)
    ... >> In the case of a const implementation I'd prefer compile time ... >> validation for all languages though. ... > familiarize myself with compilers. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: merge of character strings
    ... * What happens in mergeif lengths of strings ... are not known at compile time, but are in fact equal at run time? ... Dick's version compiled and ran with all 4 compilers. ...
    (comp.lang.fortran)
  • Re: Difference between variables and functions
    ... So some implementations with minimal ... will do the additional checking and report the error at compile time. ... Sounds like the OP was using one of the latter types of compilers. ... memory and the compilers were deliberately kept simple. ...
    (comp.unix.programmer)