Path: utzoo!attcan!uunet!husc6!spdcc!esegue!johnl From: johnl@iecc.cambridge.ma.us (John R. Levine) Newsgroups: comp.lang.fortran Subject: Re: Proper interpretation of blank control in Fortran 77 Message-ID: <1990Oct29.052545.20893@iecc.cambridge.ma.us> Date: 29 Oct 90 05:25:45 GMT References: <1990Oct23.013848.16071@dmp.csiro.au> Reply-To: johnl@iecc.cambridge.ma.us (John R. Levine) Organization: I.E.C.C., Cambridge MA 02238 Lines: 36 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."