ID: Q125470
5.10 1.00a | 1.00 4.00
MS-DOS | WINDOWS NT
kbprb
The information in this article applies to:
You receive the following message when attempting to run a FORTRAN program:
run-time error F6103: READ(internal) - invalid REAL
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.
Initialize the string variable before using it. This will cause the string to be padded to its full size with spaces, if necessary.
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.
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
FORTRAN ANSI X3.9-1978, para 10.4
Additional reference words: 1.00 1.00a 4.00 5.10
KBCategory: kbprb
KBSubcategory: FORTLngIss
Keywords : kberrmsg kbFortranPS kbLangFortran
Version : 5.10 1.00a | 1.00 4.00
Platform : MS-DOS NT WINDOWS
Last Reviewed: May 23, 1998