Incorrect Inline Variable Format May NOT Generate Errors

ID: Q72846


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


SUMMARY

Using Microsoft FORTRAN, a program using a character variable for a FORMAT specifier on a READ or WRITE statement may not generate a run-time error even though the FORMAT specifier is incorrect. This may happen if the FORMAT specifier represented by the character variable is correct up to one edit descriptor past the edit descriptor needed by the I/O list of the corresponding READ or WRITE statement, even if the remainder of the FORMAT specifier is incorrect.

The errors that may be expected correspond to those available within Microsoft FORTRAN that indicate an invalid format descriptor.


MORE INFORMATION

The character variable is parsed as a FORMAT specifier only to the point required by the number of variables in the I/O list of the READ or WRITE statement using the FORMAT specifier. A run-time error will not be generated unless the number of variables in the I/O list causes the run- time routines to parse to the incorrect or syntactically invalid portion of the FORMAT specifier.

For example, in the program below, during the first WRITE statement, the run-time routine parses the format specifier string to obtain the first edit descriptor. It then matches the edit descriptor with the first variable in the WRITE statement. Since these match (an integer variable and an integer edit descriptor), the run-time routine goes back to the FORMAT specifier string to obtain the second edit descriptor. In parsing this edit descriptor and finding it valid, the run-time routine then attempts to match it with the next variable in the WRITE statement. As no second variable exists, the first variable is printed out according to the first FORMAT specifier, and the program continues on.

The difference with the second WRITE statement is that while matching the edit descriptors with the corresponding variables to be written out, the run-time routine attempts to parse the string one edit descriptor further than the first WRITE statement. This edit descriptor is incomplete, and the "F6988: unexpected end of format" error is generated.


       character*20 fmt
       integer i
       i=10
       fmt='(1x,i4,i4'
       write(*,fmt) i     ! prints out i, since the FORMAT is
                          ! correct up to the next edit descriptor
       write(*,fmt) i,i   !  generates run-time error F6988

       end 
This program produces the following output:
10
run-time error F6988: WRITE(CON)
- unexpected end of format

Additional query words: kbinf 1.00 5.00 5.10

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


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