PRB: Run-time Error F6103: READ (internal) - invalid REAL

Last reviewed: December 9, 1995
Article ID: Q125470
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.1
  • Microsoft FORTRAN PowerStation for MS-DOS, versions 1.0a
  • Microsoft FORTRAN PowerStation 32 for Windows NT, version 1.0 and 4.0

SYMPTOMS

You receive the following message when attempting to run a FORTRAN program:

   run-time error F6103: READ(internal) - invalid REAL

CAUSE

This error may be generated by an internal READ when the string that is the target of the read is not padded with blanks to fill the size of the REAL format edit descriptor.

RESOLUTION

Initialize the string variable before using it. This will cause the string to be padded to its full size with spaces, if necessary.

MORE INFORMATION

The FORTRAN standard does not demand that string variables be initialized by the compiler until an assignment is made. The memory locations will be zeroed, but will not contain proper ASCII codes for characters in a REAL. If you assign characters to a single-element sub-string, the full string will not be initialized.

In the "Sample Code" section of this article, the string buffer will have the characters 1, 2, and 3 in the first three elements of the string. However, because you are not assigning to the entire string, the string is not initialized and the remaining memory locations will contain a 0 (zero) or the NULL character. Because the NULL character is not a legal ASCII value for a REAL, the internal read generates the error message as given above.

To solve the problem, initialize the entire string by assigning a character to it. In the code below, change the comment into an excuted line to solve the problem by assigning a blank to the string. This simple assignment results in the string being filled with all blanks or ASCII character 32, replacing the zeros that were there initially. Blanks are acceptable characters in a READ of a REAL value.

Sample Code

C Compile options needed: none

      CHARACTER*80 buffer
      REAL num

C buffer = ' '

      buffer(1:1) = '1'
      buffer(2:2) = '2'
      buffer(3:3) = '3'

      READ(buffer, '(F7.1)') num

      PRINT*, 'buffer = ', buffer, '  num = ', num

      END

REFERENCES

FORTRAN ANSI X3.9-1978, para 10.4


Additional reference words: 1.00 1.00a 4.00 5.10
KBCategory: kbprg kberrmsg kbprb
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 9, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.