PRB: Run-time Error F6103: READ (internal) - invalid REAL
ID: Q125470
|
The information in this article applies to:
-
Microsoft FORTRAN for MS-DOS, version 5.1
-
Microsoft FORTRAN PowerStation for MS-DOS, version 1.0a
-
Microsoft Fortran Powerstation 32 for Windows NT, versions 1.0, 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 query words:
1.00 1.00a 4.00 5.10
Keywords : kberrmsg kbFortranPS kbLangFortran
Version : :1.0,1.0a,4.0,5.1
Platform : MS-DOS NT WINDOWS
Issue type :