Incorrect treatment of separators in list directed read of REALs
THOMAS Paul Richard
prthomas@drfccad.cea.fr
Tue Jan 11 16:46:00 GMT 2005
List directed read of REALs gives variable treatment, depending on the
format of the data being read.
(i) *.* => gobbles trailing ',' but ' ,' is treated as additional null.
(ii) [.]* => ungets trailing ',' so ',' is treated as additional null.
(ii) [*][.]*E* => gobbles trailing ',' or ' ,' so does not produce
extraneous null.
Using input file for list directed read
1.0, 2.0 , 3.0,, 2* , 2*4.0 , 5*99.0
1.0e0, 2.0e0 , 3.0e0,, 2* , 2*4.0e0 , 5*99.0e0
1, 2 , 3,, 2* , 2*4 , 5*99
1, 2 , 3,, 2* , 2*4 , 5*99
g77 (and commercial compilers) give the correct behaviour
reals with decimal point
1 2 3 0 0 0 4 4 99 99
reals with exponent
1 2 3 0 0 0 4 4 99 99
reals read as integers
1 2 3 0 0 0 4 4 99 99
integers
1 2 3 0 0 0 4 4 99 99
gfortran before modification( E-format and integer read are OK)
reals with decimal point
1 2 0 3 0 0 0 4 4 0
reals with exponent
1 2 3 0 0 0 4 4 99 99
reals read as integers
1 0 2 0 3 0 0 0 0 4
integers
1 2 3 0 0 0 4 4 99 99
STOP 0
With the patch below applied, gfortran gives the same behaviour as g77 and
the others.
Logical and complex appear to be OK but I will check this overnight.
Paul Thomas
*********Patch to fix list directed REAL reads***************
*** list_read.old Tue Jan 11 16:37:30 2005
--- ./gcc-4.0-20041205/libgfortran/io/list_read.c Tue Jan 11 17:08:26
2005
***************
*** 1070,1076 ****
CASE_SEPARATORS:
- if (c != '\n')
- unget_char (c); /* Real number that is just a digit-string.
*/
goto done;
default:
--- 1070,1075 ----
***************
*** 1181,1188 ****
break;
CASE_SEPARATORS:
- unget_char (c);
- eat_separator ();
goto done;
default:
--- 1180,1185 ----
***************
*** 1191,1196 ****
--- 1188,1195 ----
}
done:
+ unget_char (c);
+ eat_separator ();
push_char ('\0');
if (convert_real (value, saved_string, length))
More information about the Fortran
mailing list