Problem loading large files (IOSTAT=100)

  • Thread starter Thread starter mrz1982
  • Start date Start date
  • Tags Tags
    files
Click For Summary
SUMMARY

The issue of loading large data files in Fortran was resolved by changing the format specification in the READ statement. Initially, the user encountered an IOSTAT value of 100 when attempting to read files with more than 99 columns, indicating a failure in data loading. The solution involved replacing the specific format in the READ statement with asterisk notation, allowing for variable length input records. This adjustment successfully eliminated the error and enabled the loading of files with 100 columns.

PREREQUISITES
  • Understanding of Fortran programming language
  • Familiarity with IOSTAT error handling in Fortran
  • Knowledge of formatted and unformatted I/O operations in Fortran
  • Experience with data file structures and reading techniques
NEXT STEPS
  • Explore Fortran I/O formatting options and their implications
  • Learn about error handling using IOSTAT in Fortran
  • Investigate variable length input records in Fortran
  • Study best practices for managing large datasets in Fortran
USEFUL FOR

Fortran developers, data scientists working with large datasets, and anyone troubleshooting file I/O operations in Fortran.

mrz1982
Messages
10
Reaction score
0
Hi.
I am having problem loading large data files. The files consist of values defined as (with a extra space at the end of each line):
Code:
+1.326000e-005 -1.159306e+000 -1.171263e+000 
+1.327000e-005 -1.159202e+000 -1.173770e+000 
+1.328000e-005 -1.159563e+000 -1.175345e+000
The problem is when the number of colomns in my data file becomes more than 99. It is not a memory issue as 99 colomns with 4001 rows works, but 100 colomns with 1001 rows does not work. I am loading the files for 99 colomns like (var2 needs to be larger for later use):
Code:
REAL var1(1001,99), var2(1001,194)
WRITE(READFMT,'(1H(I2,5HE15.61H))')99
open(1,file='folder/file1',FORM='FORMATTED',IOSTAT=IOS,RECL=1486)
open(2,file='folder/file2',FORM='FORMATTED',IOSTAT=IOS,RECL=1471)
DO t=1,1001
 READ(1,FMT=READFMT,IOSTAT=IOS)(var1(t,x),x=1,99)
 READ(2,FMT=READFMT,IOSTAT=IOS)(var2(t,x),x=1,98)
ENDDO
close(1)
close(2)
and for 100 colomns like:
Code:
REAL var1(1001,100), var2(1001,195)
WRITE(READFMT,'(1H(I2,5HE15.61H))')100
open(1,file='folder/file1',FORM='FORMATTED',IOSTAT=IOS,RECL=1501)
open(2,file='folder/file2',FORM='FORMATTED',IOSTAT=IOS,RECL=1486)
DO t=1,1001
 READ(1,FMT=READFMT,IOSTAT=IOS)(var1(t,x),x=1,100)
 READ(2,FMT=READFMT,IOSTAT=IOS)(var2(t,x),x=1,99)
ENDDO
close(1)
close(2)
I have looked at the IOSTAT value, it returns 100. I have found many values for IOSTAT but not for 100.
I am noticing that as the XXX value in WRITE(READFMT,'(1H(I2,5HE15.61H))')XXX becomes a three digit number the loading is failing i.e. the files can be any size, if the XXX value is larger than 99 the variables, var1 and var2, will be zero.
How can this be solved?

Kind regards!
/Z

I changed the
Code:
READ(1,FMT=READFMT,IOSTAT=IOS)(var1(t,x),x=1,100)
READ(2,FMT=READFMT,IOSTAT=IOS)(var2(t,x),x=1,99)
to
Code:
READ(1,FMT=*,IOSTAT=IOS)(var1(t,x),x=1,100)
READ(2,FMT=*,IOSTAT=IOS)(var2(t,x),x=1,99)
and the problem was solved! :)
 
Last edited:
Technology news on Phys.org


Hi Z,

Thank you for sharing your issue with loading large data files. It seems like the issue may be with the formatting of your READFMT statement. I would recommend trying to change the format to something like '(1H(I2,5HE15.61H))' which specifies the number of characters to be read. Additionally, you may want to try using the "*" format option in your READ statement, which allows for variable length input records.

I hope this helps solve your problem. If not, please provide more information about the specific error message you are receiving and I will do my best to assist further.


 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K