[PATCH] fortran/28213 -- Fix Hollerith in IO list
Feng Wang
wf_cs@yahoo.com
Wed Jul 5 07:45:00 GMT 2006
--- Steve Kargl <sgk@troutmask.apl.washington.edu> wrote:
> On Tue, Jul 04, 2006 at 08:21:54AM -0700, Steve Kargl wrote:
> > On Tue, Jul 04, 2006 at 10:26:55PM +0800, Feng Wang wrote:
> >>
> >> --- Jerry DeLisle <jvdelisle@verizon.net>????:
> >>
> >>> Steve Kargl wrote:
> >>
> >
> >>From Fortran 66, 5.1.1.6, page 10.
> >
> > "This type of constant may be written only in the argument list
> > of a CALL statement and in the data initialization statement."
> >
> > There is an ambiguity with a Hollerith constant in an output statement.
> >
> > program z
> > data i/3horz/
> > data x/3horz/
> > print *, i, x
> > c What value should the following list-directed print statement print?
> > c print *, 3horz
> > end
> >
> > Furthermore, see section A2, "Conflicts with ANSI X3.9-1966,"
> > of the Fortran 77 standard. Item (3) says "Hollerith constants
> > and Hollerith data are not permitted in this standard." However,
> > Appendix C, address the use of Hollerith in a Fortran 77
> > program. In particular, section C6 address IO with the A edit
> > descriptor, but my interpretation (which is sometimes known to
> > be too strict and/or wrong) is that a "print '(A3)', 3horz' is
> > not permitted.
Hollerith constant is a more compiler implementation dependency feature. The
legacy specification is less meaningful than the practice codes. This typeless
literal constant was created to be used as character. So I prefer to accept it
to be printed as character type.
> >
> > Finally, the behavior I implemented is consistent with NAG's
> > Fortran 95 compiler.
ifort is consistent with mine :-)
> atlas:kargl[205] cat z.f
> program z
> data i/3horz/
> data x/3horz/
> print *, i, x
> print *, 3horz
> print '(A3)', i
> end
[wf@WFPC bug]$ ifort z.f
[wf@WFPC bug]$ ./a.out
544895599 2.1213687E-19
orz
orz
And IBM XL Fortran V10.1 online documents say:
(http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlf101l.doc/xlflr/typeless_lit_constants.htm)
When you use a typeless constant in any other context, the constant assumes the
default integer type, with the exception of Hollerith constants. Hollerith
constants assume a character data type when used in the following situations:
1. An H edit descriptor
2. A relational operation with both operands being Hollerith constants
3. An input/output list
>
> Sigh. g77 does something completely different from your patch and
> from mine.
>
> atlas:kargl[203] g77 -o z z.f
> atlas:kargl[204] ./z
> 544895599 2.12136866E-19
> 544895599
> orz
>
> g77 converts the Hollerith constant to an integer in list-directed
> output. This means we probably need to implement the g77 behavior
> for backwards compatibility.
>
The patch enclosed implements g77 behavior, but I still think it is better to
print as character type.
Best Regards,
Feng Wang
--
Creative Compiler Research Group,
National University of Defense Technology, China.
___________________________________________________________
Mp3·è¿ñÃÃ-ÃøèÃøè¸ÃÃÃÃÃ
http://music.yahoo.com.cn/?source=mail_mailbox_footer
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr28213.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20060705/497615f6/attachment.ksh>
More information about the Fortran
mailing list