FIX: Internal Read and MORE I/O List Items than in FORMAT

ID: Q74461


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 3.3, 4.0, 4.01, 4.1, 5.0, 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0, 1.0a
  • Microsoft Fortran Powerstation 32 for Windows NT, version 1.0


SYMPTOMS

In Microsoft FORTRAN versions 3.3, 4.0, 4.01, 4.1, 5.0, and 5.1, an internal file is not treated as a single record when a READ statement contains extra list items beyond the format specification's corresponding edit descriptors.


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in FORTRAN PowerStation, version 4.0.


MORE INFORMATION

The ANSI 77 Standard states that when there are more input or output list items than the number of specified FORMAT statement edit descriptors:

"...the file is positioned at the beginning of the next record and format control then reverts to the beginning of the format specification terminated by the last preceding right parenthesis."
The ANSI 77 Standard also states:
"...if an [internal] file is a character variable, character array element, or character substring, it consists of a single record."
The latter statement means that while reading from an internal file that is a character variable, character array element, or character substring, if more list items appear on a statement beyond the corresponding edit descriptors within the FORMAT, an end-of-file should be encountered.

However, Microsoft FORTRAN treats each character of a character variable as a single record, and will advance the file pointer to the next character in the variable instead of producing the F6501 end of file error message. The following code reproduces the problem:

       character*20 a<BR/>
       a='123456789'<BR/>
       read(a,'(f1.0,f2.0)')x1,x2,x3<BR/>
       print*,x1,x2,x3<BR/>
       end 
The above code will produce the following results:
1.000000 23.000000 4.000000
The run-time error "F6501: end of file encountered" should be generated after the variable x2 is read.

Additional query words: 1.00 5.00 5.10

Keywords : kbFortranPS kbLangFortran
Version : :1.0,1.0a,3.3,4.0,4.01,4.1,5.0,5.1
Platform : MS-DOS NT OS/2 WINDOWS
Issue type :


Last Reviewed: November 5, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.