rsc@merit.edu (Richard Conto) (05/05/90)
In article <XT73_W7ggpc2@ficc.uu.net> peter@ficc.uu.net (Peter da Silva) writes: >> With respect to the C statement: > >> printf("The answer is %d, not %d\n", ans, resp) > >> one can use the following Fortran statement > >> write(*,*)' The answer is',ans,' not',resp > >Will this not pad the numbers "ans" and "resp" with spaces? Fortran I/O is >heavily oriented towards columnar output, to the extent that it's all but >impossible to avoid this. >-- Using the IBM FORTRANVS compiler (which is supposed to be FORTRAN-77 with extensions) on the following program: PROGRAM TESTIO INTEGER I REAL Q C C C DO 10 I=1,10 Q = SQRT(I*1.0) 10 WRITE(*,*) ' SQRT(',I,') is ',Q END I got the following output: SQRT(1,) is 1., SQRT(2,) is 1.414213, SQRT(3,) is 1.732051, SQRT(4,) is 2., SQRT(5,) is 2.236068, SQRT(6,) is 2.44949, SQRT(7,) is 2.645751, SQRT(8,) is 2.828427, SQRT(9,) is 3., SQRT(10,) is 3.162277, Our system's IO library (on MTS) seems to like stuffing ","s on the end of numbers in WRITE statements like the above. Is this what the standard says? --- Richard Conto rsc@merit.edu Richard_Conto@ummts.cc.umich.edu USERW014 at UMICHUM (bitnet) Richard_Conto@um.cc.umich.edu
jlg@lambda.UUCP (Jim Giles) (05/05/90)
From article <1990May4.170754.18659@terminator.cc.umich.edu>, by rsc@merit.edu (Richard Conto): > Using the IBM FORTRANVS compiler (which is supposed to be FORTRAN-77 with > extensions) on the following program: > PROGRAM TESTIO > INTEGER I > REAL Q > DO 10 I=1,10 > Q = SQRT(I*1.0) > 10 WRITE(*,*) ' SQRT(',I,') is ',Q > END > I got the following output: > > SQRT(1,) is 1., > [...] > SQRT(10,) is 3.162277, Your Fortran I/O library is broken. The commas (and blanks) are allowed to be inserted as value _separators_ - so the trailing comma on the each line is wrong. Furthermore: ANSI X3.9-1978, page 13-16, line 14: Character constants produced are not delimited by apostrophes, are not preceded or followed by a value separator, .... So, all the commas or spaces that your library inserted before, After, or between character values are wrong. In short, all the commas in your example output are non-standard. I'd complain to IBM if I were you :-). J. Giles