FIX: READ Gets Bad Data After Exit ErrorLast reviewed: September 18, 1997Article ID: Q118393 |
5.10
MS-DOS
kbprg kbbuglist kbfixlist
The information in this article applies to:
SYMPTOMSIf you attempt to do a READ from a file after another READ has exited during an error, the data you obtain will be bad.
STATUSMicrosoft has confirmed this to be a bug in FORTRAN, version 5.1. This problem was corrected in FORTRAN PowerStation for MS-DOS, version 1.0.
MORE INFORMATIONWhen you read from a file, the READ statement transfers control to another line if the "err=" is included and there is a read error. If another READ is attempted immediately, the variables in the iolist contain bad data, usually 0. If your data file looks like
11. *** 22. 33.then the expected output from the attached sample code below will read as follows:
Normal print after read 1. iostat= 0 data(1): 11.000000 Error from read 2. Normal print after read 3. iostat= 0 data(3): 22.000000 Normal print after read 4. iostat= 0 data(4): 33.000000 Printing out data data( 1) = 11.000000 data( 2) = 99.000000 data( 3) = 22.000000 data( 4) = 33.000000 Stop - Program terminated.Both PowerStation for MS-DOS and PowerStation 32 for Windows NT produce the expected output. However the FORTRAN 5.1 produces the following:
Normal print after read 1. iostat= 0 data(1): 11.000000 Error from read 2. Normal print after read 3. iostat= 0 data(3): 0.000000E+00 Normal print after read 4. iostat= 0 data(4): 22.000000 Printing out data data( 1) = 11.000000 data( 2) = 99.000000 data( 3) = 0.000000E+00 data( 4) = 22.000000 Stop - Program terminated. Sample CodeC Compile options needed: none
REAL*4 data(4) DATA data /4*99./ OPEN(15, file="Data") READ(15, "(f3.0)", ERR=10, END=90, IOSTAT=i) data(1) PRINT*, "Normal print after read 1. ", +"iostat=", i, " data(1): ", data(1) GOTO 15 10 PRINT*, "Error from read 1." 15 READ(15, "(f3.0)", ERR=20, END=90, IOSTAT=i) data(2) PRINT*, "Normal print after read 2. ", +"iostat=", i, " data(2): ", data(2) GOTO 25 20 PRINT*, "Error from read 2." 25 READ(15, "(f3.0)", ERR=30, END=90, IOSTAT=i) data(3) PRINT*, "Normal print after read 3. ", +"iostat=", i, " data(3): ", data(3) GOTO 35 30 PRINT*, "error from read 3" 35 READ(15, "(f3.0)", ERR=40, END=90, IOSTAT=i) data(4) PRINT*, "Normal print after read 4. ", +"iostat=", i, " data(4): ", data(4) goto 999 40 PRINT*, "error from read 4" GOTO 999 90 PRINT*, "End of file jump." 999 PRINT*, "Printing out data" DO 1000 i = 1, 4 PRINT*, "data(",i,") = ", data(i) 1000 CONTINUE STOP END |
Additional reference words: 5.10 buglist5.10 fixlist1.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |