Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ttrdc.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.lang.f77 Subject: Re: Minor I/O bug (and my favorite f77 I/O bug) Message-ID: <670@ttrdc.UUCP> Date: Fri, 3-Jan-86 22:59:13 EST Article-I.D.: ttrdc.670 Posted: Fri Jan 3 22:59:13 1986 Date-Received: Sat, 4-Jan-86 17:14:10 EST References: <3117@sdcc3.UUCP> <247@xanth.UUCP> <115@sdcsmb.UUCP> Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 56 In article <115@sdcsmb.UUCP>, pmontgom@sdcsmb.UUCP (Peter Montgomery) writes: >In article <247@xanth.UUCP> tadguy@xanth.UUCP (Tad Guy) writes: >>>The f77 compiler complains of a syntax error at the first line of the >>>following program (4.2bsd on VAX, v2.0 on SUN): >>> write(6,10) (-1) >>>10 format(i2) >>> end >>I haven't found a fortran compiler yet that will accept that line. > > Both the Control Data FTN 4 (1966 plus extensions, such as >expressions in iolists) and FTN 5 (1977) compilers accept the construct. > The WRITE statement corresponds to FORTRAN 77. The FORMAT should >be changed to (i3) or (1x,i2), since FORTRAN 77 does not permit a "-" as a >carriage control. > Peter Montgomery I think the f77 compiler is expecting an implied DO and then barfing when it doesn't get one. VMS Fortran swallows this OK. If the write is changed to something like write(6,10) (-1,i=1,1) f77 is happy. But yes it is a bug. My favorite I/O bug is character*10 buf integer num buf = '12' read(buf,'(I2)',err=20) num write(6,*)num stop 20 write(6,*)'Error!',num stop end The output will be Error! 12 [can anybody figure out WHY, and/or suggest a patch? Oh yes, if you do read(buf,'(I2)',iostat=i) num you get a core dump. Both Berkeley and AT&T Unix f77's are guilty of this. If the formatted I/O is done from a file it works fine; only with internal I/O it seems to barf.] -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!ihnp4!ttrdc!levy