Illegal internal write?
- From: harper@xxxxxxxxxxxxx (John Harper)
- Date: 28 Feb 2006 13:44:20 +1300
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
.
- Follow-Ups:
- Re: Illegal internal write?
- From: glen herrmannsfeldt
- Re: Illegal internal write?
- From: robert . corbett
- Re: Illegal internal write?
- Prev by Date: Re: MPI
- Next by Date: Re: MPI
- Previous by thread: Standards conforming or not?
- Next by thread: Re: Illegal internal write?
- Index(es):
Relevant Pages
|