Thread View: net.lang.f77
6 messages
6 total messages
Started by Donald R. Fredkin
Fri, 20 Dec 1985 19:44
Minor I/O bug
Author: Donald R. Fredkin
Date: Fri, 20 Dec 1985 19:44
Date: Fri, 20 Dec 1985 19:44
10 lines
1004 bytes
1004 bytes
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 Removal of the parentheses around -1 cures the problem. This seems to violate section 12.8.2.2 of ANSI X3.9-1978, which states that an <output list item> can be "(5) Any other expression ..."
Re: Minor I/O bug
Author: Tad Guy
Date: Tue, 24 Dec 1985 18:57
Date: Tue, 24 Dec 1985 18:57
37 lines
1796 bytes
1796 bytes
In article <3117@sdcc3.UUCP> Donald R. Fredkin (drf@sdcc3.UUCP) 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 > >Removal of the parentheses around -1 cures the problem. This seems to violate >section 12.8.2.2 of ANSI X3.9-1978, which states that an <output list item> >can be "(5) Any other expression ..." I haven't found a fortran compiler yet that will accept that line. The compiler sees the starting paran and is assuming that you are starting an implied do loop: integer array(20), i write(6,10) (array(i),i=1,20) And chokes since that isn't what you are doing. I avoid using () around lists in writes or reads for this reason and since I haven't found necessary to use them. A solution I was told about when I used WATFIV on an IBM 370 was to do this: write(6,10) +(-1) or, more apropriate for your use: write(6,10) -(1) It appears that the presence of a sign forces the element to be evualated as a expression and not a implied-do-loop. Hope this helps... ...tad ihnp4!burl!icase!xanth!tadguy
Re: Minor I/O bug
Author: Peter Montgomery
Date: Tue, 31 Dec 1985 19:33
Date: Tue, 31 Dec 1985 19:33
23 lines
1510 bytes
1510 bytes
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
{aero,allegra,bmcg,burdvax,hplabs,
ihnp4,psivax,randvax,sdcsvax,trwrb}!sdcrdcf!sdcsmb!pmontgom
Don't blame me for the crowded freeways - I don't drive.
Re: Minor I/O bug
Author: Alan T. Bowler [SDG]
Date: Sat, 04 Jan 1986 00:53
Date: Sat, 04 Jan 1986 00:53
26 lines
1763 bytes
1763 bytes
In article <247@xanth.UUCP> tadguy@xanth.UUCP (Tad Guy) writes: >In article <3117@sdcc3.UUCP> Donald R. Fredkin (drf@sdcc3.UUCP) 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 >> >>Removal of the parentheses around -1 cures the problem. This seems to violate >>section 12.8.2.2 of ANSI X3.9-1978, which states that an <output list item> >>can be "(5) Any other expression ..." > >I haven't found a fortran compiler yet that will accept that line. I suggest you have not looked very hard. The IBM/370 and Honeywell DPS-8 Fortran 77 compilers work just fine. Other have pointed out that the compiler from other manufacturers work just fine. > >A solution I was told about when I used WATFIV on an IBM 370 was to do this: WATFIV never claimed to be Fortran 77, just an extension of Fortran IV (alias 66) and as such was not required to accept this. The correct way arround it, if you were working with Fortran compilers that conform to the 1966 standard, is to assign to a variable and use the variable in the WRITE statement.
Re: Minor I/O bug (and my favorite f77 I/O bug)
Author: Daniel R. Levy
Date: Sat, 04 Jan 1986 03:59
Date: Sat, 04 Jan 1986 03:59
56 lines
2573 bytes
2573 bytes
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
Re: Minor I/O bug (and my favorite f77 I/O bug)
Author: Daniel R. Levy
Date: Tue, 07 Jan 1986 09:57
Date: Tue, 07 Jan 1986 09:57
42 lines
2435 bytes
2435 bytes
In article <670@ttrdc.UUCP>, levy@ttrdc.UUCP (That's me) writes: > >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 First, I may owe a retraction on the first statement. I got mail from someone who seemed to know what they were talking about that allowed that (-1) as an output list expression might violate some obscure rule of the Fortran 77 standard (I don't have that venerable document handy so I can't check whether this is kosher or not, though it escapes me why one would WANT to put a lonely constant or even variable within parens and call that an expression). If it IS a violation, than f77, of course, is well within its rights to barf at this "expression." Second, the same mail pointed out to me that the second example worked fine under BSD 4.3. I will not dispute that since I do not have a 4.3 system handy to test with (it does barf on 4.2 and earlier, and on the Sys5r2 and earlier f77's that I have had a chance to try). I still would like to know if the fault lay in the library or in the compiled code that called it, and how it could be patched if it were feasible in the 4.2 (or better, the Sys5) version. -- ------------------------------- 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads