sfy@dmp.csiro.au (Shane Youl) (10/23/90)
Can someone provide the *CORRECT* interpretation for the BZ format specifier. The Sun Fortran manual says "BZ - if BZ precedes a specification, a non-leading blank in the input data is considered zero." The VMS Fortran manual says "The BZ descriptor causes the processor to treat all the embedded and trailing blanks it encounters within a numeric input field as zeros." In neither of the above cases is the behaviour flagged as an extension nor a modification of the standard. The following code illustrates the problem under Sun OS and Sun's f77 - sfy_68% cat bz.f character CARD*8 real A, B c 12345678 data CARD / " 1" / c read ( CARD, 1000 ) A,B write ( *, 2000 ) A,B read ( CARD, 1001 ) A,B write ( *, 2000 ) A,B stop 1000 format ( bz,f1.0,f7.0 ) 1001 format ( bz,f2.0,f6.0 ) 2000 format ( 2f8.4 ) end sfy_69% f77 bz.f bz.f: MAIN: sfy_70% a.out 0.NaN0 1.0000 0.0000 1.0000 sfy_71% Under VMS, the two output lines are identical. ADVthanksANCE -- ____ _____ ____ ____ Shane Youl / \ / / / \ / \ CSIRO Division of Mineral Products / /_____ / /_____/ / / PO Box 124 Port Melbourne 3207 / / / / \ / / AUSTRALIA \____/ _____/ / / \ \____/ Internet : sfy@dmp.CSIRO.AU Phone : +61-3-647-0211 SCIENCE ADVANCING AUSTRALIA
johnl@iecc.cambridge.ma.us (John R. Levine) (10/29/90)
In article <1990Oct23.013848.16071@dmp.csiro.au> sfy@dmp.csiro.au (Shane Youl) writes: >Can someone provide the *CORRECT* interpretation for the BZ format specifier. > character CARD*8 > real A, B >c 12345678 > data CARD / " 1" / >c > read ( CARD, 1000 ) A,B > write ( *, 2000 ) A,B > read ( CARD, 1001 ) A,B > write ( *, 2000 ) A,B > stop > 1000 format ( bz,f1.0,f7.0 ) > 1001 format ( bz,f2.0,f6.0 ) > 2000 format ( 2f8.4 ) > end >[results:] > 0.NaN0 1.0000 > 0.0000 1.0000 The Sun result above is wrong. The F77 standard explicitly says that the value of a blank field is always zero. The difference between BZ formatting and the default BN formatting is that under BN, the processor conceptually pushes all non-blank characters to the right side of the field, then pads out on the left with zeros to the field size. Under BZ, blanks are replaced with zeros wherever they may happen to be. BZ formatting is pretty gross, and is useful mostly to be comptible with data files read and written by old Fortran processors that always worked that way. -- John R. Levine, IECC, POB 349, Cambridge MA 02238, +1 617 864 9650 johnl@iecc.cambridge.ma.us, {ima|spdcc|world}!esegue!johnl "Although the moon is smaller than the earth, it is also farther away."
khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) (10/30/90)
In article <1990Oct23.013848.16071@dmp.csiro.au> sfy@dmp.csiro.au (Shane Youl) writes:
...
The following code illustrates the problem under Sun OS and Sun's f77 -
... but which version ?
This is a run with the current FCS version of Sun's product...
$ f77 -V k.f && a.out
version-id of "/usr/lang/SC0.0/f77pass1": SC0.0 f77 1.3.1 FCS 90/06/25
/usr/lang/SC0.0/f77pass1 "-P -cg87" k.f /tmp/f77pass1.01129.s.0.s /tmp/f77pass1.01129.i.1.s /tmp/f77pass1.01129.d.2.s
k.f:
MAIN:
version-id of "/usr/lang/SC0.0/as": SC0.0 90/02/12
/usr/lang/SC0.0/as -o k.o -Q -cg87 /tmp/f77pass1.01129.s.0.s /tmp/f77pass1.01129.i.1.s /tmp/f77pass1.01129.d.2.s
rm /tmp/f77pass1.01129.s.0.s
rm /tmp/f77pass1.01129.i.1.s
rm /tmp/f77pass1.01129.d.2.s
version-id of "/bin/ld": Unknown
/bin/ld -dc -dp -e start -u _MAIN_ -X -o a.out /usr/lang/SC0.0/crt0.o /usr/lang/SC0.0/cg87/_crt1.o -L/usr/lang/SC0.0/cg87 -L/usr/lang/SC0.0 k.o -lF77 -lm -lc
rm k.o
0.0000 1.0000
0.0000 1.0000
$
--
----------------------------------------------------------------
Keith H. Bierman kbierman@Eng.Sun.COM | khb@chiba.Eng.Sun.COM
SMI 2550 Garcia 12-33 | (415 336 2648)
Mountain View, CA 94043