Microsoft KB Archive/72846

= Incorrect Inline Variable Format May NOT Generate Errors =

Article ID: 72846

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN PowerStation 1.0 Standard Edition
 * Microsoft Fortran PowerStation 1.0a for MS-DOS
 * Microsoft FORTRAN PowerStation 32
 * Microsoft FORTRAN PowerStation 32

-



This article was previously published under Q72846



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 &quot;F6988: unexpected end of format&quot; 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: kblangfortran KB72846

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.