Incorrect Inline Variable Format May NOT Generate Errors

Last reviewed: December 11, 1995
Article ID: Q72846
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 5.0 and 5.1
  • Microsoft FORTRAN for OS/2, versions 5.0 and 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0 and 1.0a
  • Microsoft FORTRAN PowerStation 32 for Windows NT, version 1.0 and 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 reference words: kbinf 1.00 5.00 5.10
KBCategory: kbprg
KBSubcategory: FORTLngIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 11, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.