[comp.lang.fortran] Fortran77 internal files

cudac@warwick.UUCP (08/13/87)

The following piece of code can produce different effects on different
implementations of Fortran77. It demonstrates the differences in BLANK
handling in formatted input from internal files.

      CHARACTER*8 BUFF
      BUFF = '1'
      READ(BUFF,'(F8.0)') X
      WRITE(*,*) X
      STOP
      END

Unix 4.2 bsd f77 yeilds:-
   1.00000

whilst IBM's VS FORTRAN yields:-
  10000000.0

I can't find anywhere in the Fortran 77 standard which defines the effect
of blank handling on internal files. Any suggestions on which is correct?

Tim Clark.
T.Clark@daisy.warwick.ac.uk    or:-
UUCP:  ...!ukc!warwick!daisy!T.Clark             |Post: Computing Services
ARPA:  T.Clark%daisy.warwick.ac.uk@cs.ucl.ac.uk  |      University of Warwick
JANET: T.Clark@uk.ac.warwick.daisy               |      Coventry,  UK
Phone:	+44 203 523224                    |	 CV4  7AL

Beebe@SCIENCE (Nelson H.F. Beebe) (08/15/87)

X-Us-Mail: "Center for Scientific Computation, South Physics, University of Utah, Salt Lake City, UT 84112"

X-Telephone: (801) 581-5254


Regarding the following observation from T.Clark@daisy.warwick.ac.uk 
>>       CHARACTER*8 BUFF
>>       BUFF = '1'
>>       READ(BUFF,'(F8.0)') X
>>       WRITE(*,*) X
>>       STOP
>>       END
>> 
>> Unix 4.2 bsd f77 yeilds:-
>>    1.00000
>> 
>> whilst IBM's VS FORTRAN yields:-
>>   10000000.0

Sun OS 3.3 (~4.2BSD) gives 1.0, while DEC VAX VMS and
TOPS-20 give the same value as IBM.  The Standard is silent
on the question of BLANK=ZERO or BLANK=NULL for internal
files.  Historically (pre-Fortran 77), BLANK=ZERO was the
default, and on that basis, Unix is wrong, and DEC and IBM
are right.  However, if the BLANK= specifier is omitted in
an OPEN statement, the default is BLANK=NULL, which would
suggest that Unix is correct, and the others are wrong.
However, no OPEN statement is involved for internal files,
so it appears we have a definite ambiguity in ANSI
X3.9-1978.

A programming solution is simply to change the format to use
a BN or BZ item, depending on the desired interpretation of
blanks.
-------