Microsoft KB Archive/125470

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

Article ID: 125470

Article Last Modified on 12/1/2003

-

APPLIES TO


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

-



This article was previously published under Q125470



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

